From 6150735cd7b33e8556b4c1b113c3180b4092b664 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Mon, 27 Mar 2023 14:10:19 +0000 Subject: [PATCH] CodeGen from PR 23305 in Azure/azure-rest-api-specs Merge bf55525e278bc7f09e18a586abbd026a77c1fe61 into 9d8a951af5d78e24d9d83592107f8d3c2cc417f5 --- .../security/armsecurity/CHANGELOG.md | 169 ++ .../armsecurity/accountconnectors_client.go | 64 +- .../accountconnectors_client_example_test.go | 197 -- .../adaptiveapplicationcontrols_client.go | 71 +- ...applicationcontrols_client_example_test.go | 186 -- .../adaptivenetworkhardenings_client.go | 83 +- ...venetworkhardenings_client_example_test.go | 106 - .../advancedthreatprotection_client.go | 45 +- ...cedthreatprotection_client_example_test.go | 63 - .../security/armsecurity/alerts_client.go | 221 +- .../armsecurity/alerts_client_example_test.go | 323 --- .../alertssuppressionrules_client.go | 67 +- ...rtssuppressionrules_client_example_test.go | 149 -- .../armsecurity/allowedconnections_client.go | 55 +- .../allowedconnections_client_example_test.go | 84 - .../armsecurity/apicollection_client.go | 181 ++ .../apicollectionoffboarding_client.go | 101 + .../apicollectiononboarding_client.go | 111 + .../armsecurity/application_client.go | 54 +- .../application_client_example_test.go | 89 - .../armsecurity/applications_client.go | 30 +- .../applications_client_example_test.go | 41 - .../armsecurity/assessments_client.go | 69 +- .../assessments_client_example_test.go | 125 -- .../armsecurity/assessmentsmetadata_client.go | 85 +- ...assessmentsmetadata_client_example_test.go | 156 -- .../armsecurity/automations_client.go | 91 +- .../automations_client_example_test.go | 299 --- .../autoprovisioningsettings_client.go | 56 +- ...rovisioningsettings_client_example_test.go | 87 - .../security/armsecurity/autorest.md | 7 +- .../security/armsecurity/client_factory.go | 339 +++ .../armsecurity/complianceresults_client.go | 44 +- .../complianceresults_client_example_test.go | 60 - .../armsecurity/compliances_client.go | 45 +- .../compliances_client_example_test.go | 60 - .../connectorapplication_client.go | 70 +- ...onnectorapplication_client_example_test.go | 89 - .../connectorapplications_client.go | 36 +- ...nnectorapplications_client_example_test.go | 41 - .../connectorgovernancerule_client.go | 125 -- ...ectorgovernancerule_client_example_test.go | 41 - .../connectorgovernancerules_client.go | 233 -- ...ctorgovernancerules_client_example_test.go | 102 - ...ctorgovernancerulesexecutestatus_client.go | 129 -- ...erulesexecutestatus_client_example_test.go | 40 - .../security/armsecurity/connectors_client.go | 115 +- .../connectors_client_example_test.go | 176 -- .../security/armsecurity/constants.go | 113 +- .../security/armsecurity/contacts_client.go | 59 +- .../contacts_client_example_test.go | 111 - .../customassessmentautomations_client.go | 84 +- ...sessmentautomations_client_example_test.go | 130 -- .../customentitystoreassignments_client.go | 84 +- ...itystoreassignments_client_example_test.go | 125 -- .../security/armsecurity/date_type.go | 2 +- .../devicesecuritygroups_client.go | 79 +- ...evicesecuritygroups_client_example_test.go | 108 - .../discoveredsecuritysolutions_client.go | 58 +- ...edsecuritysolutions_client_example_test.go | 84 - .../externalsecuritysolutions_client.go | 58 +- ...alsecuritysolutions_client_example_test.go | 84 - .../security/armsecurity/go.mod | 20 +- .../security/armsecurity/go.sum | 37 +- .../governanceassignments_client.go | 117 +- ...vernanceassignments_client_example_test.go | 118 - .../armsecurity/governancerule_client.go | 114 - .../governancerule_client_example_test.go | 41 - .../armsecurity/governancerules_client.go | 396 ++-- .../governancerules_client_example_test.go | 144 -- .../armsecurity/healthreport_client.go | 92 + .../armsecurity/healthreports_client.go | 99 + .../informationprotectionpolicies_client.go | 66 +- ...nprotectionpolicies_client_example_test.go | 147 -- .../armsecurity/ingestionsettings_client.go | 86 +- .../ingestionsettings_client_example_test.go | 134 -- .../armsecurity/iotsecuritysolution_client.go | 97 +- ...iotsecuritysolution_client_example_test.go | 235 -- .../iotsecuritysolutionanalytics_client.go | 49 +- ...tysolutionanalytics_client_example_test.go | 55 - ...olutionsanalyticsaggregatedalert_client.go | 66 +- ...ticsaggregatedalert_client_example_test.go | 77 - ...solutionsanalyticsrecommendation_client.go | 51 +- ...yticsrecommendation_client_example_test.go | 60 - .../jitnetworkaccesspolicies_client.go | 127 +- ...tworkaccesspolicies_client_example_test.go | 242 -- .../security/armsecurity/locations_client.go | 39 +- .../locations_client_example_test.go | 60 - .../armsecurity/mdeonboardings_client.go | 37 +- .../mdeonboardings_client_example_test.go | 55 - .../security/armsecurity/models.go | 804 +++++-- .../security/armsecurity/models_serde.go | 1958 +++++++++++++---- .../security/armsecurity/operations_client.go | 28 +- .../armsecurity/polymorphic_helpers.go | 34 +- .../security/armsecurity/pricings_client.go | 62 +- .../pricings_client_example_test.go | 80 - .../regulatorycomplianceassessments_client.go | 51 +- ...mplianceassessments_client_example_test.go | 60 - .../regulatorycompliancecontrols_client.go | 47 +- ...ycompliancecontrols_client_example_test.go | 60 - .../regulatorycompliancestandards_client.go | 43 +- ...compliancestandards_client_example_test.go | 60 - .../security/armsecurity/response_types.go | 220 +- .../securescorecontroldefinitions_client.go | 41 +- ...econtroldefinitions_client_example_test.go | 65 - .../armsecurity/securescorecontrols_client.go | 43 +- ...securescorecontrols_client_example_test.go | 90 - .../armsecurity/securescores_client.go | 39 +- .../securescores_client_example_test.go | 60 - .../servervulnerabilityassessment_client.go | 96 +- ...erabilityassessment_client_example_test.go | 93 - .../security/armsecurity/settings_client.go | 50 +- .../settings_client_example_test.go | 85 - .../armsecurity/softwareinventories_client.go | 66 +- ...softwareinventories_client_example_test.go | 84 - .../security/armsecurity/solutions_client.go | 43 +- .../solutions_client_example_test.go | 60 - .../solutionsreferencedata_client.go | 43 +- ...utionsreferencedata_client_example_test.go | 55 - ...erabilityassessmentbaselinerules_client.go | 112 +- ...ssmentbaselinerules_client_example_test.go | 184 -- ...lnerabilityassessmentscanresults_client.go | 61 +- ...sessmentscanresults_client_example_test.go | 93 - .../sqlvulnerabilityassessmentscans_client.go | 57 +- ...lityassessmentscans_client_example_test.go | 74 - .../armsecurity/subassessments_client.go | 61 +- .../subassessments_client_example_test.go | 84 - ...tiongovernancerulesexecutestatus_client.go | 119 - ...erulesexecutestatus_client_example_test.go | 40 - .../security/armsecurity/tasks_client.go | 113 +- .../armsecurity/tasks_client_example_test.go | 161 -- .../security/armsecurity/time_rfc3339.go | 2 +- .../security/armsecurity/topology_client.go | 54 +- .../topology_client_example_test.go | 84 - .../armsecurity/workspacesettings_client.go | 77 +- .../workspacesettings_client_example_test.go | 131 -- 136 files changed, 5387 insertions(+), 9890 deletions(-) delete mode 100644 sdk/resourcemanager/security/armsecurity/accountconnectors_client_example_test.go delete mode 100644 sdk/resourcemanager/security/armsecurity/adaptiveapplicationcontrols_client_example_test.go delete mode 100644 sdk/resourcemanager/security/armsecurity/adaptivenetworkhardenings_client_example_test.go delete mode 100644 sdk/resourcemanager/security/armsecurity/advancedthreatprotection_client_example_test.go delete mode 100644 sdk/resourcemanager/security/armsecurity/alerts_client_example_test.go delete mode 100644 sdk/resourcemanager/security/armsecurity/alertssuppressionrules_client_example_test.go delete mode 100644 sdk/resourcemanager/security/armsecurity/allowedconnections_client_example_test.go create mode 100644 sdk/resourcemanager/security/armsecurity/apicollection_client.go create mode 100644 sdk/resourcemanager/security/armsecurity/apicollectionoffboarding_client.go create mode 100644 sdk/resourcemanager/security/armsecurity/apicollectiononboarding_client.go delete mode 100644 sdk/resourcemanager/security/armsecurity/application_client_example_test.go delete mode 100644 sdk/resourcemanager/security/armsecurity/applications_client_example_test.go delete mode 100644 sdk/resourcemanager/security/armsecurity/assessments_client_example_test.go delete mode 100644 sdk/resourcemanager/security/armsecurity/assessmentsmetadata_client_example_test.go delete mode 100644 sdk/resourcemanager/security/armsecurity/automations_client_example_test.go delete mode 100644 sdk/resourcemanager/security/armsecurity/autoprovisioningsettings_client_example_test.go create mode 100644 sdk/resourcemanager/security/armsecurity/client_factory.go delete mode 100644 sdk/resourcemanager/security/armsecurity/complianceresults_client_example_test.go delete mode 100644 sdk/resourcemanager/security/armsecurity/compliances_client_example_test.go delete mode 100644 sdk/resourcemanager/security/armsecurity/connectorapplication_client_example_test.go delete mode 100644 sdk/resourcemanager/security/armsecurity/connectorapplications_client_example_test.go delete mode 100644 sdk/resourcemanager/security/armsecurity/connectorgovernancerule_client.go delete mode 100644 sdk/resourcemanager/security/armsecurity/connectorgovernancerule_client_example_test.go delete mode 100644 sdk/resourcemanager/security/armsecurity/connectorgovernancerules_client.go delete mode 100644 sdk/resourcemanager/security/armsecurity/connectorgovernancerules_client_example_test.go delete mode 100644 sdk/resourcemanager/security/armsecurity/connectorgovernancerulesexecutestatus_client.go delete mode 100644 sdk/resourcemanager/security/armsecurity/connectorgovernancerulesexecutestatus_client_example_test.go delete mode 100644 sdk/resourcemanager/security/armsecurity/connectors_client_example_test.go delete mode 100644 sdk/resourcemanager/security/armsecurity/contacts_client_example_test.go delete mode 100644 sdk/resourcemanager/security/armsecurity/customassessmentautomations_client_example_test.go delete mode 100644 sdk/resourcemanager/security/armsecurity/customentitystoreassignments_client_example_test.go delete mode 100644 sdk/resourcemanager/security/armsecurity/devicesecuritygroups_client_example_test.go delete mode 100644 sdk/resourcemanager/security/armsecurity/discoveredsecuritysolutions_client_example_test.go delete mode 100644 sdk/resourcemanager/security/armsecurity/externalsecuritysolutions_client_example_test.go delete mode 100644 sdk/resourcemanager/security/armsecurity/governanceassignments_client_example_test.go delete mode 100644 sdk/resourcemanager/security/armsecurity/governancerule_client.go delete mode 100644 sdk/resourcemanager/security/armsecurity/governancerule_client_example_test.go delete mode 100644 sdk/resourcemanager/security/armsecurity/governancerules_client_example_test.go create mode 100644 sdk/resourcemanager/security/armsecurity/healthreport_client.go create mode 100644 sdk/resourcemanager/security/armsecurity/healthreports_client.go delete mode 100644 sdk/resourcemanager/security/armsecurity/informationprotectionpolicies_client_example_test.go delete mode 100644 sdk/resourcemanager/security/armsecurity/ingestionsettings_client_example_test.go delete mode 100644 sdk/resourcemanager/security/armsecurity/iotsecuritysolution_client_example_test.go delete mode 100644 sdk/resourcemanager/security/armsecurity/iotsecuritysolutionanalytics_client_example_test.go delete mode 100644 sdk/resourcemanager/security/armsecurity/iotsecuritysolutionsanalyticsaggregatedalert_client_example_test.go delete mode 100644 sdk/resourcemanager/security/armsecurity/iotsecuritysolutionsanalyticsrecommendation_client_example_test.go delete mode 100644 sdk/resourcemanager/security/armsecurity/jitnetworkaccesspolicies_client_example_test.go delete mode 100644 sdk/resourcemanager/security/armsecurity/locations_client_example_test.go delete mode 100644 sdk/resourcemanager/security/armsecurity/mdeonboardings_client_example_test.go delete mode 100644 sdk/resourcemanager/security/armsecurity/pricings_client_example_test.go delete mode 100644 sdk/resourcemanager/security/armsecurity/regulatorycomplianceassessments_client_example_test.go delete mode 100644 sdk/resourcemanager/security/armsecurity/regulatorycompliancecontrols_client_example_test.go delete mode 100644 sdk/resourcemanager/security/armsecurity/regulatorycompliancestandards_client_example_test.go delete mode 100644 sdk/resourcemanager/security/armsecurity/securescorecontroldefinitions_client_example_test.go delete mode 100644 sdk/resourcemanager/security/armsecurity/securescorecontrols_client_example_test.go delete mode 100644 sdk/resourcemanager/security/armsecurity/securescores_client_example_test.go delete mode 100644 sdk/resourcemanager/security/armsecurity/servervulnerabilityassessment_client_example_test.go delete mode 100644 sdk/resourcemanager/security/armsecurity/settings_client_example_test.go delete mode 100644 sdk/resourcemanager/security/armsecurity/softwareinventories_client_example_test.go delete mode 100644 sdk/resourcemanager/security/armsecurity/solutions_client_example_test.go delete mode 100644 sdk/resourcemanager/security/armsecurity/solutionsreferencedata_client_example_test.go delete mode 100644 sdk/resourcemanager/security/armsecurity/sqlvulnerabilityassessmentbaselinerules_client_example_test.go delete mode 100644 sdk/resourcemanager/security/armsecurity/sqlvulnerabilityassessmentscanresults_client_example_test.go delete mode 100644 sdk/resourcemanager/security/armsecurity/sqlvulnerabilityassessmentscans_client_example_test.go delete mode 100644 sdk/resourcemanager/security/armsecurity/subassessments_client_example_test.go delete mode 100644 sdk/resourcemanager/security/armsecurity/subscriptiongovernancerulesexecutestatus_client.go delete mode 100644 sdk/resourcemanager/security/armsecurity/subscriptiongovernancerulesexecutestatus_client_example_test.go delete mode 100644 sdk/resourcemanager/security/armsecurity/tasks_client_example_test.go delete mode 100644 sdk/resourcemanager/security/armsecurity/topology_client_example_test.go delete mode 100644 sdk/resourcemanager/security/armsecurity/workspacesettings_client_example_test.go diff --git a/sdk/resourcemanager/security/armsecurity/CHANGELOG.md b/sdk/resourcemanager/security/armsecurity/CHANGELOG.md index 16e282a184cd..498f0dca3c3c 100644 --- a/sdk/resourcemanager/security/armsecurity/CHANGELOG.md +++ b/sdk/resourcemanager/security/armsecurity/CHANGELOG.md @@ -1,5 +1,174 @@ # Release History +## 0.10.0 (2023-03-27) +### Breaking Changes + +- Function `NewGovernanceRulesClient` parameter(s) have been changed from `(string, azcore.TokenCredential, *arm.ClientOptions)` to `(azcore.TokenCredential, *arm.ClientOptions)` +- Function `*GovernanceRulesClient.CreateOrUpdate` parameter(s) have been changed from `(context.Context, string, GovernanceRule, *GovernanceRulesClientCreateOrUpdateOptions)` to `(context.Context, string, string, GovernanceRule, *GovernanceRulesClientCreateOrUpdateOptions)` +- Function `*GovernanceRulesClient.Get` parameter(s) have been changed from `(context.Context, string, *GovernanceRulesClientGetOptions)` to `(context.Context, string, string, *GovernanceRulesClientGetOptions)` +- Function `NewConnectorGovernanceRuleClient` has been removed +- Function `*ConnectorGovernanceRuleClient.NewListPager` has been removed +- Function `NewConnectorGovernanceRulesClient` has been removed +- Function `*ConnectorGovernanceRulesClient.CreateOrUpdate` has been removed +- Function `*ConnectorGovernanceRulesClient.Delete` has been removed +- Function `*ConnectorGovernanceRulesClient.Get` has been removed +- Function `NewConnectorGovernanceRulesExecuteStatusClient` has been removed +- Function `*ConnectorGovernanceRulesExecuteStatusClient.BeginGet` has been removed +- Function `NewGovernanceRuleClient` has been removed +- Function `*GovernanceRuleClient.NewListPager` has been removed +- Function `*GovernanceRulesClient.BeginRuleIDExecuteSingleSecurityConnector` has been removed +- Function `*GovernanceRulesClient.BeginRuleIDExecuteSingleSubscription` has been removed +- Function `NewSubscriptionGovernanceRulesExecuteStatusClient` has been removed +- Function `*SubscriptionGovernanceRulesExecuteStatusClient.BeginGet` has been removed +- Operation `*GovernanceRulesClient.Delete` has been changed to LRO, use `*GovernanceRulesClient.BeginDelete` instead. +- Struct `ConnectorGovernanceRuleClient` has been removed +- Struct `ConnectorGovernanceRulesClient` has been removed +- Struct `ConnectorGovernanceRulesExecuteStatusClient` has been removed +- Struct `ExecuteRuleStatus` has been removed +- Struct `GovernanceRuleClient` has been removed +- Struct `SubscriptionGovernanceRulesExecuteStatusClient` has been removed + +### Features Added + +- New value `CloudNameGitLab` added to enum type `CloudName` +- New value `EnvironmentTypeGitlabScope` added to enum type `EnvironmentType` +- New value `OfferingTypeCspmMonitorGitLab`, `OfferingTypeDefenderForDevOpsGitLab` added to enum type `OfferingType` +- New enum type `Code` with values `CodeFailed`, `CodeSucceeded` +- New enum type `IsEnabled` with values `IsEnabledFalse`, `IsEnabledTrue` +- New enum type `OperationResult` with values `OperationResultCanceled`, `OperationResultFailed`, `OperationResultSucceeded` +- New enum type `ScopeName` with values `ScopeNameClusters`, `ScopeNameConnectors`, `ScopeNameUnknown`, `ScopeNameVirtualMachines` +- New enum type `StatusName` with values `StatusNameHealthy`, `StatusNameNotApplicable`, `StatusNameNotHealthy` +- New function `NewAPICollectionClient(string, azcore.TokenCredential, *arm.ClientOptions) (*APICollectionClient, error)` +- New function `*APICollectionClient.Get(context.Context, string, string, string, *APICollectionClientGetOptions) (APICollectionClientGetResponse, error)` +- New function `*APICollectionClient.NewListPager(string, string, *APICollectionClientListOptions) *runtime.Pager[APICollectionClientListResponse]` +- New function `NewAPICollectionOffboardingClient(string, azcore.TokenCredential, *arm.ClientOptions) (*APICollectionOffboardingClient, error)` +- New function `*APICollectionOffboardingClient.Delete(context.Context, string, string, string, *APICollectionOffboardingClientDeleteOptions) (APICollectionOffboardingClientDeleteResponse, error)` +- New function `NewAPICollectionOnboardingClient(string, azcore.TokenCredential, *arm.ClientOptions) (*APICollectionOnboardingClient, error)` +- New function `*APICollectionOnboardingClient.Create(context.Context, string, string, string, *APICollectionOnboardingClientCreateOptions) (APICollectionOnboardingClientCreateResponse, error)` +- New function `NewClientFactory(string, azcore.TokenCredential, *arm.ClientOptions) (*ClientFactory, error)` +- New function `*ClientFactory.NewAPICollectionClient() *APICollectionClient` +- New function `*ClientFactory.NewAPICollectionOffboardingClient() *APICollectionOffboardingClient` +- New function `*ClientFactory.NewAPICollectionOnboardingClient() *APICollectionOnboardingClient` +- New function `*ClientFactory.NewAccountConnectorsClient() *AccountConnectorsClient` +- New function `*ClientFactory.NewAdaptiveApplicationControlsClient() *AdaptiveApplicationControlsClient` +- New function `*ClientFactory.NewAdaptiveNetworkHardeningsClient() *AdaptiveNetworkHardeningsClient` +- New function `*ClientFactory.NewAdvancedThreatProtectionClient() *AdvancedThreatProtectionClient` +- New function `*ClientFactory.NewAlertsClient() *AlertsClient` +- New function `*ClientFactory.NewAlertsSuppressionRulesClient() *AlertsSuppressionRulesClient` +- New function `*ClientFactory.NewAllowedConnectionsClient() *AllowedConnectionsClient` +- New function `*ClientFactory.NewApplicationClient() *ApplicationClient` +- New function `*ClientFactory.NewApplicationsClient() *ApplicationsClient` +- New function `*ClientFactory.NewAssessmentsClient() *AssessmentsClient` +- New function `*ClientFactory.NewAssessmentsMetadataClient() *AssessmentsMetadataClient` +- New function `*ClientFactory.NewAutoProvisioningSettingsClient() *AutoProvisioningSettingsClient` +- New function `*ClientFactory.NewAutomationsClient() *AutomationsClient` +- New function `*ClientFactory.NewComplianceResultsClient() *ComplianceResultsClient` +- New function `*ClientFactory.NewCompliancesClient() *CompliancesClient` +- New function `*ClientFactory.NewConnectorApplicationClient() *ConnectorApplicationClient` +- New function `*ClientFactory.NewConnectorApplicationsClient() *ConnectorApplicationsClient` +- New function `*ClientFactory.NewConnectorsClient() *ConnectorsClient` +- New function `*ClientFactory.NewContactsClient() *ContactsClient` +- New function `*ClientFactory.NewCustomAssessmentAutomationsClient() *CustomAssessmentAutomationsClient` +- New function `*ClientFactory.NewCustomEntityStoreAssignmentsClient() *CustomEntityStoreAssignmentsClient` +- New function `*ClientFactory.NewDeviceSecurityGroupsClient() *DeviceSecurityGroupsClient` +- New function `*ClientFactory.NewDiscoveredSecuritySolutionsClient() *DiscoveredSecuritySolutionsClient` +- New function `*ClientFactory.NewExternalSecuritySolutionsClient() *ExternalSecuritySolutionsClient` +- New function `*ClientFactory.NewGovernanceAssignmentsClient() *GovernanceAssignmentsClient` +- New function `*ClientFactory.NewGovernanceRulesClient() *GovernanceRulesClient` +- New function `*ClientFactory.NewHealthReportClient() *HealthReportClient` +- New function `*ClientFactory.NewHealthReportsClient() *HealthReportsClient` +- New function `*ClientFactory.NewInformationProtectionPoliciesClient() *InformationProtectionPoliciesClient` +- New function `*ClientFactory.NewIngestionSettingsClient() *IngestionSettingsClient` +- New function `*ClientFactory.NewIotSecuritySolutionAnalyticsClient() *IotSecuritySolutionAnalyticsClient` +- New function `*ClientFactory.NewIotSecuritySolutionClient() *IotSecuritySolutionClient` +- New function `*ClientFactory.NewIotSecuritySolutionsAnalyticsAggregatedAlertClient() *IotSecuritySolutionsAnalyticsAggregatedAlertClient` +- New function `*ClientFactory.NewIotSecuritySolutionsAnalyticsRecommendationClient() *IotSecuritySolutionsAnalyticsRecommendationClient` +- New function `*ClientFactory.NewJitNetworkAccessPoliciesClient() *JitNetworkAccessPoliciesClient` +- New function `*ClientFactory.NewLocationsClient() *LocationsClient` +- New function `*ClientFactory.NewMdeOnboardingsClient() *MdeOnboardingsClient` +- New function `*ClientFactory.NewOperationsClient() *OperationsClient` +- New function `*ClientFactory.NewPricingsClient() *PricingsClient` +- New function `*ClientFactory.NewRegulatoryComplianceAssessmentsClient() *RegulatoryComplianceAssessmentsClient` +- New function `*ClientFactory.NewRegulatoryComplianceControlsClient() *RegulatoryComplianceControlsClient` +- New function `*ClientFactory.NewRegulatoryComplianceStandardsClient() *RegulatoryComplianceStandardsClient` +- New function `*ClientFactory.NewSQLVulnerabilityAssessmentBaselineRulesClient() *SQLVulnerabilityAssessmentBaselineRulesClient` +- New function `*ClientFactory.NewSQLVulnerabilityAssessmentScanResultsClient() *SQLVulnerabilityAssessmentScanResultsClient` +- New function `*ClientFactory.NewSQLVulnerabilityAssessmentScansClient() *SQLVulnerabilityAssessmentScansClient` +- New function `*ClientFactory.NewSecureScoreControlDefinitionsClient() *SecureScoreControlDefinitionsClient` +- New function `*ClientFactory.NewSecureScoreControlsClient() *SecureScoreControlsClient` +- New function `*ClientFactory.NewSecureScoresClient() *SecureScoresClient` +- New function `*ClientFactory.NewServerVulnerabilityAssessmentClient() *ServerVulnerabilityAssessmentClient` +- New function `*ClientFactory.NewSettingsClient() *SettingsClient` +- New function `*ClientFactory.NewSoftwareInventoriesClient() *SoftwareInventoriesClient` +- New function `*ClientFactory.NewSolutionsClient() *SolutionsClient` +- New function `*ClientFactory.NewSolutionsReferenceDataClient() *SolutionsReferenceDataClient` +- New function `*ClientFactory.NewSubAssessmentsClient() *SubAssessmentsClient` +- New function `*ClientFactory.NewTasksClient() *TasksClient` +- New function `*ClientFactory.NewTopologyClient() *TopologyClient` +- New function `*ClientFactory.NewWorkspaceSettingsClient() *WorkspaceSettingsClient` +- New function `*CspmMonitorGitLabOffering.GetCloudOffering() *CloudOffering` +- New function `*DefenderForDevOpsGitLabOffering.GetCloudOffering() *CloudOffering` +- New function `*GitlabScopeEnvironmentData.GetEnvironmentData() *EnvironmentData` +- New function `*GovernanceRulesClient.BeginExecute(context.Context, string, string, *GovernanceRulesClientBeginExecuteOptions) (*runtime.Poller[GovernanceRulesClientExecuteResponse], error)` +- New function `*GovernanceRulesClient.NewListPager(string, *GovernanceRulesClientListOptions) *runtime.Pager[GovernanceRulesClientListResponse]` +- New function `*GovernanceRulesClient.OperationResults(context.Context, string, string, string, *GovernanceRulesClientOperationResultsOptions) (GovernanceRulesClientOperationResultsResponse, error)` +- New function `NewHealthReportClient(azcore.TokenCredential, *arm.ClientOptions) (*HealthReportClient, error)` +- New function `*HealthReportClient.Get(context.Context, string, string, *HealthReportClientGetOptions) (HealthReportClientGetResponse, error)` +- New function `NewHealthReportsClient(azcore.TokenCredential, *arm.ClientOptions) (*HealthReportsClient, error)` +- New function `*HealthReportsClient.NewListPager(string, *HealthReportsClientListOptions) *runtime.Pager[HealthReportsClientListResponse]` +- New struct `APICollectionProperties` +- New struct `APICollectionResponse` +- New struct `APICollectionResponseList` +- New struct `ClientFactory` +- New struct `CspmMonitorGitLabOffering` +- New struct `DefenderCspmAwsOfferingDataSensitivityDiscovery` +- New struct `DefenderCspmAwsOfferingDatabasesDspm` +- New struct `DefenderFoDatabasesAwsOfferingArcAutoProvisioningConfiguration` +- New struct `DefenderFoDatabasesAwsOfferingDatabasesDspm` +- New struct `DefenderForDatabasesGcpOfferingArcAutoProvisioningConfiguration` +- New struct `DefenderForDevOpsGitLabOffering` +- New struct `DefenderForServersAwsOfferingArcAutoProvisioningConfiguration` +- New struct `DefenderForServersGcpOfferingArcAutoProvisioningConfiguration` +- New struct `DefenderForServersGcpOfferingVMScanners` +- New struct `DefenderForServersGcpOfferingVMScannersConfiguration` +- New struct `EnvironmentDetails` +- New struct `ErrorDetail` +- New struct `ErrorDetailAutoGenerated` +- New struct `ErrorResponse` +- New struct `ErrorResponseAutoGenerated` +- New struct `Extension` +- New struct `GitlabScopeEnvironmentData` +- New struct `GovernanceRuleMetadata` +- New struct `HealthDataClassification` +- New struct `HealthReport` +- New struct `HealthReportProperties` +- New struct `HealthReportsList` +- New struct `Issue` +- New struct `OperationResultAutoGenerated` +- New struct `OperationStatus` +- New struct `ResourceDetailsAutoGenerated` +- New struct `StatusAutoGenerated` +- New field `AccountName` in struct `AwsEnvironmentData` +- New field `Regions` in struct `AwsEnvironmentData` +- New field `DataSensitivityDiscovery` in struct `DefenderCspmAwsOffering` +- New field `DatabasesDspm` in struct `DefenderCspmAwsOffering` +- New field `DatabasesDspm` in struct `DefenderFoDatabasesAwsOffering` +- New field `Configuration` in struct `DefenderFoDatabasesAwsOfferingArcAutoProvisioning` +- New field `Configuration` in struct `DefenderForDatabasesGcpOfferingArcAutoProvisioning` +- New field `Configuration` in struct `DefenderForServersAwsOfferingArcAutoProvisioning` +- New field `VMScanners` in struct `DefenderForServersGcpOffering` +- New field `Configuration` in struct `DefenderForServersGcpOfferingArcAutoProvisioning` +- New field `OrganizationName` in struct `GcpOrganizationalDataOrganization` +- New field `ProjectName` in struct `GcpProjectDetails` +- New field `ExcludedScopes` in struct `GovernanceRuleProperties` +- New field `IncludeMemberScopes` in struct `GovernanceRuleProperties` +- New field `Metadata` in struct `GovernanceRuleProperties` +- New field `TenantID` in struct `GovernanceRuleProperties` +- New field `EnablementTime` in struct `PricingProperties` +- New field `Extensions` in struct `PricingProperties` +- New field `LastScanTime` in struct `ScanProperties` + + ## 0.9.0 (2022-11-15) ### Breaking Changes diff --git a/sdk/resourcemanager/security/armsecurity/accountconnectors_client.go b/sdk/resourcemanager/security/armsecurity/accountconnectors_client.go index 81cab85c1e61..0fb13535b1b4 100644 --- a/sdk/resourcemanager/security/armsecurity/accountconnectors_client.go +++ b/sdk/resourcemanager/security/armsecurity/accountconnectors_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,31 +24,22 @@ import ( // AccountConnectorsClient contains the methods for the AccountConnectors group. // Don't use this type directly, use NewAccountConnectorsClient() instead. type AccountConnectorsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewAccountConnectorsClient creates a new instance of AccountConnectorsClient with the specified values. -// subscriptionID - Azure subscription ID -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure subscription ID +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewAccountConnectorsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AccountConnectorsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".AccountConnectorsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &AccountConnectorsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -59,17 +48,18 @@ func NewAccountConnectorsClient(subscriptionID string, credential azcore.TokenCr // either account credentials or role-based authentication. For GCP, use account organization // credentials. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-01-01-preview -// connectorName - Name of the cloud account connector -// connectorSetting - Settings for the cloud account connector -// options - AccountConnectorsClientCreateOrUpdateOptions contains the optional parameters for the AccountConnectorsClient.CreateOrUpdate -// method. +// - connectorName - Name of the cloud account connector +// - connectorSetting - Settings for the cloud account connector +// - options - AccountConnectorsClientCreateOrUpdateOptions contains the optional parameters for the AccountConnectorsClient.CreateOrUpdate +// method. func (client *AccountConnectorsClient) CreateOrUpdate(ctx context.Context, connectorName string, connectorSetting ConnectorSetting, options *AccountConnectorsClientCreateOrUpdateOptions) (AccountConnectorsClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, connectorName, connectorSetting, options) if err != nil { return AccountConnectorsClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AccountConnectorsClientCreateOrUpdateResponse{}, err } @@ -90,7 +80,7 @@ func (client *AccountConnectorsClient) createOrUpdateCreateRequest(ctx context.C return nil, errors.New("parameter connectorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{connectorName}", url.PathEscape(connectorName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -112,16 +102,17 @@ func (client *AccountConnectorsClient) createOrUpdateHandleResponse(resp *http.R // Delete - Delete a cloud account connector from a subscription // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-01-01-preview -// connectorName - Name of the cloud account connector -// options - AccountConnectorsClientDeleteOptions contains the optional parameters for the AccountConnectorsClient.Delete -// method. +// - connectorName - Name of the cloud account connector +// - options - AccountConnectorsClientDeleteOptions contains the optional parameters for the AccountConnectorsClient.Delete +// method. func (client *AccountConnectorsClient) Delete(ctx context.Context, connectorName string, options *AccountConnectorsClientDeleteOptions) (AccountConnectorsClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, connectorName, options) if err != nil { return AccountConnectorsClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AccountConnectorsClientDeleteResponse{}, err } @@ -142,7 +133,7 @@ func (client *AccountConnectorsClient) deleteCreateRequest(ctx context.Context, return nil, errors.New("parameter connectorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{connectorName}", url.PathEscape(connectorName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -155,15 +146,16 @@ func (client *AccountConnectorsClient) deleteCreateRequest(ctx context.Context, // Get - Details of a specific cloud account connector // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-01-01-preview -// connectorName - Name of the cloud account connector -// options - AccountConnectorsClientGetOptions contains the optional parameters for the AccountConnectorsClient.Get method. +// - connectorName - Name of the cloud account connector +// - options - AccountConnectorsClientGetOptions contains the optional parameters for the AccountConnectorsClient.Get method. func (client *AccountConnectorsClient) Get(ctx context.Context, connectorName string, options *AccountConnectorsClientGetOptions) (AccountConnectorsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, connectorName, options) if err != nil { return AccountConnectorsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AccountConnectorsClientGetResponse{}, err } @@ -184,7 +176,7 @@ func (client *AccountConnectorsClient) getCreateRequest(ctx context.Context, con return nil, errors.New("parameter connectorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{connectorName}", url.PathEscape(connectorName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -205,8 +197,10 @@ func (client *AccountConnectorsClient) getHandleResponse(resp *http.Response) (A } // NewListPager - Cloud accounts connectors of a subscription +// // Generated from API version 2020-01-01-preview -// options - AccountConnectorsClientListOptions contains the optional parameters for the AccountConnectorsClient.List method. +// - options - AccountConnectorsClientListOptions contains the optional parameters for the AccountConnectorsClient.NewListPager +// method. func (client *AccountConnectorsClient) NewListPager(options *AccountConnectorsClientListOptions) *runtime.Pager[AccountConnectorsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[AccountConnectorsClientListResponse]{ More: func(page AccountConnectorsClientListResponse) bool { @@ -223,7 +217,7 @@ func (client *AccountConnectorsClient) NewListPager(options *AccountConnectorsCl if err != nil { return AccountConnectorsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AccountConnectorsClientListResponse{}, err } @@ -242,7 +236,7 @@ func (client *AccountConnectorsClient) listCreateRequest(ctx context.Context, op return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/security/armsecurity/accountconnectors_client_example_test.go b/sdk/resourcemanager/security/armsecurity/accountconnectors_client_example_test.go deleted file mode 100644 index 472e11b3c208..000000000000 --- a/sdk/resourcemanager/security/armsecurity/accountconnectors_client_example_test.go +++ /dev/null @@ -1,197 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. - -package armsecurity_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2020-01-01-preview/examples/Connectors/GetListConnectorSubscription_example.json -func ExampleAccountConnectorsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAccountConnectorsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2020-01-01-preview/examples/Connectors/GetConnectorSubscription_example.json -func ExampleAccountConnectorsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAccountConnectorsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "aws_dev1", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2020-01-01-preview/examples/Connectors/CreateUpdateAwsAssumeRoleConnectorSubscription_example.json -func ExampleAccountConnectorsClient_CreateOrUpdate_awsAssumeRoleCreateACloudAccountConnectorForASubscription() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAccountConnectorsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdate(ctx, "aws_dev2", armsecurity.ConnectorSetting{ - Properties: &armsecurity.ConnectorSettingProperties{ - AuthenticationDetails: &armsecurity.AwAssumeRoleAuthenticationDetailsProperties{ - AuthenticationType: to.Ptr(armsecurity.AuthenticationTypeAwsAssumeRole), - AwsAssumeRoleArn: to.Ptr("arn:aws:iam::81231569658:role/AscConnector"), - AwsExternalID: to.Ptr("20ff7fc3-e762-44dd-bd96-b71116dcdc23"), - }, - HybridComputeSettings: &armsecurity.HybridComputeSettingsProperties{ - AutoProvision: to.Ptr(armsecurity.AutoProvisionOn), - ProxyServer: &armsecurity.ProxyServerProperties{ - IP: to.Ptr("167.220.197.140"), - Port: to.Ptr("34"), - }, - Region: to.Ptr("West US 2"), - ResourceGroupName: to.Ptr("AwsConnectorRG"), - ServicePrincipal: &armsecurity.ServicePrincipalProperties{ - ApplicationID: to.Ptr("ad9bcd79-be9c-45ab-abd8-80ca1654a7d1"), - Secret: to.Ptr(""), - }, - }, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2020-01-01-preview/examples/Connectors/CreateUpdateAwsCredConnectorSubscription_example.json -func ExampleAccountConnectorsClient_CreateOrUpdate_awsCredCreateACloudAccountConnectorForASubscription() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAccountConnectorsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdate(ctx, "aws_dev1", armsecurity.ConnectorSetting{ - Properties: &armsecurity.ConnectorSettingProperties{ - AuthenticationDetails: &armsecurity.AwsCredsAuthenticationDetailsProperties{ - AuthenticationType: to.Ptr(armsecurity.AuthenticationTypeAwsCreds), - AwsAccessKeyID: to.Ptr("AKIARPZCNODDNAEQFSOE"), - AwsSecretAccessKey: to.Ptr(""), - }, - HybridComputeSettings: &armsecurity.HybridComputeSettingsProperties{ - AutoProvision: to.Ptr(armsecurity.AutoProvisionOn), - ProxyServer: &armsecurity.ProxyServerProperties{ - IP: to.Ptr("167.220.197.140"), - Port: to.Ptr("34"), - }, - Region: to.Ptr("West US 2"), - ResourceGroupName: to.Ptr("AwsConnectorRG"), - ServicePrincipal: &armsecurity.ServicePrincipalProperties{ - ApplicationID: to.Ptr("ad9bcd79-be9c-45ab-abd8-80ca1654a7d1"), - Secret: to.Ptr(""), - }, - }, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2020-01-01-preview/examples/Connectors/CreateUpdateGcpCredentialsConnectorSubscription_example.json -func ExampleAccountConnectorsClient_CreateOrUpdate_gcpCredentialsCreateACloudAccountConnectorForASubscription() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAccountConnectorsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdate(ctx, "gcp_dev", armsecurity.ConnectorSetting{ - Properties: &armsecurity.ConnectorSettingProperties{ - AuthenticationDetails: &armsecurity.GcpCredentialsDetailsProperties{ - AuthenticationType: to.Ptr(armsecurity.AuthenticationTypeGcpCredentials), - Type: to.Ptr("service_account"), - AuthProviderX509CertURL: to.Ptr("https://www.googleapis.com/oauth2/v1/certs"), - AuthURI: to.Ptr("https://accounts.google.com/o/oauth2/auth"), - ClientEmail: to.Ptr("asc-135@asc-project-1234.iam.gserviceaccount.com"), - ClientID: to.Ptr("105889053725632919854"), - ClientX509CertURL: to.Ptr("https://www.googleapis.com/robot/v1/metadata/x509/asc-135%40asc-project-1234.iam.gserviceaccount.com"), - OrganizationID: to.Ptr("AscDemoOrg"), - PrivateKey: to.Ptr("-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCpxYHcLzcDZ6/Q\nAeQZnQXM5GTb3p09Xsbjo2T2F61b6I7FZiQXBrbw3Zf0CUCkkqTTpD5xifl82yQ6\n89V7SAe8hxI7esAcVDhm/aJMqzVjHLISAU2L3li1sn0jjY2oYtndwN6bRivP8O6t\n9F+W6E0zMlbCxtpZEHLbb6WxlJJrwEQ0MPH2yOCwZUQi6NHksAtEzX2nNKJNyUC7\nQyBVHHMm34H2bmZwsuQp3y2otpcJ9tJnVmYfC3k/w4x2L+DIK7JnQP/C1wQqu2du\nc0w6sydF6RhLoHButrVdYRJTdfK4k03SsSTyMqZ+f7LNnKw3xenzw1VmEpk8mvoQ\nt08tCBOrAgMBAAECggEAByzz6iyMtLYjNjV+QJ7kad6VbL2iA8AHxANZ9xTVHPdd\nYXaJu/dqsA+NpqDlfI8+LDva782XH/HbPCqmMUnAGfXTjXQIvqnIoIHD5F2wKfpC\nhIRNlMXXFgbvRxtqi11yO+80+XcjzuwuCmgzyhsTeEB+bkkdXXpWgHPdmv3emnM6\nMQM9Zgrug0UndPmiUwKOcJSU4PlmlTpHEV4vA6JfA4bvphy9m1jxO5qWeah5yym2\n6FP5BRIDF98kFrDnSXJjajwgLCQ+MypFQXyax6XkxDxuKXbng1bv7eZDjqazIChk\nm0y14X0s0jnWc+AX8vfeSf7d+EsGdVinEwR1aAawEQKBgQDqDB0qxcIQ1oI1Kww8\n9vXefTiuWsf47F+fJ/DIOEbiRfE8IdCgmOABvcqJIoxW/DFMBEdLCcx73Km7pOmd\nKg1ddScnaO8cOj2v/Ub+fAqVrA4ki4ViYP0A7/Nogga3Jr/x3ey5bitrIfFImteS\nCgBHBzZvoQpvO4lB2tKVgo2P9wKBgQC5sgTEq4sasRGSAY6lIoJno0I8w28a/16D\nes60XQeY1ger8uTGwlT02v/u/arDUmRLPClpujXq6gK29KvtRCHy7JkpGbqW2bZs\nPFKKWR7Tk3XPKYyjv94AIi5/xoFeDhS4lpAvy3Z5tQhYS6wqWKvT6yZQ3kM+Hfxs\npHgvu3mU7QKBgQC9/E1k3hj1cBtMK4CIsHPPQljTd4+iacYJPPPAo6YuoVX8WPqw\nksgrwbN59Fh1d8xQh5yTtgWOegYx8uFMGcm1lpbM7+pBQKm4hWGuzGQPMRZd5f/F\nZzOZIi61I+9tlv/yxxIVR+/ozCm/pSneO04UWi9/F/uPZYW6tnWAtfRR6wKBgGsZ\n8MQaCK4JaI/klAhMghgSQnbXZXKVzUZaA3Rln6cX8u7KtgapOOTMlwaZie8Dy1LV\nTTFstAJcm9o3/h1nyYjZy3C4JTUyNpPwqs6enjf7edxVI4eidwFutZD+xcigqHTa\naikW2atSrZB3fMIjyF7+5meH+hKOqvNiXOty3qn1AoGAZuVxYQy5FVq3YZxzr3Aa\nAm0ShoXTF6QYIbsaUiUGoa/NlHcw9V/lj4AqBRbxbaYMD+hz2J/od9cb268eJKY8\n3b6MvaUqdNhNnWodJXLhgtmGEHDKmTppz2JSTx/tVzCfhFdcOC79StZvcKLhtoFQ\n+/3lEw6NCIXzm5E4+dtJG4k=\n-----END PRIVATE KEY-----\n"), - PrivateKeyID: to.Ptr("6efg587hra2568as34d22326b044cc20dc2af"), - ProjectID: to.Ptr("asc-project-1234"), - TokenURI: to.Ptr("https://oauth2.googleapis.com/token"), - }, - HybridComputeSettings: &armsecurity.HybridComputeSettingsProperties{ - AutoProvision: to.Ptr(armsecurity.AutoProvisionOff), - }, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2020-01-01-preview/examples/Connectors/DeleteConnectorSubscription_example.json -func ExampleAccountConnectorsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAccountConnectorsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, "aws_dev1", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/security/armsecurity/adaptiveapplicationcontrols_client.go b/sdk/resourcemanager/security/armsecurity/adaptiveapplicationcontrols_client.go index e52701429fd3..38a9f78ce371 100644 --- a/sdk/resourcemanager/security/armsecurity/adaptiveapplicationcontrols_client.go +++ b/sdk/resourcemanager/security/armsecurity/adaptiveapplicationcontrols_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -27,48 +25,40 @@ import ( // AdaptiveApplicationControlsClient contains the methods for the AdaptiveApplicationControls group. // Don't use this type directly, use NewAdaptiveApplicationControlsClient() instead. type AdaptiveApplicationControlsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewAdaptiveApplicationControlsClient creates a new instance of AdaptiveApplicationControlsClient with the specified values. -// subscriptionID - Azure subscription ID -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure subscription ID +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewAdaptiveApplicationControlsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AdaptiveApplicationControlsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".AdaptiveApplicationControlsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &AdaptiveApplicationControlsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Delete - Delete an application control machine group // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-01-01 -// ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations -// groupName - Name of an application control machine group -// options - AdaptiveApplicationControlsClientDeleteOptions contains the optional parameters for the AdaptiveApplicationControlsClient.Delete -// method. +// - ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations +// - groupName - Name of an application control machine group +// - options - AdaptiveApplicationControlsClientDeleteOptions contains the optional parameters for the AdaptiveApplicationControlsClient.Delete +// method. func (client *AdaptiveApplicationControlsClient) Delete(ctx context.Context, ascLocation string, groupName string, options *AdaptiveApplicationControlsClientDeleteOptions) (AdaptiveApplicationControlsClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, ascLocation, groupName, options) if err != nil { return AdaptiveApplicationControlsClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AdaptiveApplicationControlsClientDeleteResponse{}, err } @@ -93,7 +83,7 @@ func (client *AdaptiveApplicationControlsClient) deleteCreateRequest(ctx context return nil, errors.New("parameter groupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{groupName}", url.PathEscape(groupName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -106,17 +96,18 @@ func (client *AdaptiveApplicationControlsClient) deleteCreateRequest(ctx context // Get - Gets an application control VM/server group. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-01-01 -// ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations -// groupName - Name of an application control machine group -// options - AdaptiveApplicationControlsClientGetOptions contains the optional parameters for the AdaptiveApplicationControlsClient.Get -// method. +// - ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations +// - groupName - Name of an application control machine group +// - options - AdaptiveApplicationControlsClientGetOptions contains the optional parameters for the AdaptiveApplicationControlsClient.Get +// method. func (client *AdaptiveApplicationControlsClient) Get(ctx context.Context, ascLocation string, groupName string, options *AdaptiveApplicationControlsClientGetOptions) (AdaptiveApplicationControlsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, ascLocation, groupName, options) if err != nil { return AdaptiveApplicationControlsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AdaptiveApplicationControlsClientGetResponse{}, err } @@ -141,7 +132,7 @@ func (client *AdaptiveApplicationControlsClient) getCreateRequest(ctx context.Co return nil, errors.New("parameter groupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{groupName}", url.PathEscape(groupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -163,15 +154,16 @@ func (client *AdaptiveApplicationControlsClient) getHandleResponse(resp *http.Re // List - Gets a list of application control machine groups for the subscription. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-01-01 -// options - AdaptiveApplicationControlsClientListOptions contains the optional parameters for the AdaptiveApplicationControlsClient.List -// method. +// - options - AdaptiveApplicationControlsClientListOptions contains the optional parameters for the AdaptiveApplicationControlsClient.List +// method. func (client *AdaptiveApplicationControlsClient) List(ctx context.Context, options *AdaptiveApplicationControlsClientListOptions) (AdaptiveApplicationControlsClientListResponse, error) { req, err := client.listCreateRequest(ctx, options) if err != nil { return AdaptiveApplicationControlsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AdaptiveApplicationControlsClientListResponse{}, err } @@ -188,7 +180,7 @@ func (client *AdaptiveApplicationControlsClient) listCreateRequest(ctx context.C return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -216,17 +208,18 @@ func (client *AdaptiveApplicationControlsClient) listHandleResponse(resp *http.R // Put - Update an application control machine group // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-01-01 -// ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations -// groupName - Name of an application control machine group -// options - AdaptiveApplicationControlsClientPutOptions contains the optional parameters for the AdaptiveApplicationControlsClient.Put -// method. +// - ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations +// - groupName - Name of an application control machine group +// - options - AdaptiveApplicationControlsClientPutOptions contains the optional parameters for the AdaptiveApplicationControlsClient.Put +// method. func (client *AdaptiveApplicationControlsClient) Put(ctx context.Context, ascLocation string, groupName string, body AdaptiveApplicationControlGroup, options *AdaptiveApplicationControlsClientPutOptions) (AdaptiveApplicationControlsClientPutResponse, error) { req, err := client.putCreateRequest(ctx, ascLocation, groupName, body, options) if err != nil { return AdaptiveApplicationControlsClientPutResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AdaptiveApplicationControlsClientPutResponse{}, err } @@ -251,7 +244,7 @@ func (client *AdaptiveApplicationControlsClient) putCreateRequest(ctx context.Co return nil, errors.New("parameter groupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{groupName}", url.PathEscape(groupName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/security/armsecurity/adaptiveapplicationcontrols_client_example_test.go b/sdk/resourcemanager/security/armsecurity/adaptiveapplicationcontrols_client_example_test.go deleted file mode 100644 index baec5716dc12..000000000000 --- a/sdk/resourcemanager/security/armsecurity/adaptiveapplicationcontrols_client_example_test.go +++ /dev/null @@ -1,186 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. - -package armsecurity_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/ApplicationWhitelistings/GetAdaptiveApplicationControlsSubscription_example.json -func ExampleAdaptiveApplicationControlsClient_List() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAdaptiveApplicationControlsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.List(ctx, &armsecurity.AdaptiveApplicationControlsClientListOptions{IncludePathRecommendations: to.Ptr(true), - Summary: to.Ptr(false), - }) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/ApplicationWhitelistings/GetAdaptiveApplicationControlsGroup_example.json -func ExampleAdaptiveApplicationControlsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAdaptiveApplicationControlsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "centralus", "ERELGROUP1", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/ApplicationWhitelistings/PutAdaptiveApplicationControls_example.json -func ExampleAdaptiveApplicationControlsClient_Put() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAdaptiveApplicationControlsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Put(ctx, "centralus", "ERELGROUP1", armsecurity.AdaptiveApplicationControlGroup{ - Properties: &armsecurity.AdaptiveApplicationControlGroupData{ - EnforcementMode: to.Ptr(armsecurity.EnforcementModeAudit), - PathRecommendations: []*armsecurity.PathRecommendation{ - { - Type: to.Ptr(armsecurity.RecommendationType("PublisherSignature")), - Path: to.Ptr("[Exe] O=MICROSOFT CORPORATION, L=REDMOND, S=WASHINGTON, C=US\\*\\*\\0.0.0.0"), - Action: to.Ptr(armsecurity.RecommendationActionRecommended), - Common: to.Ptr(true), - ConfigurationStatus: to.Ptr(armsecurity.ConfigurationStatusConfigured), - FileType: to.Ptr(armsecurity.FileTypeExe), - PublisherInfo: &armsecurity.PublisherInfo{ - BinaryName: to.Ptr("*"), - ProductName: to.Ptr("*"), - PublisherName: to.Ptr("O=MICROSOFT CORPORATION, L=REDMOND, S=WASHINGTON, C=US"), - Version: to.Ptr("0.0.0.0"), - }, - UserSids: []*string{ - to.Ptr("S-1-1-0")}, - Usernames: []*armsecurity.UserRecommendation{ - { - RecommendationAction: to.Ptr(armsecurity.RecommendationActionRecommended), - Username: to.Ptr("Everyone"), - }}, - }, - { - Type: to.Ptr(armsecurity.RecommendationType("ProductSignature")), - Path: to.Ptr("%OSDRIVE%\\WINDOWSAZURE\\SECAGENT\\WASECAGENTPROV.EXE"), - Action: to.Ptr(armsecurity.RecommendationActionRecommended), - Common: to.Ptr(true), - ConfigurationStatus: to.Ptr(armsecurity.ConfigurationStatusConfigured), - FileType: to.Ptr(armsecurity.FileTypeExe), - PublisherInfo: &armsecurity.PublisherInfo{ - BinaryName: to.Ptr("*"), - ProductName: to.Ptr("MICROSOFT® COREXT"), - PublisherName: to.Ptr("CN=MICROSOFT AZURE DEPENDENCY CODE SIGN"), - Version: to.Ptr("0.0.0.0"), - }, - UserSids: []*string{ - to.Ptr("S-1-1-0")}, - Usernames: []*armsecurity.UserRecommendation{ - { - RecommendationAction: to.Ptr(armsecurity.RecommendationActionRecommended), - Username: to.Ptr("NT AUTHORITY\\SYSTEM"), - }}, - }, - { - Type: to.Ptr(armsecurity.RecommendationType("PublisherSignature")), - Path: to.Ptr("%OSDRIVE%\\WINDOWSAZURE\\PACKAGES_201973_7415\\COLLECTGUESTLOGS.EXE"), - Action: to.Ptr(armsecurity.RecommendationActionRecommended), - Common: to.Ptr(true), - ConfigurationStatus: to.Ptr(armsecurity.ConfigurationStatusConfigured), - FileType: to.Ptr(armsecurity.FileTypeExe), - PublisherInfo: &armsecurity.PublisherInfo{ - BinaryName: to.Ptr("*"), - ProductName: to.Ptr("*"), - PublisherName: to.Ptr("CN=MICROSOFT AZURE DEPENDENCY CODE SIGN"), - Version: to.Ptr("0.0.0.0"), - }, - UserSids: []*string{ - to.Ptr("S-1-1-0")}, - Usernames: []*armsecurity.UserRecommendation{ - { - RecommendationAction: to.Ptr(armsecurity.RecommendationActionRecommended), - Username: to.Ptr("NT AUTHORITY\\SYSTEM"), - }}, - }, - { - Type: to.Ptr(armsecurity.RecommendationType("File")), - Path: to.Ptr("C:\\directory\\file.exe"), - Action: to.Ptr(armsecurity.RecommendationActionAdd), - Common: to.Ptr(true), - }}, - ProtectionMode: &armsecurity.ProtectionMode{ - Exe: to.Ptr(armsecurity.EnforcementModeAudit), - Msi: to.Ptr(armsecurity.EnforcementModeNone), - Script: to.Ptr(armsecurity.EnforcementModeNone), - }, - VMRecommendations: []*armsecurity.VMRecommendation{ - { - ConfigurationStatus: to.Ptr(armsecurity.ConfigurationStatusConfigured), - EnforcementSupport: to.Ptr(armsecurity.EnforcementSupportSupported), - RecommendationAction: to.Ptr(armsecurity.RecommendationActionRecommended), - ResourceID: to.Ptr("/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourcegroups/erelh-stable/providers/microsoft.compute/virtualmachines/erelh-16090"), - }, - { - ConfigurationStatus: to.Ptr(armsecurity.ConfigurationStatusConfigured), - EnforcementSupport: to.Ptr(armsecurity.EnforcementSupportSupported), - RecommendationAction: to.Ptr(armsecurity.RecommendationActionRecommended), - ResourceID: to.Ptr("/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourcegroups/matanvs/providers/microsoft.compute/virtualmachines/matanvs19"), - }}, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/ApplicationWhitelistings/DeleteAdaptiveApplicationControls_example.json -func ExampleAdaptiveApplicationControlsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAdaptiveApplicationControlsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, "centralus", "GROUP1", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/security/armsecurity/adaptivenetworkhardenings_client.go b/sdk/resourcemanager/security/armsecurity/adaptivenetworkhardenings_client.go index 93a654b5efdd..ddb91e7baca0 100644 --- a/sdk/resourcemanager/security/armsecurity/adaptivenetworkhardenings_client.go +++ b/sdk/resourcemanager/security/armsecurity/adaptivenetworkhardenings_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,66 +24,59 @@ import ( // AdaptiveNetworkHardeningsClient contains the methods for the AdaptiveNetworkHardenings group. // Don't use this type directly, use NewAdaptiveNetworkHardeningsClient() instead. type AdaptiveNetworkHardeningsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewAdaptiveNetworkHardeningsClient creates a new instance of AdaptiveNetworkHardeningsClient with the specified values. -// subscriptionID - Azure subscription ID -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure subscription ID +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewAdaptiveNetworkHardeningsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AdaptiveNetworkHardeningsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".AdaptiveNetworkHardeningsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &AdaptiveNetworkHardeningsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginEnforce - Enforces the given rules on the NSG(s) listed in the request // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-01-01 -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// resourceNamespace - The Namespace of the resource. -// resourceType - The type of the resource. -// resourceName - Name of the resource. -// adaptiveNetworkHardeningResourceName - The name of the Adaptive Network Hardening resource. -// options - AdaptiveNetworkHardeningsClientBeginEnforceOptions contains the optional parameters for the AdaptiveNetworkHardeningsClient.BeginEnforce -// method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - resourceNamespace - The Namespace of the resource. +// - resourceType - The type of the resource. +// - resourceName - Name of the resource. +// - adaptiveNetworkHardeningResourceName - The name of the Adaptive Network Hardening resource. +// - options - AdaptiveNetworkHardeningsClientBeginEnforceOptions contains the optional parameters for the AdaptiveNetworkHardeningsClient.BeginEnforce +// method. func (client *AdaptiveNetworkHardeningsClient) BeginEnforce(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string, adaptiveNetworkHardeningResourceName string, body AdaptiveNetworkHardeningEnforceRequest, options *AdaptiveNetworkHardeningsClientBeginEnforceOptions) (*runtime.Poller[AdaptiveNetworkHardeningsClientEnforceResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.enforce(ctx, resourceGroupName, resourceNamespace, resourceType, resourceName, adaptiveNetworkHardeningResourceName, body, options) if err != nil { return nil, err } - return runtime.NewPoller[AdaptiveNetworkHardeningsClientEnforceResponse](resp, client.pl, nil) + return runtime.NewPoller[AdaptiveNetworkHardeningsClientEnforceResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[AdaptiveNetworkHardeningsClientEnforceResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[AdaptiveNetworkHardeningsClientEnforceResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Enforce - Enforces the given rules on the NSG(s) listed in the request // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-01-01 func (client *AdaptiveNetworkHardeningsClient) enforce(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string, adaptiveNetworkHardeningResourceName string, body AdaptiveNetworkHardeningEnforceRequest, options *AdaptiveNetworkHardeningsClientBeginEnforceOptions) (*http.Response, error) { req, err := client.enforceCreateRequest(ctx, resourceGroupName, resourceNamespace, resourceType, resourceName, adaptiveNetworkHardeningResourceName, body, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -123,7 +114,7 @@ func (client *AdaptiveNetworkHardeningsClient) enforceCreateRequest(ctx context. } urlPath = strings.ReplaceAll(urlPath, "{adaptiveNetworkHardeningResourceName}", url.PathEscape(adaptiveNetworkHardeningResourceName)) urlPath = strings.ReplaceAll(urlPath, "{adaptiveNetworkHardeningEnforceAction}", url.PathEscape("enforce")) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -136,20 +127,21 @@ func (client *AdaptiveNetworkHardeningsClient) enforceCreateRequest(ctx context. // Get - Gets a single Adaptive Network Hardening resource // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-01-01 -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// resourceNamespace - The Namespace of the resource. -// resourceType - The type of the resource. -// resourceName - Name of the resource. -// adaptiveNetworkHardeningResourceName - The name of the Adaptive Network Hardening resource. -// options - AdaptiveNetworkHardeningsClientGetOptions contains the optional parameters for the AdaptiveNetworkHardeningsClient.Get -// method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - resourceNamespace - The Namespace of the resource. +// - resourceType - The type of the resource. +// - resourceName - Name of the resource. +// - adaptiveNetworkHardeningResourceName - The name of the Adaptive Network Hardening resource. +// - options - AdaptiveNetworkHardeningsClientGetOptions contains the optional parameters for the AdaptiveNetworkHardeningsClient.Get +// method. func (client *AdaptiveNetworkHardeningsClient) Get(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string, adaptiveNetworkHardeningResourceName string, options *AdaptiveNetworkHardeningsClientGetOptions) (AdaptiveNetworkHardeningsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, resourceNamespace, resourceType, resourceName, adaptiveNetworkHardeningResourceName, options) if err != nil { return AdaptiveNetworkHardeningsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AdaptiveNetworkHardeningsClientGetResponse{}, err } @@ -186,7 +178,7 @@ func (client *AdaptiveNetworkHardeningsClient) getCreateRequest(ctx context.Cont return nil, errors.New("parameter adaptiveNetworkHardeningResourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{adaptiveNetworkHardeningResourceName}", url.PathEscape(adaptiveNetworkHardeningResourceName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -207,13 +199,14 @@ func (client *AdaptiveNetworkHardeningsClient) getHandleResponse(resp *http.Resp } // NewListByExtendedResourcePager - Gets a list of Adaptive Network Hardenings resources in scope of an extended resource. +// // Generated from API version 2020-01-01 -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// resourceNamespace - The Namespace of the resource. -// resourceType - The type of the resource. -// resourceName - Name of the resource. -// options - AdaptiveNetworkHardeningsClientListByExtendedResourceOptions contains the optional parameters for the AdaptiveNetworkHardeningsClient.ListByExtendedResource -// method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - resourceNamespace - The Namespace of the resource. +// - resourceType - The type of the resource. +// - resourceName - Name of the resource. +// - options - AdaptiveNetworkHardeningsClientListByExtendedResourceOptions contains the optional parameters for the AdaptiveNetworkHardeningsClient.NewListByExtendedResourcePager +// method. func (client *AdaptiveNetworkHardeningsClient) NewListByExtendedResourcePager(resourceGroupName string, resourceNamespace string, resourceType string, resourceName string, options *AdaptiveNetworkHardeningsClientListByExtendedResourceOptions) *runtime.Pager[AdaptiveNetworkHardeningsClientListByExtendedResourceResponse] { return runtime.NewPager(runtime.PagingHandler[AdaptiveNetworkHardeningsClientListByExtendedResourceResponse]{ More: func(page AdaptiveNetworkHardeningsClientListByExtendedResourceResponse) bool { @@ -230,7 +223,7 @@ func (client *AdaptiveNetworkHardeningsClient) NewListByExtendedResourcePager(re if err != nil { return AdaptiveNetworkHardeningsClientListByExtendedResourceResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AdaptiveNetworkHardeningsClientListByExtendedResourceResponse{}, err } @@ -265,7 +258,7 @@ func (client *AdaptiveNetworkHardeningsClient) listByExtendedResourceCreateReque return nil, errors.New("parameter resourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/security/armsecurity/adaptivenetworkhardenings_client_example_test.go b/sdk/resourcemanager/security/armsecurity/adaptivenetworkhardenings_client_example_test.go deleted file mode 100644 index 44fde258e75b..000000000000 --- a/sdk/resourcemanager/security/armsecurity/adaptivenetworkhardenings_client_example_test.go +++ /dev/null @@ -1,106 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. - -package armsecurity_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/AdaptiveNetworkHardenings/ListByExtendedResourceAdaptiveNetworkHardenings_example.json -func ExampleAdaptiveNetworkHardeningsClient_NewListByExtendedResourcePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAdaptiveNetworkHardeningsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByExtendedResourcePager("rg1", "Microsoft.Compute", "virtualMachines", "vm1", nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/AdaptiveNetworkHardenings/GetAdaptiveNetworkHardening_example.json -func ExampleAdaptiveNetworkHardeningsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAdaptiveNetworkHardeningsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "rg1", "Microsoft.Compute", "virtualMachines", "vm1", "default", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/AdaptiveNetworkHardenings/EnforceAdaptiveNetworkHardeningRules_example.json -func ExampleAdaptiveNetworkHardeningsClient_BeginEnforce() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAdaptiveNetworkHardeningsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginEnforce(ctx, "rg1", "Microsoft.Compute", "virtualMachines", "vm1", "default", armsecurity.AdaptiveNetworkHardeningEnforceRequest{ - NetworkSecurityGroups: []*string{ - to.Ptr("/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/rg1/providers/Microsoft.Network/networkSecurityGroups/nsg1"), - to.Ptr("/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/rg2/providers/Microsoft.Network/networkSecurityGroups/nsg2")}, - Rules: []*armsecurity.Rule{ - { - Name: to.Ptr("rule1"), - DestinationPort: to.Ptr[int32](3389), - Direction: to.Ptr(armsecurity.DirectionInbound), - IPAddresses: []*string{ - to.Ptr("100.10.1.1"), - to.Ptr("200.20.2.2"), - to.Ptr("81.199.3.0/24")}, - Protocols: []*armsecurity.TransportProtocol{ - to.Ptr(armsecurity.TransportProtocolTCP)}, - }, - { - Name: to.Ptr("rule2"), - DestinationPort: to.Ptr[int32](22), - Direction: to.Ptr(armsecurity.DirectionInbound), - IPAddresses: []*string{}, - Protocols: []*armsecurity.TransportProtocol{ - to.Ptr(armsecurity.TransportProtocolTCP)}, - }}, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} diff --git a/sdk/resourcemanager/security/armsecurity/advancedthreatprotection_client.go b/sdk/resourcemanager/security/armsecurity/advancedthreatprotection_client.go index 6af769e44f1b..77f1b1dc0085 100644 --- a/sdk/resourcemanager/security/armsecurity/advancedthreatprotection_client.go +++ b/sdk/resourcemanager/security/armsecurity/advancedthreatprotection_client.go @@ -13,8 +13,6 @@ import ( "context" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,45 +23,37 @@ import ( // AdvancedThreatProtectionClient contains the methods for the AdvancedThreatProtection group. // Don't use this type directly, use NewAdvancedThreatProtectionClient() instead. type AdvancedThreatProtectionClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewAdvancedThreatProtectionClient creates a new instance of AdvancedThreatProtectionClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewAdvancedThreatProtectionClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*AdvancedThreatProtectionClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".AdvancedThreatProtectionClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &AdvancedThreatProtectionClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } // Create - Creates or updates the Advanced Threat Protection settings on a specified resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-01-01 -// resourceID - The identifier of the resource. -// advancedThreatProtectionSetting - Advanced Threat Protection Settings -// options - AdvancedThreatProtectionClientCreateOptions contains the optional parameters for the AdvancedThreatProtectionClient.Create -// method. +// - resourceID - The identifier of the resource. +// - advancedThreatProtectionSetting - Advanced Threat Protection Settings +// - options - AdvancedThreatProtectionClientCreateOptions contains the optional parameters for the AdvancedThreatProtectionClient.Create +// method. func (client *AdvancedThreatProtectionClient) Create(ctx context.Context, resourceID string, advancedThreatProtectionSetting AdvancedThreatProtectionSetting, options *AdvancedThreatProtectionClientCreateOptions) (AdvancedThreatProtectionClientCreateResponse, error) { req, err := client.createCreateRequest(ctx, resourceID, advancedThreatProtectionSetting, options) if err != nil { return AdvancedThreatProtectionClientCreateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AdvancedThreatProtectionClientCreateResponse{}, err } @@ -78,7 +68,7 @@ func (client *AdvancedThreatProtectionClient) createCreateRequest(ctx context.Co urlPath := "/{resourceId}/providers/Microsoft.Security/advancedThreatProtectionSettings/{settingName}" urlPath = strings.ReplaceAll(urlPath, "{resourceId}", resourceID) urlPath = strings.ReplaceAll(urlPath, "{settingName}", url.PathEscape("current")) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -100,16 +90,17 @@ func (client *AdvancedThreatProtectionClient) createHandleResponse(resp *http.Re // Get - Gets the Advanced Threat Protection settings for the specified resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-01-01 -// resourceID - The identifier of the resource. -// options - AdvancedThreatProtectionClientGetOptions contains the optional parameters for the AdvancedThreatProtectionClient.Get -// method. +// - resourceID - The identifier of the resource. +// - options - AdvancedThreatProtectionClientGetOptions contains the optional parameters for the AdvancedThreatProtectionClient.Get +// method. func (client *AdvancedThreatProtectionClient) Get(ctx context.Context, resourceID string, options *AdvancedThreatProtectionClientGetOptions) (AdvancedThreatProtectionClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceID, options) if err != nil { return AdvancedThreatProtectionClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AdvancedThreatProtectionClientGetResponse{}, err } @@ -124,7 +115,7 @@ func (client *AdvancedThreatProtectionClient) getCreateRequest(ctx context.Conte urlPath := "/{resourceId}/providers/Microsoft.Security/advancedThreatProtectionSettings/{settingName}" urlPath = strings.ReplaceAll(urlPath, "{resourceId}", resourceID) urlPath = strings.ReplaceAll(urlPath, "{settingName}", url.PathEscape("current")) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/security/armsecurity/advancedthreatprotection_client_example_test.go b/sdk/resourcemanager/security/armsecurity/advancedthreatprotection_client_example_test.go deleted file mode 100644 index b699a5751cfe..000000000000 --- a/sdk/resourcemanager/security/armsecurity/advancedthreatprotection_client_example_test.go +++ /dev/null @@ -1,63 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. - -package armsecurity_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2019-01-01/examples/AdvancedThreatProtection/GetAdvancedThreatProtectionSettings_example.json -func ExampleAdvancedThreatProtectionClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAdvancedThreatProtectionClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/SampleRG/providers/Microsoft.Storage/storageAccounts/samplestorageaccount", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2019-01-01/examples/AdvancedThreatProtection/PutAdvancedThreatProtectionSettings_example.json -func ExampleAdvancedThreatProtectionClient_Create() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAdvancedThreatProtectionClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Create(ctx, "subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/SampleRG/providers/Microsoft.Storage/storageAccounts/samplestorageaccount", armsecurity.AdvancedThreatProtectionSetting{ - Name: to.Ptr("current"), - Type: to.Ptr("Microsoft.Security/advancedThreatProtectionSettings"), - ID: to.Ptr("/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/SampleRG/providers/Microsoft.Storage/storageAccounts/samplestorageaccount/providers/Microsoft.Security/advancedThreatProtectionSettings/current"), - Properties: &armsecurity.AdvancedThreatProtectionProperties{ - IsEnabled: to.Ptr(true), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/security/armsecurity/alerts_client.go b/sdk/resourcemanager/security/armsecurity/alerts_client.go index 47c1652825ce..ff92fdafd2a7 100644 --- a/sdk/resourcemanager/security/armsecurity/alerts_client.go +++ b/sdk/resourcemanager/security/armsecurity/alerts_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,49 +24,41 @@ import ( // AlertsClient contains the methods for the Alerts group. // Don't use this type directly, use NewAlertsClient() instead. type AlertsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewAlertsClient creates a new instance of AlertsClient with the specified values. -// subscriptionID - Azure subscription ID -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure subscription ID +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewAlertsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AlertsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".AlertsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &AlertsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // GetResourceGroupLevel - Get an alert that is associated a resource group or a resource in a resource group // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-01 -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations -// alertName - Name of the alert object -// options - AlertsClientGetResourceGroupLevelOptions contains the optional parameters for the AlertsClient.GetResourceGroupLevel -// method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations +// - alertName - Name of the alert object +// - options - AlertsClientGetResourceGroupLevelOptions contains the optional parameters for the AlertsClient.GetResourceGroupLevel +// method. func (client *AlertsClient) GetResourceGroupLevel(ctx context.Context, resourceGroupName string, ascLocation string, alertName string, options *AlertsClientGetResourceGroupLevelOptions) (AlertsClientGetResourceGroupLevelResponse, error) { req, err := client.getResourceGroupLevelCreateRequest(ctx, resourceGroupName, ascLocation, alertName, options) if err != nil { return AlertsClientGetResourceGroupLevelResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AlertsClientGetResourceGroupLevelResponse{}, err } @@ -97,7 +87,7 @@ func (client *AlertsClient) getResourceGroupLevelCreateRequest(ctx context.Conte return nil, errors.New("parameter alertName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{alertName}", url.PathEscape(alertName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -119,17 +109,18 @@ func (client *AlertsClient) getResourceGroupLevelHandleResponse(resp *http.Respo // GetSubscriptionLevel - Get an alert that is associated with a subscription // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-01 -// ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations -// alertName - Name of the alert object -// options - AlertsClientGetSubscriptionLevelOptions contains the optional parameters for the AlertsClient.GetSubscriptionLevel -// method. +// - ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations +// - alertName - Name of the alert object +// - options - AlertsClientGetSubscriptionLevelOptions contains the optional parameters for the AlertsClient.GetSubscriptionLevel +// method. func (client *AlertsClient) GetSubscriptionLevel(ctx context.Context, ascLocation string, alertName string, options *AlertsClientGetSubscriptionLevelOptions) (AlertsClientGetSubscriptionLevelResponse, error) { req, err := client.getSubscriptionLevelCreateRequest(ctx, ascLocation, alertName, options) if err != nil { return AlertsClientGetSubscriptionLevelResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AlertsClientGetSubscriptionLevelResponse{}, err } @@ -154,7 +145,7 @@ func (client *AlertsClient) getSubscriptionLevelCreateRequest(ctx context.Contex return nil, errors.New("parameter alertName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{alertName}", url.PathEscape(alertName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -175,8 +166,9 @@ func (client *AlertsClient) getSubscriptionLevelHandleResponse(resp *http.Respon } // NewListPager - List all the alerts that are associated with the subscription +// // Generated from API version 2022-01-01 -// options - AlertsClientListOptions contains the optional parameters for the AlertsClient.List method. +// - options - AlertsClientListOptions contains the optional parameters for the AlertsClient.NewListPager method. func (client *AlertsClient) NewListPager(options *AlertsClientListOptions) *runtime.Pager[AlertsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[AlertsClientListResponse]{ More: func(page AlertsClientListResponse) bool { @@ -193,7 +185,7 @@ func (client *AlertsClient) NewListPager(options *AlertsClientListOptions) *runt if err != nil { return AlertsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AlertsClientListResponse{}, err } @@ -212,7 +204,7 @@ func (client *AlertsClient) listCreateRequest(ctx context.Context, options *Aler return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -233,10 +225,11 @@ func (client *AlertsClient) listHandleResponse(resp *http.Response) (AlertsClien } // NewListByResourceGroupPager - List all the alerts that are associated with the resource group +// // Generated from API version 2022-01-01 -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// options - AlertsClientListByResourceGroupOptions contains the optional parameters for the AlertsClient.ListByResourceGroup -// method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - options - AlertsClientListByResourceGroupOptions contains the optional parameters for the AlertsClient.NewListByResourceGroupPager +// method. func (client *AlertsClient) NewListByResourceGroupPager(resourceGroupName string, options *AlertsClientListByResourceGroupOptions) *runtime.Pager[AlertsClientListByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[AlertsClientListByResourceGroupResponse]{ More: func(page AlertsClientListByResourceGroupResponse) bool { @@ -253,7 +246,7 @@ func (client *AlertsClient) NewListByResourceGroupPager(resourceGroupName string if err != nil { return AlertsClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AlertsClientListByResourceGroupResponse{}, err } @@ -276,7 +269,7 @@ func (client *AlertsClient) listByResourceGroupCreateRequest(ctx context.Context return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -298,11 +291,12 @@ func (client *AlertsClient) listByResourceGroupHandleResponse(resp *http.Respons // NewListResourceGroupLevelByRegionPager - List all the alerts that are associated with the resource group that are stored // in a specific location +// // Generated from API version 2022-01-01 -// ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// options - AlertsClientListResourceGroupLevelByRegionOptions contains the optional parameters for the AlertsClient.ListResourceGroupLevelByRegion -// method. +// - ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - options - AlertsClientListResourceGroupLevelByRegionOptions contains the optional parameters for the AlertsClient.NewListResourceGroupLevelByRegionPager +// method. func (client *AlertsClient) NewListResourceGroupLevelByRegionPager(ascLocation string, resourceGroupName string, options *AlertsClientListResourceGroupLevelByRegionOptions) *runtime.Pager[AlertsClientListResourceGroupLevelByRegionResponse] { return runtime.NewPager(runtime.PagingHandler[AlertsClientListResourceGroupLevelByRegionResponse]{ More: func(page AlertsClientListResourceGroupLevelByRegionResponse) bool { @@ -319,7 +313,7 @@ func (client *AlertsClient) NewListResourceGroupLevelByRegionPager(ascLocation s if err != nil { return AlertsClientListResourceGroupLevelByRegionResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AlertsClientListResourceGroupLevelByRegionResponse{}, err } @@ -346,7 +340,7 @@ func (client *AlertsClient) listResourceGroupLevelByRegionCreateRequest(ctx cont return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -368,10 +362,11 @@ func (client *AlertsClient) listResourceGroupLevelByRegionHandleResponse(resp *h // NewListSubscriptionLevelByRegionPager - List all the alerts that are associated with the subscription that are stored in // a specific location +// // Generated from API version 2022-01-01 -// ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations -// options - AlertsClientListSubscriptionLevelByRegionOptions contains the optional parameters for the AlertsClient.ListSubscriptionLevelByRegion -// method. +// - ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations +// - options - AlertsClientListSubscriptionLevelByRegionOptions contains the optional parameters for the AlertsClient.NewListSubscriptionLevelByRegionPager +// method. func (client *AlertsClient) NewListSubscriptionLevelByRegionPager(ascLocation string, options *AlertsClientListSubscriptionLevelByRegionOptions) *runtime.Pager[AlertsClientListSubscriptionLevelByRegionResponse] { return runtime.NewPager(runtime.PagingHandler[AlertsClientListSubscriptionLevelByRegionResponse]{ More: func(page AlertsClientListSubscriptionLevelByRegionResponse) bool { @@ -388,7 +383,7 @@ func (client *AlertsClient) NewListSubscriptionLevelByRegionPager(ascLocation st if err != nil { return AlertsClientListSubscriptionLevelByRegionResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AlertsClientListSubscriptionLevelByRegionResponse{}, err } @@ -411,7 +406,7 @@ func (client *AlertsClient) listSubscriptionLevelByRegionCreateRequest(ctx conte return nil, errors.New("parameter ascLocation cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{ascLocation}", url.PathEscape(ascLocation)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -433,33 +428,35 @@ func (client *AlertsClient) listSubscriptionLevelByRegionHandleResponse(resp *ht // BeginSimulate - Simulate security alerts // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-01 -// ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations -// alertSimulatorRequestBody - Alert Simulator Request Properties -// options - AlertsClientBeginSimulateOptions contains the optional parameters for the AlertsClient.BeginSimulate method. +// - ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations +// - alertSimulatorRequestBody - Alert Simulator Request Properties +// - options - AlertsClientBeginSimulateOptions contains the optional parameters for the AlertsClient.BeginSimulate method. func (client *AlertsClient) BeginSimulate(ctx context.Context, ascLocation string, alertSimulatorRequestBody AlertSimulatorRequestBody, options *AlertsClientBeginSimulateOptions) (*runtime.Poller[AlertsClientSimulateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.simulate(ctx, ascLocation, alertSimulatorRequestBody, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[AlertsClientSimulateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[AlertsClientSimulateResponse]{ FinalStateVia: runtime.FinalStateViaOriginalURI, }) } else { - return runtime.NewPollerFromResumeToken[AlertsClientSimulateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[AlertsClientSimulateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Simulate - Simulate security alerts // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-01 func (client *AlertsClient) simulate(ctx context.Context, ascLocation string, alertSimulatorRequestBody AlertSimulatorRequestBody, options *AlertsClientBeginSimulateOptions) (*http.Response, error) { req, err := client.simulateCreateRequest(ctx, ascLocation, alertSimulatorRequestBody, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -480,7 +477,7 @@ func (client *AlertsClient) simulateCreateRequest(ctx context.Context, ascLocati return nil, errors.New("parameter ascLocation cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{ascLocation}", url.PathEscape(ascLocation)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -493,18 +490,19 @@ func (client *AlertsClient) simulateCreateRequest(ctx context.Context, ascLocati // UpdateResourceGroupLevelStateToActivate - Update the alert's state // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-01 -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations -// alertName - Name of the alert object -// options - AlertsClientUpdateResourceGroupLevelStateToActivateOptions contains the optional parameters for the AlertsClient.UpdateResourceGroupLevelStateToActivate -// method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations +// - alertName - Name of the alert object +// - options - AlertsClientUpdateResourceGroupLevelStateToActivateOptions contains the optional parameters for the AlertsClient.UpdateResourceGroupLevelStateToActivate +// method. func (client *AlertsClient) UpdateResourceGroupLevelStateToActivate(ctx context.Context, resourceGroupName string, ascLocation string, alertName string, options *AlertsClientUpdateResourceGroupLevelStateToActivateOptions) (AlertsClientUpdateResourceGroupLevelStateToActivateResponse, error) { req, err := client.updateResourceGroupLevelStateToActivateCreateRequest(ctx, resourceGroupName, ascLocation, alertName, options) if err != nil { return AlertsClientUpdateResourceGroupLevelStateToActivateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AlertsClientUpdateResourceGroupLevelStateToActivateResponse{}, err } @@ -533,7 +531,7 @@ func (client *AlertsClient) updateResourceGroupLevelStateToActivateCreateRequest return nil, errors.New("parameter alertName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{alertName}", url.PathEscape(alertName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -546,18 +544,19 @@ func (client *AlertsClient) updateResourceGroupLevelStateToActivateCreateRequest // UpdateResourceGroupLevelStateToDismiss - Update the alert's state // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-01 -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations -// alertName - Name of the alert object -// options - AlertsClientUpdateResourceGroupLevelStateToDismissOptions contains the optional parameters for the AlertsClient.UpdateResourceGroupLevelStateToDismiss -// method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations +// - alertName - Name of the alert object +// - options - AlertsClientUpdateResourceGroupLevelStateToDismissOptions contains the optional parameters for the AlertsClient.UpdateResourceGroupLevelStateToDismiss +// method. func (client *AlertsClient) UpdateResourceGroupLevelStateToDismiss(ctx context.Context, resourceGroupName string, ascLocation string, alertName string, options *AlertsClientUpdateResourceGroupLevelStateToDismissOptions) (AlertsClientUpdateResourceGroupLevelStateToDismissResponse, error) { req, err := client.updateResourceGroupLevelStateToDismissCreateRequest(ctx, resourceGroupName, ascLocation, alertName, options) if err != nil { return AlertsClientUpdateResourceGroupLevelStateToDismissResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AlertsClientUpdateResourceGroupLevelStateToDismissResponse{}, err } @@ -586,7 +585,7 @@ func (client *AlertsClient) updateResourceGroupLevelStateToDismissCreateRequest( return nil, errors.New("parameter alertName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{alertName}", url.PathEscape(alertName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -599,18 +598,19 @@ func (client *AlertsClient) updateResourceGroupLevelStateToDismissCreateRequest( // UpdateResourceGroupLevelStateToInProgress - Update the alert's state // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-01 -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations -// alertName - Name of the alert object -// options - AlertsClientUpdateResourceGroupLevelStateToInProgressOptions contains the optional parameters for the AlertsClient.UpdateResourceGroupLevelStateToInProgress -// method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations +// - alertName - Name of the alert object +// - options - AlertsClientUpdateResourceGroupLevelStateToInProgressOptions contains the optional parameters for the AlertsClient.UpdateResourceGroupLevelStateToInProgress +// method. func (client *AlertsClient) UpdateResourceGroupLevelStateToInProgress(ctx context.Context, resourceGroupName string, ascLocation string, alertName string, options *AlertsClientUpdateResourceGroupLevelStateToInProgressOptions) (AlertsClientUpdateResourceGroupLevelStateToInProgressResponse, error) { req, err := client.updateResourceGroupLevelStateToInProgressCreateRequest(ctx, resourceGroupName, ascLocation, alertName, options) if err != nil { return AlertsClientUpdateResourceGroupLevelStateToInProgressResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AlertsClientUpdateResourceGroupLevelStateToInProgressResponse{}, err } @@ -639,7 +639,7 @@ func (client *AlertsClient) updateResourceGroupLevelStateToInProgressCreateReque return nil, errors.New("parameter alertName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{alertName}", url.PathEscape(alertName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -652,18 +652,19 @@ func (client *AlertsClient) updateResourceGroupLevelStateToInProgressCreateReque // UpdateResourceGroupLevelStateToResolve - Update the alert's state // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-01 -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations -// alertName - Name of the alert object -// options - AlertsClientUpdateResourceGroupLevelStateToResolveOptions contains the optional parameters for the AlertsClient.UpdateResourceGroupLevelStateToResolve -// method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations +// - alertName - Name of the alert object +// - options - AlertsClientUpdateResourceGroupLevelStateToResolveOptions contains the optional parameters for the AlertsClient.UpdateResourceGroupLevelStateToResolve +// method. func (client *AlertsClient) UpdateResourceGroupLevelStateToResolve(ctx context.Context, resourceGroupName string, ascLocation string, alertName string, options *AlertsClientUpdateResourceGroupLevelStateToResolveOptions) (AlertsClientUpdateResourceGroupLevelStateToResolveResponse, error) { req, err := client.updateResourceGroupLevelStateToResolveCreateRequest(ctx, resourceGroupName, ascLocation, alertName, options) if err != nil { return AlertsClientUpdateResourceGroupLevelStateToResolveResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AlertsClientUpdateResourceGroupLevelStateToResolveResponse{}, err } @@ -692,7 +693,7 @@ func (client *AlertsClient) updateResourceGroupLevelStateToResolveCreateRequest( return nil, errors.New("parameter alertName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{alertName}", url.PathEscape(alertName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -705,17 +706,18 @@ func (client *AlertsClient) updateResourceGroupLevelStateToResolveCreateRequest( // UpdateSubscriptionLevelStateToActivate - Update the alert's state // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-01 -// ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations -// alertName - Name of the alert object -// options - AlertsClientUpdateSubscriptionLevelStateToActivateOptions contains the optional parameters for the AlertsClient.UpdateSubscriptionLevelStateToActivate -// method. +// - ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations +// - alertName - Name of the alert object +// - options - AlertsClientUpdateSubscriptionLevelStateToActivateOptions contains the optional parameters for the AlertsClient.UpdateSubscriptionLevelStateToActivate +// method. func (client *AlertsClient) UpdateSubscriptionLevelStateToActivate(ctx context.Context, ascLocation string, alertName string, options *AlertsClientUpdateSubscriptionLevelStateToActivateOptions) (AlertsClientUpdateSubscriptionLevelStateToActivateResponse, error) { req, err := client.updateSubscriptionLevelStateToActivateCreateRequest(ctx, ascLocation, alertName, options) if err != nil { return AlertsClientUpdateSubscriptionLevelStateToActivateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AlertsClientUpdateSubscriptionLevelStateToActivateResponse{}, err } @@ -740,7 +742,7 @@ func (client *AlertsClient) updateSubscriptionLevelStateToActivateCreateRequest( return nil, errors.New("parameter alertName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{alertName}", url.PathEscape(alertName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -753,17 +755,18 @@ func (client *AlertsClient) updateSubscriptionLevelStateToActivateCreateRequest( // UpdateSubscriptionLevelStateToDismiss - Update the alert's state // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-01 -// ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations -// alertName - Name of the alert object -// options - AlertsClientUpdateSubscriptionLevelStateToDismissOptions contains the optional parameters for the AlertsClient.UpdateSubscriptionLevelStateToDismiss -// method. +// - ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations +// - alertName - Name of the alert object +// - options - AlertsClientUpdateSubscriptionLevelStateToDismissOptions contains the optional parameters for the AlertsClient.UpdateSubscriptionLevelStateToDismiss +// method. func (client *AlertsClient) UpdateSubscriptionLevelStateToDismiss(ctx context.Context, ascLocation string, alertName string, options *AlertsClientUpdateSubscriptionLevelStateToDismissOptions) (AlertsClientUpdateSubscriptionLevelStateToDismissResponse, error) { req, err := client.updateSubscriptionLevelStateToDismissCreateRequest(ctx, ascLocation, alertName, options) if err != nil { return AlertsClientUpdateSubscriptionLevelStateToDismissResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AlertsClientUpdateSubscriptionLevelStateToDismissResponse{}, err } @@ -788,7 +791,7 @@ func (client *AlertsClient) updateSubscriptionLevelStateToDismissCreateRequest(c return nil, errors.New("parameter alertName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{alertName}", url.PathEscape(alertName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -801,17 +804,18 @@ func (client *AlertsClient) updateSubscriptionLevelStateToDismissCreateRequest(c // UpdateSubscriptionLevelStateToInProgress - Update the alert's state // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-01 -// ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations -// alertName - Name of the alert object -// options - AlertsClientUpdateSubscriptionLevelStateToInProgressOptions contains the optional parameters for the AlertsClient.UpdateSubscriptionLevelStateToInProgress -// method. +// - ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations +// - alertName - Name of the alert object +// - options - AlertsClientUpdateSubscriptionLevelStateToInProgressOptions contains the optional parameters for the AlertsClient.UpdateSubscriptionLevelStateToInProgress +// method. func (client *AlertsClient) UpdateSubscriptionLevelStateToInProgress(ctx context.Context, ascLocation string, alertName string, options *AlertsClientUpdateSubscriptionLevelStateToInProgressOptions) (AlertsClientUpdateSubscriptionLevelStateToInProgressResponse, error) { req, err := client.updateSubscriptionLevelStateToInProgressCreateRequest(ctx, ascLocation, alertName, options) if err != nil { return AlertsClientUpdateSubscriptionLevelStateToInProgressResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AlertsClientUpdateSubscriptionLevelStateToInProgressResponse{}, err } @@ -836,7 +840,7 @@ func (client *AlertsClient) updateSubscriptionLevelStateToInProgressCreateReques return nil, errors.New("parameter alertName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{alertName}", url.PathEscape(alertName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -849,17 +853,18 @@ func (client *AlertsClient) updateSubscriptionLevelStateToInProgressCreateReques // UpdateSubscriptionLevelStateToResolve - Update the alert's state // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-01 -// ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations -// alertName - Name of the alert object -// options - AlertsClientUpdateSubscriptionLevelStateToResolveOptions contains the optional parameters for the AlertsClient.UpdateSubscriptionLevelStateToResolve -// method. +// - ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations +// - alertName - Name of the alert object +// - options - AlertsClientUpdateSubscriptionLevelStateToResolveOptions contains the optional parameters for the AlertsClient.UpdateSubscriptionLevelStateToResolve +// method. func (client *AlertsClient) UpdateSubscriptionLevelStateToResolve(ctx context.Context, ascLocation string, alertName string, options *AlertsClientUpdateSubscriptionLevelStateToResolveOptions) (AlertsClientUpdateSubscriptionLevelStateToResolveResponse, error) { req, err := client.updateSubscriptionLevelStateToResolveCreateRequest(ctx, ascLocation, alertName, options) if err != nil { return AlertsClientUpdateSubscriptionLevelStateToResolveResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AlertsClientUpdateSubscriptionLevelStateToResolveResponse{}, err } @@ -884,7 +889,7 @@ func (client *AlertsClient) updateSubscriptionLevelStateToResolveCreateRequest(c return nil, errors.New("parameter alertName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{alertName}", url.PathEscape(alertName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/security/armsecurity/alerts_client_example_test.go b/sdk/resourcemanager/security/armsecurity/alerts_client_example_test.go deleted file mode 100644 index e50f67dd567e..000000000000 --- a/sdk/resourcemanager/security/armsecurity/alerts_client_example_test.go +++ /dev/null @@ -1,323 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. - -package armsecurity_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2022-01-01/examples/Alerts/GetAlertsSubscription_example.json -func ExampleAlertsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAlertsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2022-01-01/examples/Alerts/GetAlertsResourceGroup_example.json -func ExampleAlertsClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAlertsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByResourceGroupPager("myRg1", nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2022-01-01/examples/Alerts/GetAlertsSubscriptionsLocation_example.json -func ExampleAlertsClient_NewListSubscriptionLevelByRegionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAlertsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListSubscriptionLevelByRegionPager("westeurope", nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2022-01-01/examples/Alerts/GetAlertsResourceGroupLocation_example.json -func ExampleAlertsClient_NewListResourceGroupLevelByRegionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAlertsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListResourceGroupLevelByRegionPager("westeurope", "myRg1", nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2022-01-01/examples/Alerts/GetAlertSubscriptionLocation_example.json -func ExampleAlertsClient_GetSubscriptionLevel() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAlertsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.GetSubscriptionLevel(ctx, "westeurope", "2518770965529163669_F144EE95-A3E5-42DA-A279-967D115809AA", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2022-01-01/examples/Alerts/GetAlertResourceGroupLocation_example.json -func ExampleAlertsClient_GetResourceGroupLevel() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAlertsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.GetResourceGroupLevel(ctx, "myRg1", "westeurope", "2518298467986649999_4d25bfef-2d77-4a08-adc0-3e35715cc92a", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2022-01-01/examples/Alerts/UpdateAlertSubscriptionLocation_dismiss_example.json -func ExampleAlertsClient_UpdateSubscriptionLevelStateToDismiss() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAlertsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.UpdateSubscriptionLevelStateToDismiss(ctx, "westeurope", "2518298467986649999_4d25bfef-2d77-4a08-adc0-3e35715cc92a", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2022-01-01/examples/Alerts/UpdateAlertSubscriptionLocation_resolve_example.json -func ExampleAlertsClient_UpdateSubscriptionLevelStateToResolve() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAlertsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.UpdateSubscriptionLevelStateToResolve(ctx, "westeurope", "2518298467986649999_4d25bfef-2d77-4a08-adc0-3e35715cc92a", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2022-01-01/examples/Alerts/UpdateAlertSubscriptionLocation_activate_example.json -func ExampleAlertsClient_UpdateSubscriptionLevelStateToActivate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAlertsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.UpdateSubscriptionLevelStateToActivate(ctx, "westeurope", "2518298467986649999_4d25bfef-2d77-4a08-adc0-3e35715cc92a", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2022-01-01/examples/Alerts/UpdateAlertSubscriptionLocation_inProgress_example.json -func ExampleAlertsClient_UpdateSubscriptionLevelStateToInProgress() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAlertsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.UpdateSubscriptionLevelStateToInProgress(ctx, "westeurope", "2518298467986649999_4d25bfef-2d77-4a08-adc0-3e35715cc92a", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2022-01-01/examples/Alerts/UpdateAlertResourceGroupLocation_resolve_example.json -func ExampleAlertsClient_UpdateResourceGroupLevelStateToResolve() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAlertsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.UpdateResourceGroupLevelStateToResolve(ctx, "myRg2", "westeurope", "2518765996949954086_2325cf9e-42a2-4f72-ae7f-9b863cba2d22", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2022-01-01/examples/Alerts/UpdateAlertResourceGroupLocation_dismiss_example.json -func ExampleAlertsClient_UpdateResourceGroupLevelStateToDismiss() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAlertsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.UpdateResourceGroupLevelStateToDismiss(ctx, "myRg2", "westeurope", "2518765996949954086_2325cf9e-42a2-4f72-ae7f-9b863cba2d22", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2022-01-01/examples/Alerts/UpdateAlertResourceGroupLocation_activate_example.json -func ExampleAlertsClient_UpdateResourceGroupLevelStateToActivate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAlertsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.UpdateResourceGroupLevelStateToActivate(ctx, "myRg2", "westeurope", "2518765996949954086_2325cf9e-42a2-4f72-ae7f-9b863cba2d22", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2022-01-01/examples/Alerts/UpdateAlertResourceGroupLocation_inProgress_example.json -func ExampleAlertsClient_UpdateResourceGroupLevelStateToInProgress() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAlertsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.UpdateResourceGroupLevelStateToInProgress(ctx, "myRg2", "westeurope", "2518765996949954086_2325cf9e-42a2-4f72-ae7f-9b863cba2d22", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2022-01-01/examples/Alerts/SimulateAlerts_example.json -func ExampleAlertsClient_BeginSimulate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAlertsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginSimulate(ctx, "centralus", armsecurity.AlertSimulatorRequestBody{ - Properties: &armsecurity.AlertSimulatorBundlesRequestProperties{ - Kind: to.Ptr(armsecurity.KindBundles), - Bundles: []*armsecurity.BundleType{ - to.Ptr(armsecurity.BundleTypeAppServices), - to.Ptr(armsecurity.BundleTypeDNS), - to.Ptr(armsecurity.BundleTypeKeyVaults), - to.Ptr(armsecurity.BundleTypeKubernetesService), - to.Ptr(armsecurity.BundleTypeResourceManager), - to.Ptr(armsecurity.BundleTypeSQLServers), - to.Ptr(armsecurity.BundleTypeStorageAccounts), - to.Ptr(armsecurity.BundleTypeVirtualMachines), - to.Ptr(armsecurity.BundleTypeCosmosDbs)}, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} diff --git a/sdk/resourcemanager/security/armsecurity/alertssuppressionrules_client.go b/sdk/resourcemanager/security/armsecurity/alertssuppressionrules_client.go index 0752c68e821d..f30e6761ac9a 100644 --- a/sdk/resourcemanager/security/armsecurity/alertssuppressionrules_client.go +++ b/sdk/resourcemanager/security/armsecurity/alertssuppressionrules_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,47 +24,39 @@ import ( // AlertsSuppressionRulesClient contains the methods for the AlertsSuppressionRules group. // Don't use this type directly, use NewAlertsSuppressionRulesClient() instead. type AlertsSuppressionRulesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewAlertsSuppressionRulesClient creates a new instance of AlertsSuppressionRulesClient with the specified values. -// subscriptionID - Azure subscription ID -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure subscription ID +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewAlertsSuppressionRulesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AlertsSuppressionRulesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".AlertsSuppressionRulesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &AlertsSuppressionRulesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Delete - Delete dismiss alert rule for this subscription. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-01-01-preview -// alertsSuppressionRuleName - The unique name of the suppression alert rule -// options - AlertsSuppressionRulesClientDeleteOptions contains the optional parameters for the AlertsSuppressionRulesClient.Delete -// method. +// - alertsSuppressionRuleName - The unique name of the suppression alert rule +// - options - AlertsSuppressionRulesClientDeleteOptions contains the optional parameters for the AlertsSuppressionRulesClient.Delete +// method. func (client *AlertsSuppressionRulesClient) Delete(ctx context.Context, alertsSuppressionRuleName string, options *AlertsSuppressionRulesClientDeleteOptions) (AlertsSuppressionRulesClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, alertsSuppressionRuleName, options) if err != nil { return AlertsSuppressionRulesClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AlertsSuppressionRulesClientDeleteResponse{}, err } @@ -87,7 +77,7 @@ func (client *AlertsSuppressionRulesClient) deleteCreateRequest(ctx context.Cont return nil, errors.New("parameter alertsSuppressionRuleName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{alertsSuppressionRuleName}", url.PathEscape(alertsSuppressionRuleName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -100,16 +90,17 @@ func (client *AlertsSuppressionRulesClient) deleteCreateRequest(ctx context.Cont // Get - Get dismiss rule, with name: {alertsSuppressionRuleName}, for the given subscription // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-01-01-preview -// alertsSuppressionRuleName - The unique name of the suppression alert rule -// options - AlertsSuppressionRulesClientGetOptions contains the optional parameters for the AlertsSuppressionRulesClient.Get -// method. +// - alertsSuppressionRuleName - The unique name of the suppression alert rule +// - options - AlertsSuppressionRulesClientGetOptions contains the optional parameters for the AlertsSuppressionRulesClient.Get +// method. func (client *AlertsSuppressionRulesClient) Get(ctx context.Context, alertsSuppressionRuleName string, options *AlertsSuppressionRulesClientGetOptions) (AlertsSuppressionRulesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, alertsSuppressionRuleName, options) if err != nil { return AlertsSuppressionRulesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AlertsSuppressionRulesClientGetResponse{}, err } @@ -130,7 +121,7 @@ func (client *AlertsSuppressionRulesClient) getCreateRequest(ctx context.Context return nil, errors.New("parameter alertsSuppressionRuleName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{alertsSuppressionRuleName}", url.PathEscape(alertsSuppressionRuleName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -151,9 +142,10 @@ func (client *AlertsSuppressionRulesClient) getHandleResponse(resp *http.Respons } // NewListPager - List of all the dismiss rules for the given subscription +// // Generated from API version 2019-01-01-preview -// options - AlertsSuppressionRulesClientListOptions contains the optional parameters for the AlertsSuppressionRulesClient.List -// method. +// - options - AlertsSuppressionRulesClientListOptions contains the optional parameters for the AlertsSuppressionRulesClient.NewListPager +// method. func (client *AlertsSuppressionRulesClient) NewListPager(options *AlertsSuppressionRulesClientListOptions) *runtime.Pager[AlertsSuppressionRulesClientListResponse] { return runtime.NewPager(runtime.PagingHandler[AlertsSuppressionRulesClientListResponse]{ More: func(page AlertsSuppressionRulesClientListResponse) bool { @@ -170,7 +162,7 @@ func (client *AlertsSuppressionRulesClient) NewListPager(options *AlertsSuppress if err != nil { return AlertsSuppressionRulesClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AlertsSuppressionRulesClientListResponse{}, err } @@ -189,7 +181,7 @@ func (client *AlertsSuppressionRulesClient) listCreateRequest(ctx context.Contex return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -214,17 +206,18 @@ func (client *AlertsSuppressionRulesClient) listHandleResponse(resp *http.Respon // Update - Update existing rule or create new rule if it doesn't exist // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-01-01-preview -// alertsSuppressionRuleName - The unique name of the suppression alert rule -// alertsSuppressionRule - Suppression rule object -// options - AlertsSuppressionRulesClientUpdateOptions contains the optional parameters for the AlertsSuppressionRulesClient.Update -// method. +// - alertsSuppressionRuleName - The unique name of the suppression alert rule +// - alertsSuppressionRule - Suppression rule object +// - options - AlertsSuppressionRulesClientUpdateOptions contains the optional parameters for the AlertsSuppressionRulesClient.Update +// method. func (client *AlertsSuppressionRulesClient) Update(ctx context.Context, alertsSuppressionRuleName string, alertsSuppressionRule AlertsSuppressionRule, options *AlertsSuppressionRulesClientUpdateOptions) (AlertsSuppressionRulesClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, alertsSuppressionRuleName, alertsSuppressionRule, options) if err != nil { return AlertsSuppressionRulesClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AlertsSuppressionRulesClientUpdateResponse{}, err } @@ -245,7 +238,7 @@ func (client *AlertsSuppressionRulesClient) updateCreateRequest(ctx context.Cont return nil, errors.New("parameter alertsSuppressionRuleName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{alertsSuppressionRuleName}", url.PathEscape(alertsSuppressionRuleName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/security/armsecurity/alertssuppressionrules_client_example_test.go b/sdk/resourcemanager/security/armsecurity/alertssuppressionrules_client_example_test.go deleted file mode 100644 index 54fa9616bbfc..000000000000 --- a/sdk/resourcemanager/security/armsecurity/alertssuppressionrules_client_example_test.go +++ /dev/null @@ -1,149 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. - -package armsecurity_test - -import ( - "context" - "log" - - "time" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/AlertsSuppressionRules/GetAlertsSuppressionRulesWithAlertType_example.json -func ExampleAlertsSuppressionRulesClient_NewListPager_getSuppressionAlertRuleForSubscriptionFilteredByAlertType() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAlertsSuppressionRulesClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(&armsecurity.AlertsSuppressionRulesClientListOptions{AlertType: nil}) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/AlertsSuppressionRules/GetAlertsSuppressionRules_example.json -func ExampleAlertsSuppressionRulesClient_NewListPager_getSuppressionRulesForSubscription() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAlertsSuppressionRulesClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(&armsecurity.AlertsSuppressionRulesClientListOptions{AlertType: nil}) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/AlertsSuppressionRules/GetAlertsSuppressionRule_example.json -func ExampleAlertsSuppressionRulesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAlertsSuppressionRulesClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "dismissIpAnomalyAlerts", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/AlertsSuppressionRules/PutAlertsSuppressionRule_example.json -func ExampleAlertsSuppressionRulesClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAlertsSuppressionRulesClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Update(ctx, "dismissIpAnomalyAlerts", armsecurity.AlertsSuppressionRule{ - Properties: &armsecurity.AlertsSuppressionRuleProperties{ - AlertType: to.Ptr("IpAnomaly"), - Comment: to.Ptr("Test VM"), - ExpirationDateUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-12-01T19:50:47.083633Z"); return t }()), - Reason: to.Ptr("FalsePositive"), - State: to.Ptr(armsecurity.RuleStateEnabled), - SuppressionAlertsScope: &armsecurity.SuppressionAlertsScope{ - AllOf: []*armsecurity.ScopeElement{ - { - AdditionalProperties: map[string]interface{}{ - "in": []interface{}{ - "104.215.95.187", - "52.164.206.56", - }, - }, - Field: to.Ptr("entities.ip.address"), - }, - { - AdditionalProperties: map[string]interface{}{ - "contains": "POWERSHELL.EXE", - }, - Field: to.Ptr("entities.process.commandline"), - }}, - }, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/AlertsSuppressionRules/DeleteAlertsSuppressionRule_example.json -func ExampleAlertsSuppressionRulesClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAlertsSuppressionRulesClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, "dismissIpAnomalyAlerts", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/security/armsecurity/allowedconnections_client.go b/sdk/resourcemanager/security/armsecurity/allowedconnections_client.go index 3d1d2ed42cde..14c83d479266 100644 --- a/sdk/resourcemanager/security/armsecurity/allowedconnections_client.go +++ b/sdk/resourcemanager/security/armsecurity/allowedconnections_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,48 +24,40 @@ import ( // AllowedConnectionsClient contains the methods for the AllowedConnections group. // Don't use this type directly, use NewAllowedConnectionsClient() instead. type AllowedConnectionsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewAllowedConnectionsClient creates a new instance of AllowedConnectionsClient with the specified values. -// subscriptionID - Azure subscription ID -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure subscription ID +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewAllowedConnectionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AllowedConnectionsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".AllowedConnectionsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &AllowedConnectionsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Gets the list of all possible traffic between resources for the subscription and location, based on connection type. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-01-01 -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations -// connectionType - The type of allowed connections (Internal, External) -// options - AllowedConnectionsClientGetOptions contains the optional parameters for the AllowedConnectionsClient.Get method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations +// - connectionType - The type of allowed connections (Internal, External) +// - options - AllowedConnectionsClientGetOptions contains the optional parameters for the AllowedConnectionsClient.Get method. func (client *AllowedConnectionsClient) Get(ctx context.Context, resourceGroupName string, ascLocation string, connectionType ConnectionType, options *AllowedConnectionsClientGetOptions) (AllowedConnectionsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, ascLocation, connectionType, options) if err != nil { return AllowedConnectionsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AllowedConnectionsClientGetResponse{}, err } @@ -96,7 +86,7 @@ func (client *AllowedConnectionsClient) getCreateRequest(ctx context.Context, re return nil, errors.New("parameter connectionType cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{connectionType}", url.PathEscape(string(connectionType))) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -117,8 +107,10 @@ func (client *AllowedConnectionsClient) getHandleResponse(resp *http.Response) ( } // NewListPager - Gets the list of all possible traffic between resources for the subscription +// // Generated from API version 2020-01-01 -// options - AllowedConnectionsClientListOptions contains the optional parameters for the AllowedConnectionsClient.List method. +// - options - AllowedConnectionsClientListOptions contains the optional parameters for the AllowedConnectionsClient.NewListPager +// method. func (client *AllowedConnectionsClient) NewListPager(options *AllowedConnectionsClientListOptions) *runtime.Pager[AllowedConnectionsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[AllowedConnectionsClientListResponse]{ More: func(page AllowedConnectionsClientListResponse) bool { @@ -135,7 +127,7 @@ func (client *AllowedConnectionsClient) NewListPager(options *AllowedConnections if err != nil { return AllowedConnectionsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AllowedConnectionsClientListResponse{}, err } @@ -154,7 +146,7 @@ func (client *AllowedConnectionsClient) listCreateRequest(ctx context.Context, o return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -175,10 +167,11 @@ func (client *AllowedConnectionsClient) listHandleResponse(resp *http.Response) } // NewListByHomeRegionPager - Gets the list of all possible traffic between resources for the subscription and location. +// // Generated from API version 2020-01-01 -// ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations -// options - AllowedConnectionsClientListByHomeRegionOptions contains the optional parameters for the AllowedConnectionsClient.ListByHomeRegion -// method. +// - ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations +// - options - AllowedConnectionsClientListByHomeRegionOptions contains the optional parameters for the AllowedConnectionsClient.NewListByHomeRegionPager +// method. func (client *AllowedConnectionsClient) NewListByHomeRegionPager(ascLocation string, options *AllowedConnectionsClientListByHomeRegionOptions) *runtime.Pager[AllowedConnectionsClientListByHomeRegionResponse] { return runtime.NewPager(runtime.PagingHandler[AllowedConnectionsClientListByHomeRegionResponse]{ More: func(page AllowedConnectionsClientListByHomeRegionResponse) bool { @@ -195,7 +188,7 @@ func (client *AllowedConnectionsClient) NewListByHomeRegionPager(ascLocation str if err != nil { return AllowedConnectionsClientListByHomeRegionResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AllowedConnectionsClientListByHomeRegionResponse{}, err } @@ -218,7 +211,7 @@ func (client *AllowedConnectionsClient) listByHomeRegionCreateRequest(ctx contex return nil, errors.New("parameter ascLocation cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{ascLocation}", url.PathEscape(ascLocation)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/security/armsecurity/allowedconnections_client_example_test.go b/sdk/resourcemanager/security/armsecurity/allowedconnections_client_example_test.go deleted file mode 100644 index 00a316323c4a..000000000000 --- a/sdk/resourcemanager/security/armsecurity/allowedconnections_client_example_test.go +++ /dev/null @@ -1,84 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. - -package armsecurity_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/AllowedConnections/GetAllowedConnectionsSubscription_example.json -func ExampleAllowedConnectionsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAllowedConnectionsClient("3eeab341-f466-499c-a8be-85427e154bad", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/AllowedConnections/GetAllowedConnectionsSubscriptionLocation_example.json -func ExampleAllowedConnectionsClient_NewListByHomeRegionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAllowedConnectionsClient("3eeab341-f466-499c-a8be-85427e154bad", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByHomeRegionPager("centralus", nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/AllowedConnections/GetAllowedConnections_example.json -func ExampleAllowedConnectionsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAllowedConnectionsClient("3eeab341-f466-499c-a8be-85427e154bad", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "myResourceGroup", "centralus", armsecurity.ConnectionTypeInternal, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/security/armsecurity/apicollection_client.go b/sdk/resourcemanager/security/armsecurity/apicollection_client.go new file mode 100644 index 000000000000..95bd4364e6c6 --- /dev/null +++ b/sdk/resourcemanager/security/armsecurity/apicollection_client.go @@ -0,0 +1,181 @@ +//go:build go1.18 +// +build go1.18 + +// 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. +// DO NOT EDIT. + +package armsecurity + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// APICollectionClient contains the methods for the APICollection group. +// Don't use this type directly, use NewAPICollectionClient() instead. +type APICollectionClient struct { + internal *arm.Client + subscriptionID string +} + +// NewAPICollectionClient creates a new instance of APICollectionClient with the specified values. +// - subscriptionID - Azure subscription ID +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewAPICollectionClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*APICollectionClient, error) { + cl, err := arm.NewClient(moduleName+".APICollectionClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &APICollectionClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// Get - Gets an Azure API Management API if it has been onboarded to Defender for APIs. If an Azure API Management API is +// onboarded to Defender for APIs, the system will monitor the operations within the +// Azure API Management API for intrusive behaviors and provide alerts for attacks that have been detected. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-11-20-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - apiCollectionID - A string representing the apiCollections resource within the Microsoft.Security provider namespace. This +// string matches the Azure API Management API name. +// - options - APICollectionClientGetOptions contains the optional parameters for the APICollectionClient.Get method. +func (client *APICollectionClient) Get(ctx context.Context, resourceGroupName string, serviceName string, apiCollectionID string, options *APICollectionClientGetOptions) (APICollectionClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, apiCollectionID, options) + if err != nil { + return APICollectionClientGetResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return APICollectionClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return APICollectionClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *APICollectionClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiCollectionID string, options *APICollectionClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/providers/Microsoft.Security/apiCollections/{apiCollectionId}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiCollectionID == "" { + return nil, errors.New("parameter apiCollectionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiCollectionId}", url.PathEscape(apiCollectionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-11-20-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *APICollectionClient) getHandleResponse(resp *http.Response) (APICollectionClientGetResponse, error) { + result := APICollectionClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.APICollectionResponse); err != nil { + return APICollectionClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - Gets a list of Azure API Management APIs that have been onboarded to Defender for APIs. If an Azure API +// Management API is onboarded to Defender for APIs, the system will monitor the operations within +// the Azure API Management API for intrusive behaviors and provide alerts for attacks that have been detected. +// +// Generated from API version 2022-11-20-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - options - APICollectionClientListOptions contains the optional parameters for the APICollectionClient.NewListPager method. +func (client *APICollectionClient) NewListPager(resourceGroupName string, serviceName string, options *APICollectionClientListOptions) *runtime.Pager[APICollectionClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[APICollectionClientListResponse]{ + More: func(page APICollectionClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *APICollectionClientListResponse) (APICollectionClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, resourceGroupName, serviceName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return APICollectionClientListResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return APICollectionClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return APICollectionClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *APICollectionClient) listCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *APICollectionClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/providers/Microsoft.Security/apiCollections" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-11-20-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *APICollectionClient) listHandleResponse(resp *http.Response) (APICollectionClientListResponse, error) { + result := APICollectionClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.APICollectionResponseList); err != nil { + return APICollectionClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/security/armsecurity/apicollectionoffboarding_client.go b/sdk/resourcemanager/security/armsecurity/apicollectionoffboarding_client.go new file mode 100644 index 000000000000..64a48581312b --- /dev/null +++ b/sdk/resourcemanager/security/armsecurity/apicollectionoffboarding_client.go @@ -0,0 +1,101 @@ +//go:build go1.18 +// +build go1.18 + +// 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. +// DO NOT EDIT. + +package armsecurity + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// APICollectionOffboardingClient contains the methods for the APICollectionOffboarding group. +// Don't use this type directly, use NewAPICollectionOffboardingClient() instead. +type APICollectionOffboardingClient struct { + internal *arm.Client + subscriptionID string +} + +// NewAPICollectionOffboardingClient creates a new instance of APICollectionOffboardingClient with the specified values. +// - subscriptionID - Azure subscription ID +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewAPICollectionOffboardingClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*APICollectionOffboardingClient, error) { + cl, err := arm.NewClient(moduleName+".APICollectionOffboardingClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &APICollectionOffboardingClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// Delete - Offboard an Azure API Management API from Defender for APIs. The system will stop monitoring the operations within +// the Azure API Management API for intrusive behaviors. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-11-20-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - apiCollectionID - A string representing the apiCollections resource within the Microsoft.Security provider namespace. This +// string matches the Azure API Management API name. +// - options - APICollectionOffboardingClientDeleteOptions contains the optional parameters for the APICollectionOffboardingClient.Delete +// method. +func (client *APICollectionOffboardingClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, apiCollectionID string, options *APICollectionOffboardingClientDeleteOptions) (APICollectionOffboardingClientDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, apiCollectionID, options) + if err != nil { + return APICollectionOffboardingClientDeleteResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return APICollectionOffboardingClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { + return APICollectionOffboardingClientDeleteResponse{}, runtime.NewResponseError(resp) + } + return APICollectionOffboardingClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *APICollectionOffboardingClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiCollectionID string, options *APICollectionOffboardingClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/providers/Microsoft.Security/apiCollections/{apiCollectionId}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiCollectionID == "" { + return nil, errors.New("parameter apiCollectionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiCollectionId}", url.PathEscape(apiCollectionID)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-11-20-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} diff --git a/sdk/resourcemanager/security/armsecurity/apicollectiononboarding_client.go b/sdk/resourcemanager/security/armsecurity/apicollectiononboarding_client.go new file mode 100644 index 000000000000..8e8a521dc71c --- /dev/null +++ b/sdk/resourcemanager/security/armsecurity/apicollectiononboarding_client.go @@ -0,0 +1,111 @@ +//go:build go1.18 +// +build go1.18 + +// 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. +// DO NOT EDIT. + +package armsecurity + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// APICollectionOnboardingClient contains the methods for the APICollectionOnboarding group. +// Don't use this type directly, use NewAPICollectionOnboardingClient() instead. +type APICollectionOnboardingClient struct { + internal *arm.Client + subscriptionID string +} + +// NewAPICollectionOnboardingClient creates a new instance of APICollectionOnboardingClient with the specified values. +// - subscriptionID - Azure subscription ID +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewAPICollectionOnboardingClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*APICollectionOnboardingClient, error) { + cl, err := arm.NewClient(moduleName+".APICollectionOnboardingClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &APICollectionOnboardingClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// Create - Onboard an Azure API Management API to Defender for APIs. The system will start monitoring the operations within +// the Azure Management API for intrusive behaviors and provide alerts for attacks that +// have been detected. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-11-20-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - apiCollectionID - A string representing the apiCollections resource within the Microsoft.Security provider namespace. This +// string matches the Azure API Management API name. +// - options - APICollectionOnboardingClientCreateOptions contains the optional parameters for the APICollectionOnboardingClient.Create +// method. +func (client *APICollectionOnboardingClient) Create(ctx context.Context, resourceGroupName string, serviceName string, apiCollectionID string, options *APICollectionOnboardingClientCreateOptions) (APICollectionOnboardingClientCreateResponse, error) { + req, err := client.createCreateRequest(ctx, resourceGroupName, serviceName, apiCollectionID, options) + if err != nil { + return APICollectionOnboardingClientCreateResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return APICollectionOnboardingClientCreateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return APICollectionOnboardingClientCreateResponse{}, runtime.NewResponseError(resp) + } + return client.createHandleResponse(resp) +} + +// createCreateRequest creates the Create request. +func (client *APICollectionOnboardingClient) createCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiCollectionID string, options *APICollectionOnboardingClientCreateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/providers/Microsoft.Security/apiCollections/{apiCollectionId}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiCollectionID == "" { + return nil, errors.New("parameter apiCollectionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiCollectionId}", url.PathEscape(apiCollectionID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-11-20-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// createHandleResponse handles the Create response. +func (client *APICollectionOnboardingClient) createHandleResponse(resp *http.Response) (APICollectionOnboardingClientCreateResponse, error) { + result := APICollectionOnboardingClientCreateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.APICollectionResponse); err != nil { + return APICollectionOnboardingClientCreateResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/security/armsecurity/application_client.go b/sdk/resourcemanager/security/armsecurity/application_client.go index 796f510b90ca..d5a1438723e0 100644 --- a/sdk/resourcemanager/security/armsecurity/application_client.go +++ b/sdk/resourcemanager/security/armsecurity/application_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,48 +24,40 @@ import ( // ApplicationClient contains the methods for the Application group. // Don't use this type directly, use NewApplicationClient() instead. type ApplicationClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewApplicationClient creates a new instance of ApplicationClient with the specified values. -// subscriptionID - Azure subscription ID -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure subscription ID +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewApplicationClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ApplicationClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".ApplicationClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ApplicationClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // CreateOrUpdate - Creates or update a security application on the given subscription. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01-preview -// applicationID - The security Application key - unique key for the standard application -// application - Application over a subscription scope -// options - ApplicationClientCreateOrUpdateOptions contains the optional parameters for the ApplicationClient.CreateOrUpdate -// method. +// - applicationID - The security Application key - unique key for the standard application +// - application - Application over a subscription scope +// - options - ApplicationClientCreateOrUpdateOptions contains the optional parameters for the ApplicationClient.CreateOrUpdate +// method. func (client *ApplicationClient) CreateOrUpdate(ctx context.Context, applicationID string, application Application, options *ApplicationClientCreateOrUpdateOptions) (ApplicationClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, applicationID, application, options) if err != nil { return ApplicationClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ApplicationClientCreateOrUpdateResponse{}, err } @@ -88,7 +78,7 @@ func (client *ApplicationClient) createOrUpdateCreateRequest(ctx context.Context return nil, errors.New("parameter applicationID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{applicationId}", url.PathEscape(applicationID)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -110,15 +100,16 @@ func (client *ApplicationClient) createOrUpdateHandleResponse(resp *http.Respons // Delete - Delete an Application over a given scope // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01-preview -// applicationID - The security Application key - unique key for the standard application -// options - ApplicationClientDeleteOptions contains the optional parameters for the ApplicationClient.Delete method. +// - applicationID - The security Application key - unique key for the standard application +// - options - ApplicationClientDeleteOptions contains the optional parameters for the ApplicationClient.Delete method. func (client *ApplicationClient) Delete(ctx context.Context, applicationID string, options *ApplicationClientDeleteOptions) (ApplicationClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, applicationID, options) if err != nil { return ApplicationClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ApplicationClientDeleteResponse{}, err } @@ -139,7 +130,7 @@ func (client *ApplicationClient) deleteCreateRequest(ctx context.Context, applic return nil, errors.New("parameter applicationID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{applicationId}", url.PathEscape(applicationID)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -151,15 +142,16 @@ func (client *ApplicationClient) deleteCreateRequest(ctx context.Context, applic // Get - Get a specific application for the requested scope by applicationId // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01-preview -// applicationID - The security Application key - unique key for the standard application -// options - ApplicationClientGetOptions contains the optional parameters for the ApplicationClient.Get method. +// - applicationID - The security Application key - unique key for the standard application +// - options - ApplicationClientGetOptions contains the optional parameters for the ApplicationClient.Get method. func (client *ApplicationClient) Get(ctx context.Context, applicationID string, options *ApplicationClientGetOptions) (ApplicationClientGetResponse, error) { req, err := client.getCreateRequest(ctx, applicationID, options) if err != nil { return ApplicationClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ApplicationClientGetResponse{}, err } @@ -180,7 +172,7 @@ func (client *ApplicationClient) getCreateRequest(ctx context.Context, applicati return nil, errors.New("parameter applicationID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{applicationId}", url.PathEscape(applicationID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/security/armsecurity/application_client_example_test.go b/sdk/resourcemanager/security/armsecurity/application_client_example_test.go deleted file mode 100644 index 0b14d808a1a2..000000000000 --- a/sdk/resourcemanager/security/armsecurity/application_client_example_test.go +++ /dev/null @@ -1,89 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. - -package armsecurity_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2022-07-01-preview/examples/Applications/GetApplication_example.json -func ExampleApplicationClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewApplicationClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "ad9a8e26-29d9-4829-bb30-e597a58cdbb8", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2022-07-01-preview/examples/Applications/PutApplication_example.json -func ExampleApplicationClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewApplicationClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdate(ctx, "ad9a8e26-29d9-4829-bb30-e597a58cdbb8", armsecurity.Application{ - Properties: &armsecurity.ApplicationProperties{ - Description: to.Ptr("An application on critical recommendations"), - ConditionSets: []interface{}{ - map[string]interface{}{ - "conditions": []interface{}{ - map[string]interface{}{ - "operator": "contains", - "property": "$.Id", - "value": "-bil-", - }, - }, - }}, - DisplayName: to.Ptr("Admin's application"), - SourceResourceType: to.Ptr(armsecurity.ApplicationSourceResourceTypeAssessments), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2022-07-01-preview/examples/Applications/DeleteApplication_example.json -func ExampleApplicationClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewApplicationClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, "ad9a8e26-29d9-4829-bb30-e597a58cdbb8", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/security/armsecurity/applications_client.go b/sdk/resourcemanager/security/armsecurity/applications_client.go index 656a08325ebb..cf4eda222bec 100644 --- a/sdk/resourcemanager/security/armsecurity/applications_client.go +++ b/sdk/resourcemanager/security/armsecurity/applications_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,38 +24,30 @@ import ( // ApplicationsClient contains the methods for the Applications group. // Don't use this type directly, use NewApplicationsClient() instead. type ApplicationsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewApplicationsClient creates a new instance of ApplicationsClient with the specified values. -// subscriptionID - Azure subscription ID -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure subscription ID +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewApplicationsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ApplicationsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".ApplicationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ApplicationsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListPager - Get a list of all relevant applications over a subscription level scope +// // Generated from API version 2022-07-01-preview -// options - ApplicationsClientListOptions contains the optional parameters for the ApplicationsClient.List method. +// - options - ApplicationsClientListOptions contains the optional parameters for the ApplicationsClient.NewListPager method. func (client *ApplicationsClient) NewListPager(options *ApplicationsClientListOptions) *runtime.Pager[ApplicationsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[ApplicationsClientListResponse]{ More: func(page ApplicationsClientListResponse) bool { @@ -74,7 +64,7 @@ func (client *ApplicationsClient) NewListPager(options *ApplicationsClientListOp if err != nil { return ApplicationsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ApplicationsClientListResponse{}, err } @@ -93,7 +83,7 @@ func (client *ApplicationsClient) listCreateRequest(ctx context.Context, options return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/security/armsecurity/applications_client_example_test.go b/sdk/resourcemanager/security/armsecurity/applications_client_example_test.go deleted file mode 100644 index d652401fa85e..000000000000 --- a/sdk/resourcemanager/security/armsecurity/applications_client_example_test.go +++ /dev/null @@ -1,41 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. - -package armsecurity_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2022-07-01-preview/examples/Applications/ListBySubscriptionApplications_example.json -func ExampleApplicationsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewApplicationsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/security/armsecurity/assessments_client.go b/sdk/resourcemanager/security/armsecurity/assessments_client.go index 76a2f6f3ccc7..ea74c069e49b 100644 --- a/sdk/resourcemanager/security/armsecurity/assessments_client.go +++ b/sdk/resourcemanager/security/armsecurity/assessments_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,28 +24,19 @@ import ( // AssessmentsClient contains the methods for the Assessments group. // Don't use this type directly, use NewAssessmentsClient() instead. type AssessmentsClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewAssessmentsClient creates a new instance of AssessmentsClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewAssessmentsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*AssessmentsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".AssessmentsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &AssessmentsClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -55,18 +44,19 @@ func NewAssessmentsClient(credential azcore.TokenCredential, options *arm.Client // CreateOrUpdate - Create a security assessment on your resource. An assessment metadata that describes this assessment must // be predefined with the same name before inserting the assessment result // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-06-01 -// resourceID - The identifier of the resource. -// assessmentName - The Assessment Key - Unique key for the assessment type -// assessment - Calculated assessment on a pre-defined assessment metadata -// options - AssessmentsClientCreateOrUpdateOptions contains the optional parameters for the AssessmentsClient.CreateOrUpdate -// method. +// - resourceID - The identifier of the resource. +// - assessmentName - The Assessment Key - Unique key for the assessment type +// - assessment - Calculated assessment on a pre-defined assessment metadata +// - options - AssessmentsClientCreateOrUpdateOptions contains the optional parameters for the AssessmentsClient.CreateOrUpdate +// method. func (client *AssessmentsClient) CreateOrUpdate(ctx context.Context, resourceID string, assessmentName string, assessment Assessment, options *AssessmentsClientCreateOrUpdateOptions) (AssessmentsClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceID, assessmentName, assessment, options) if err != nil { return AssessmentsClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AssessmentsClientCreateOrUpdateResponse{}, err } @@ -84,7 +74,7 @@ func (client *AssessmentsClient) createOrUpdateCreateRequest(ctx context.Context return nil, errors.New("parameter assessmentName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{assessmentName}", url.PathEscape(assessmentName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -107,16 +97,17 @@ func (client *AssessmentsClient) createOrUpdateHandleResponse(resp *http.Respons // Delete - Delete a security assessment on your resource. An assessment metadata that describes this assessment must be predefined // with the same name before inserting the assessment result // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-06-01 -// resourceID - The identifier of the resource. -// assessmentName - The Assessment Key - Unique key for the assessment type -// options - AssessmentsClientDeleteOptions contains the optional parameters for the AssessmentsClient.Delete method. +// - resourceID - The identifier of the resource. +// - assessmentName - The Assessment Key - Unique key for the assessment type +// - options - AssessmentsClientDeleteOptions contains the optional parameters for the AssessmentsClient.Delete method. func (client *AssessmentsClient) Delete(ctx context.Context, resourceID string, assessmentName string, options *AssessmentsClientDeleteOptions) (AssessmentsClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceID, assessmentName, options) if err != nil { return AssessmentsClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AssessmentsClientDeleteResponse{}, err } @@ -134,7 +125,7 @@ func (client *AssessmentsClient) deleteCreateRequest(ctx context.Context, resour return nil, errors.New("parameter assessmentName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{assessmentName}", url.PathEscape(assessmentName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -147,16 +138,17 @@ func (client *AssessmentsClient) deleteCreateRequest(ctx context.Context, resour // Get - Get a security assessment on your scanned resource // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-06-01 -// resourceID - The identifier of the resource. -// assessmentName - The Assessment Key - Unique key for the assessment type -// options - AssessmentsClientGetOptions contains the optional parameters for the AssessmentsClient.Get method. +// - resourceID - The identifier of the resource. +// - assessmentName - The Assessment Key - Unique key for the assessment type +// - options - AssessmentsClientGetOptions contains the optional parameters for the AssessmentsClient.Get method. func (client *AssessmentsClient) Get(ctx context.Context, resourceID string, assessmentName string, options *AssessmentsClientGetOptions) (AssessmentsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceID, assessmentName, options) if err != nil { return AssessmentsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AssessmentsClientGetResponse{}, err } @@ -174,7 +166,7 @@ func (client *AssessmentsClient) getCreateRequest(ctx context.Context, resourceI return nil, errors.New("parameter assessmentName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{assessmentName}", url.PathEscape(assessmentName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -198,10 +190,11 @@ func (client *AssessmentsClient) getHandleResponse(resp *http.Response) (Assessm } // NewListPager - Get security assessments on all your scanned resources inside a scope +// // Generated from API version 2021-06-01 -// scope - Scope of the query, can be subscription (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group -// (/providers/Microsoft.Management/managementGroups/mgName). -// options - AssessmentsClientListOptions contains the optional parameters for the AssessmentsClient.List method. +// - scope - Scope of the query, can be subscription (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group +// (/providers/Microsoft.Management/managementGroups/mgName). +// - options - AssessmentsClientListOptions contains the optional parameters for the AssessmentsClient.NewListPager method. func (client *AssessmentsClient) NewListPager(scope string, options *AssessmentsClientListOptions) *runtime.Pager[AssessmentsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[AssessmentsClientListResponse]{ More: func(page AssessmentsClientListResponse) bool { @@ -218,7 +211,7 @@ func (client *AssessmentsClient) NewListPager(scope string, options *Assessments if err != nil { return AssessmentsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AssessmentsClientListResponse{}, err } @@ -234,7 +227,7 @@ func (client *AssessmentsClient) NewListPager(scope string, options *Assessments func (client *AssessmentsClient) listCreateRequest(ctx context.Context, scope string, options *AssessmentsClientListOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.Security/assessments" urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/security/armsecurity/assessments_client_example_test.go b/sdk/resourcemanager/security/armsecurity/assessments_client_example_test.go deleted file mode 100644 index f9f558d04999..000000000000 --- a/sdk/resourcemanager/security/armsecurity/assessments_client_example_test.go +++ /dev/null @@ -1,125 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. - -package armsecurity_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2021-06-01/examples/Assessments/ListAssessments_example.json -func ExampleAssessmentsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAssessmentsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23", nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2021-06-01/examples/Assessments/GetAssessment_example.json -func ExampleAssessmentsClient_Get_getSecurityRecommendationTaskFromSecurityDataLocation() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAssessmentsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/myRg/providers/Microsoft.Compute/virtualMachineScaleSets/vmss2", "21300918-b2e3-0346-785f-c77ff57d243b", &armsecurity.AssessmentsClientGetOptions{Expand: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2021-06-01/examples/Assessments/GetAssessmentWithExpand_example.json -func ExampleAssessmentsClient_Get_getSecurityRecommendationTaskFromSecurityDataLocationWithExpandParameter() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAssessmentsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/myRg/providers/Microsoft.Compute/virtualMachineScaleSets/vmss2", "21300918-b2e3-0346-785f-c77ff57d243b", &armsecurity.AssessmentsClientGetOptions{Expand: to.Ptr(armsecurity.ExpandEnumLinks)}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2021-06-01/examples/Assessments/PutAssessment_example.json -func ExampleAssessmentsClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAssessmentsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdate(ctx, "subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/myRg/providers/Microsoft.Compute/virtualMachineScaleSets/vmss2", "8bb8be0a-6010-4789-812f-e4d661c4ed0e", armsecurity.Assessment{ - Properties: &armsecurity.AssessmentProperties{ - ResourceDetails: &armsecurity.AzureResourceDetails{ - Source: to.Ptr(armsecurity.SourceAzure), - }, - Status: &armsecurity.AssessmentStatus{ - Code: to.Ptr(armsecurity.AssessmentStatusCodeHealthy), - }, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2021-06-01/examples/Assessments/DeleteAssessment_example.json -func ExampleAssessmentsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAssessmentsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, "subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/myRg/providers/Microsoft.Compute/virtualMachineScaleSets/vmss2", "8bb8be0a-6010-4789-812f-e4d661c4ed0e", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/security/armsecurity/assessmentsmetadata_client.go b/sdk/resourcemanager/security/armsecurity/assessmentsmetadata_client.go index 20db186eeaf3..455640b4311f 100644 --- a/sdk/resourcemanager/security/armsecurity/assessmentsmetadata_client.go +++ b/sdk/resourcemanager/security/armsecurity/assessmentsmetadata_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,48 +24,40 @@ import ( // AssessmentsMetadataClient contains the methods for the AssessmentsMetadata group. // Don't use this type directly, use NewAssessmentsMetadataClient() instead. type AssessmentsMetadataClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewAssessmentsMetadataClient creates a new instance of AssessmentsMetadataClient with the specified values. -// subscriptionID - Azure subscription ID -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure subscription ID +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewAssessmentsMetadataClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AssessmentsMetadataClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".AssessmentsMetadataClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &AssessmentsMetadataClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // CreateInSubscription - Create metadata information on an assessment type in a specific subscription // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-06-01 -// assessmentMetadataName - The Assessment Key - Unique key for the assessment type -// assessmentMetadata - AssessmentMetadata object -// options - AssessmentsMetadataClientCreateInSubscriptionOptions contains the optional parameters for the AssessmentsMetadataClient.CreateInSubscription -// method. +// - assessmentMetadataName - The Assessment Key - Unique key for the assessment type +// - assessmentMetadata - AssessmentMetadata object +// - options - AssessmentsMetadataClientCreateInSubscriptionOptions contains the optional parameters for the AssessmentsMetadataClient.CreateInSubscription +// method. func (client *AssessmentsMetadataClient) CreateInSubscription(ctx context.Context, assessmentMetadataName string, assessmentMetadata AssessmentMetadataResponse, options *AssessmentsMetadataClientCreateInSubscriptionOptions) (AssessmentsMetadataClientCreateInSubscriptionResponse, error) { req, err := client.createInSubscriptionCreateRequest(ctx, assessmentMetadataName, assessmentMetadata, options) if err != nil { return AssessmentsMetadataClientCreateInSubscriptionResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AssessmentsMetadataClientCreateInSubscriptionResponse{}, err } @@ -88,7 +78,7 @@ func (client *AssessmentsMetadataClient) createInSubscriptionCreateRequest(ctx c return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -111,16 +101,17 @@ func (client *AssessmentsMetadataClient) createInSubscriptionHandleResponse(resp // DeleteInSubscription - Delete metadata information on an assessment type in a specific subscription, will cause the deletion // of all the assessments of that type in that subscription // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-06-01 -// assessmentMetadataName - The Assessment Key - Unique key for the assessment type -// options - AssessmentsMetadataClientDeleteInSubscriptionOptions contains the optional parameters for the AssessmentsMetadataClient.DeleteInSubscription -// method. +// - assessmentMetadataName - The Assessment Key - Unique key for the assessment type +// - options - AssessmentsMetadataClientDeleteInSubscriptionOptions contains the optional parameters for the AssessmentsMetadataClient.DeleteInSubscription +// method. func (client *AssessmentsMetadataClient) DeleteInSubscription(ctx context.Context, assessmentMetadataName string, options *AssessmentsMetadataClientDeleteInSubscriptionOptions) (AssessmentsMetadataClientDeleteInSubscriptionResponse, error) { req, err := client.deleteInSubscriptionCreateRequest(ctx, assessmentMetadataName, options) if err != nil { return AssessmentsMetadataClientDeleteInSubscriptionResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AssessmentsMetadataClientDeleteInSubscriptionResponse{}, err } @@ -141,7 +132,7 @@ func (client *AssessmentsMetadataClient) deleteInSubscriptionCreateRequest(ctx c return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -154,15 +145,16 @@ func (client *AssessmentsMetadataClient) deleteInSubscriptionCreateRequest(ctx c // Get - Get metadata information on an assessment type // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-06-01 -// assessmentMetadataName - The Assessment Key - Unique key for the assessment type -// options - AssessmentsMetadataClientGetOptions contains the optional parameters for the AssessmentsMetadataClient.Get method. +// - assessmentMetadataName - The Assessment Key - Unique key for the assessment type +// - options - AssessmentsMetadataClientGetOptions contains the optional parameters for the AssessmentsMetadataClient.Get method. func (client *AssessmentsMetadataClient) Get(ctx context.Context, assessmentMetadataName string, options *AssessmentsMetadataClientGetOptions) (AssessmentsMetadataClientGetResponse, error) { req, err := client.getCreateRequest(ctx, assessmentMetadataName, options) if err != nil { return AssessmentsMetadataClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AssessmentsMetadataClientGetResponse{}, err } @@ -179,7 +171,7 @@ func (client *AssessmentsMetadataClient) getCreateRequest(ctx context.Context, a return nil, errors.New("parameter assessmentMetadataName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{assessmentMetadataName}", url.PathEscape(assessmentMetadataName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -201,16 +193,17 @@ func (client *AssessmentsMetadataClient) getHandleResponse(resp *http.Response) // GetInSubscription - Get metadata information on an assessment type in a specific subscription // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-06-01 -// assessmentMetadataName - The Assessment Key - Unique key for the assessment type -// options - AssessmentsMetadataClientGetInSubscriptionOptions contains the optional parameters for the AssessmentsMetadataClient.GetInSubscription -// method. +// - assessmentMetadataName - The Assessment Key - Unique key for the assessment type +// - options - AssessmentsMetadataClientGetInSubscriptionOptions contains the optional parameters for the AssessmentsMetadataClient.GetInSubscription +// method. func (client *AssessmentsMetadataClient) GetInSubscription(ctx context.Context, assessmentMetadataName string, options *AssessmentsMetadataClientGetInSubscriptionOptions) (AssessmentsMetadataClientGetInSubscriptionResponse, error) { req, err := client.getInSubscriptionCreateRequest(ctx, assessmentMetadataName, options) if err != nil { return AssessmentsMetadataClientGetInSubscriptionResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AssessmentsMetadataClientGetInSubscriptionResponse{}, err } @@ -231,7 +224,7 @@ func (client *AssessmentsMetadataClient) getInSubscriptionCreateRequest(ctx cont return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -252,9 +245,10 @@ func (client *AssessmentsMetadataClient) getInSubscriptionHandleResponse(resp *h } // NewListPager - Get metadata information on all assessment types +// // Generated from API version 2021-06-01 -// options - AssessmentsMetadataClientListOptions contains the optional parameters for the AssessmentsMetadataClient.List -// method. +// - options - AssessmentsMetadataClientListOptions contains the optional parameters for the AssessmentsMetadataClient.NewListPager +// method. func (client *AssessmentsMetadataClient) NewListPager(options *AssessmentsMetadataClientListOptions) *runtime.Pager[AssessmentsMetadataClientListResponse] { return runtime.NewPager(runtime.PagingHandler[AssessmentsMetadataClientListResponse]{ More: func(page AssessmentsMetadataClientListResponse) bool { @@ -271,7 +265,7 @@ func (client *AssessmentsMetadataClient) NewListPager(options *AssessmentsMetada if err != nil { return AssessmentsMetadataClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AssessmentsMetadataClientListResponse{}, err } @@ -286,7 +280,7 @@ func (client *AssessmentsMetadataClient) NewListPager(options *AssessmentsMetada // listCreateRequest creates the List request. func (client *AssessmentsMetadataClient) listCreateRequest(ctx context.Context, options *AssessmentsMetadataClientListOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Security/assessmentMetadata" - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -307,9 +301,10 @@ func (client *AssessmentsMetadataClient) listHandleResponse(resp *http.Response) } // NewListBySubscriptionPager - Get metadata information on all assessment types in a specific subscription +// // Generated from API version 2021-06-01 -// options - AssessmentsMetadataClientListBySubscriptionOptions contains the optional parameters for the AssessmentsMetadataClient.ListBySubscription -// method. +// - options - AssessmentsMetadataClientListBySubscriptionOptions contains the optional parameters for the AssessmentsMetadataClient.NewListBySubscriptionPager +// method. func (client *AssessmentsMetadataClient) NewListBySubscriptionPager(options *AssessmentsMetadataClientListBySubscriptionOptions) *runtime.Pager[AssessmentsMetadataClientListBySubscriptionResponse] { return runtime.NewPager(runtime.PagingHandler[AssessmentsMetadataClientListBySubscriptionResponse]{ More: func(page AssessmentsMetadataClientListBySubscriptionResponse) bool { @@ -326,7 +321,7 @@ func (client *AssessmentsMetadataClient) NewListBySubscriptionPager(options *Ass if err != nil { return AssessmentsMetadataClientListBySubscriptionResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AssessmentsMetadataClientListBySubscriptionResponse{}, err } @@ -345,7 +340,7 @@ func (client *AssessmentsMetadataClient) listBySubscriptionCreateRequest(ctx con return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/security/armsecurity/assessmentsmetadata_client_example_test.go b/sdk/resourcemanager/security/armsecurity/assessmentsmetadata_client_example_test.go deleted file mode 100644 index 79906f8b6dee..000000000000 --- a/sdk/resourcemanager/security/armsecurity/assessmentsmetadata_client_example_test.go +++ /dev/null @@ -1,156 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. - -package armsecurity_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2021-06-01/examples/AssessmentsMetadata/ListAssessmentsMetadata_example.json -func ExampleAssessmentsMetadataClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAssessmentsMetadataClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2021-06-01/examples/AssessmentsMetadata/GetAssessmentsMetadata_example.json -func ExampleAssessmentsMetadataClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAssessmentsMetadataClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "21300918-b2e3-0346-785f-c77ff57d243b", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2021-06-01/examples/AssessmentsMetadata/ListAssessmentsMetadata_subscription_example.json -func ExampleAssessmentsMetadataClient_NewListBySubscriptionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAssessmentsMetadataClient("0980887d-03d6-408c-9566-532f3456804e", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListBySubscriptionPager(nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2021-06-01/examples/AssessmentsMetadata/GetAssessmentsMetadata_subscription_example.json -func ExampleAssessmentsMetadataClient_GetInSubscription() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAssessmentsMetadataClient("0980887d-03d6-408c-9566-532f3456804e", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.GetInSubscription(ctx, "21300918-b2e3-0346-785f-c77ff57d243b", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2021-06-01/examples/AssessmentsMetadata/CreateAssessmentsMetadata_subscription_example.json -func ExampleAssessmentsMetadataClient_CreateInSubscription() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAssessmentsMetadataClient("0980887d-03d6-408c-9566-532f3456804e", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateInSubscription(ctx, "ca039e75-a276-4175-aebc-bcd41e4b14b7", armsecurity.AssessmentMetadataResponse{ - Properties: &armsecurity.AssessmentMetadataPropertiesResponse{ - Description: to.Ptr("Install an endpoint protection solution on your virtual machines scale sets, to protect them from threats and vulnerabilities."), - AssessmentType: to.Ptr(armsecurity.AssessmentTypeCustomerManaged), - Categories: []*armsecurity.Categories{ - to.Ptr(armsecurity.CategoriesCompute)}, - DisplayName: to.Ptr("Install endpoint protection solution on virtual machine scale sets"), - ImplementationEffort: to.Ptr(armsecurity.ImplementationEffortLow), - RemediationDescription: to.Ptr("To install an endpoint protection solution: 1. Follow the instructions in How do I turn on antimalware in my virtual machine scale set"), - Severity: to.Ptr(armsecurity.SeverityMedium), - Threats: []*armsecurity.Threats{ - to.Ptr(armsecurity.ThreatsDataExfiltration), - to.Ptr(armsecurity.ThreatsDataSpillage), - to.Ptr(armsecurity.ThreatsMaliciousInsider)}, - UserImpact: to.Ptr(armsecurity.UserImpactLow), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2021-06-01/examples/AssessmentsMetadata/DeleteAssessmentsMetadata_subscription_example.json -func ExampleAssessmentsMetadataClient_DeleteInSubscription() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAssessmentsMetadataClient("0980887d-03d6-408c-9566-532f3456804e", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.DeleteInSubscription(ctx, "ca039e75-a276-4175-aebc-bcd41e4b14b7", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/security/armsecurity/automations_client.go b/sdk/resourcemanager/security/armsecurity/automations_client.go index 6db4c1c63d5d..2d0dd00fd687 100644 --- a/sdk/resourcemanager/security/armsecurity/automations_client.go +++ b/sdk/resourcemanager/security/armsecurity/automations_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,31 +24,22 @@ import ( // AutomationsClient contains the methods for the Automations group. // Don't use this type directly, use NewAutomationsClient() instead. type AutomationsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewAutomationsClient creates a new instance of AutomationsClient with the specified values. -// subscriptionID - Azure subscription ID -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure subscription ID +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewAutomationsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AutomationsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".AutomationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &AutomationsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -58,18 +47,19 @@ func NewAutomationsClient(subscriptionID string, credential azcore.TokenCredenti // CreateOrUpdate - Creates or updates a security automation. If a security automation is already created and a subsequent // request is issued for the same automation id, then it will be updated. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-01-01-preview -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// automationName - The security automation name. -// automation - The security automation resource -// options - AutomationsClientCreateOrUpdateOptions contains the optional parameters for the AutomationsClient.CreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - automationName - The security automation name. +// - automation - The security automation resource +// - options - AutomationsClientCreateOrUpdateOptions contains the optional parameters for the AutomationsClient.CreateOrUpdate +// method. func (client *AutomationsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, automationName string, automation Automation, options *AutomationsClientCreateOrUpdateOptions) (AutomationsClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, automationName, automation, options) if err != nil { return AutomationsClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AutomationsClientCreateOrUpdateResponse{}, err } @@ -94,7 +84,7 @@ func (client *AutomationsClient) createOrUpdateCreateRequest(ctx context.Context return nil, errors.New("parameter automationName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{automationName}", url.PathEscape(automationName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -116,16 +106,17 @@ func (client *AutomationsClient) createOrUpdateHandleResponse(resp *http.Respons // Delete - Deletes a security automation. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-01-01-preview -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// automationName - The security automation name. -// options - AutomationsClientDeleteOptions contains the optional parameters for the AutomationsClient.Delete method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - automationName - The security automation name. +// - options - AutomationsClientDeleteOptions contains the optional parameters for the AutomationsClient.Delete method. func (client *AutomationsClient) Delete(ctx context.Context, resourceGroupName string, automationName string, options *AutomationsClientDeleteOptions) (AutomationsClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, automationName, options) if err != nil { return AutomationsClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AutomationsClientDeleteResponse{}, err } @@ -150,7 +141,7 @@ func (client *AutomationsClient) deleteCreateRequest(ctx context.Context, resour return nil, errors.New("parameter automationName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{automationName}", url.PathEscape(automationName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -163,16 +154,17 @@ func (client *AutomationsClient) deleteCreateRequest(ctx context.Context, resour // Get - Retrieves information about the model of a security automation. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-01-01-preview -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// automationName - The security automation name. -// options - AutomationsClientGetOptions contains the optional parameters for the AutomationsClient.Get method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - automationName - The security automation name. +// - options - AutomationsClientGetOptions contains the optional parameters for the AutomationsClient.Get method. func (client *AutomationsClient) Get(ctx context.Context, resourceGroupName string, automationName string, options *AutomationsClientGetOptions) (AutomationsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, automationName, options) if err != nil { return AutomationsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AutomationsClientGetResponse{}, err } @@ -197,7 +189,7 @@ func (client *AutomationsClient) getCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter automationName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{automationName}", url.PathEscape(automationName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -219,8 +211,9 @@ func (client *AutomationsClient) getHandleResponse(resp *http.Response) (Automat // NewListPager - Lists all the security automations in the specified subscription. Use the 'nextLink' property in the response // to get the next page of security automations for the specified subscription. +// // Generated from API version 2019-01-01-preview -// options - AutomationsClientListOptions contains the optional parameters for the AutomationsClient.List method. +// - options - AutomationsClientListOptions contains the optional parameters for the AutomationsClient.NewListPager method. func (client *AutomationsClient) NewListPager(options *AutomationsClientListOptions) *runtime.Pager[AutomationsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[AutomationsClientListResponse]{ More: func(page AutomationsClientListResponse) bool { @@ -237,7 +230,7 @@ func (client *AutomationsClient) NewListPager(options *AutomationsClientListOpti if err != nil { return AutomationsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AutomationsClientListResponse{}, err } @@ -256,7 +249,7 @@ func (client *AutomationsClient) listCreateRequest(ctx context.Context, options return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -278,10 +271,11 @@ func (client *AutomationsClient) listHandleResponse(resp *http.Response) (Automa // NewListByResourceGroupPager - Lists all the security automations in the specified resource group. Use the 'nextLink' property // in the response to get the next page of security automations for the specified resource group. +// // Generated from API version 2019-01-01-preview -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// options - AutomationsClientListByResourceGroupOptions contains the optional parameters for the AutomationsClient.ListByResourceGroup -// method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - options - AutomationsClientListByResourceGroupOptions contains the optional parameters for the AutomationsClient.NewListByResourceGroupPager +// method. func (client *AutomationsClient) NewListByResourceGroupPager(resourceGroupName string, options *AutomationsClientListByResourceGroupOptions) *runtime.Pager[AutomationsClientListByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[AutomationsClientListByResourceGroupResponse]{ More: func(page AutomationsClientListByResourceGroupResponse) bool { @@ -298,7 +292,7 @@ func (client *AutomationsClient) NewListByResourceGroupPager(resourceGroupName s if err != nil { return AutomationsClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AutomationsClientListByResourceGroupResponse{}, err } @@ -321,7 +315,7 @@ func (client *AutomationsClient) listByResourceGroupCreateRequest(ctx context.Co return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -343,17 +337,18 @@ func (client *AutomationsClient) listByResourceGroupHandleResponse(resp *http.Re // Validate - Validates the security automation model before create or update. Any validation errors are returned to the client. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-01-01-preview -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// automationName - The security automation name. -// automation - The security automation resource -// options - AutomationsClientValidateOptions contains the optional parameters for the AutomationsClient.Validate method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - automationName - The security automation name. +// - automation - The security automation resource +// - options - AutomationsClientValidateOptions contains the optional parameters for the AutomationsClient.Validate method. func (client *AutomationsClient) Validate(ctx context.Context, resourceGroupName string, automationName string, automation Automation, options *AutomationsClientValidateOptions) (AutomationsClientValidateResponse, error) { req, err := client.validateCreateRequest(ctx, resourceGroupName, automationName, automation, options) if err != nil { return AutomationsClientValidateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AutomationsClientValidateResponse{}, err } @@ -378,7 +373,7 @@ func (client *AutomationsClient) validateCreateRequest(ctx context.Context, reso return nil, errors.New("parameter automationName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{automationName}", url.PathEscape(automationName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/security/armsecurity/automations_client_example_test.go b/sdk/resourcemanager/security/armsecurity/automations_client_example_test.go deleted file mode 100644 index 4f4642ddcbad..000000000000 --- a/sdk/resourcemanager/security/armsecurity/automations_client_example_test.go +++ /dev/null @@ -1,299 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. - -package armsecurity_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/Automations/GetAutomationsSubscription_example.json -func ExampleAutomationsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAutomationsClient("a5caac9c-5c04-49af-b3d0-e204f40345d5", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/Automations/GetAutomationsResourceGroup_example.json -func ExampleAutomationsClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAutomationsClient("a5caac9c-5c04-49af-b3d0-e204f40345d5", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByResourceGroupPager("exampleResourceGroup", nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/Automations/GetAutomationResourceGroup_example.json -func ExampleAutomationsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAutomationsClient("a5caac9c-5c04-49af-b3d0-e204f40345d5", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "exampleResourceGroup", "exampleAutomation", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/Automations/PutAutomationAllAssessments_example.json -func ExampleAutomationsClient_CreateOrUpdate_createOrUpdateASecurityAutomationForAllAssessmentsIncludingAllSeverities() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAutomationsClient("a5caac9c-5c04-49af-b3d0-e204f40345d5", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdate(ctx, "exampleResourceGroup", "exampleAutomation", armsecurity.Automation{ - Location: to.Ptr("Central US"), - Etag: to.Ptr("etag value (must be supplied for update)"), - Tags: map[string]*string{}, - Properties: &armsecurity.AutomationProperties{ - Description: to.Ptr("An example of a security automation that triggers one LogicApp resource (myTest1) on any security assessment"), - Actions: []armsecurity.AutomationActionClassification{ - &armsecurity.AutomationActionLogicApp{ - ActionType: to.Ptr(armsecurity.ActionTypeLogicApp), - LogicAppResourceID: to.Ptr("/subscriptions/e54a4a18-5b94-4f90-9471-bd3decad8a2e/resourceGroups/sample/providers/Microsoft.Logic/workflows/MyTest1"), - URI: to.Ptr("https://exampleTriggerUri1.com"), - }}, - IsEnabled: to.Ptr(true), - Scopes: []*armsecurity.AutomationScope{ - { - Description: to.Ptr("A description that helps to identify this scope - for example: security assessments that relate to the resource group myResourceGroup within the subscription a5caac9c-5c04-49af-b3d0-e204f40345d5"), - ScopePath: to.Ptr("/subscriptions/a5caac9c-5c04-49af-b3d0-e204f40345d5/resourceGroups/myResourceGroup"), - }}, - Sources: []*armsecurity.AutomationSource{ - { - EventSource: to.Ptr(armsecurity.EventSourceAssessments), - }}, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/Automations/PutAutomationHighSeverityAssessments_example.json -func ExampleAutomationsClient_CreateOrUpdate_createOrUpdateASecurityAutomationForAllHighSeverityAssessments() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAutomationsClient("a5caac9c-5c04-49af-b3d0-e204f40345d5", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdate(ctx, "exampleResourceGroup", "exampleAutomation", armsecurity.Automation{ - Location: to.Ptr("Central US"), - Etag: to.Ptr("etag value (must be supplied for update)"), - Tags: map[string]*string{}, - Properties: &armsecurity.AutomationProperties{ - Description: to.Ptr("An example of a security automation that triggers one LogicApp resource (myTest1) on any high severity security assessment"), - Actions: []armsecurity.AutomationActionClassification{ - &armsecurity.AutomationActionLogicApp{ - ActionType: to.Ptr(armsecurity.ActionTypeLogicApp), - LogicAppResourceID: to.Ptr("/subscriptions/e54a4a18-5b94-4f90-9471-bd3decad8a2e/resourceGroups/sample/providers/Microsoft.Logic/workflows/MyTest1"), - URI: to.Ptr("https://exampleTriggerUri1.com"), - }}, - IsEnabled: to.Ptr(true), - Scopes: []*armsecurity.AutomationScope{ - { - Description: to.Ptr("A description that helps to identify this scope - for example: security assessments that relate to the resource group myResourceGroup within the subscription a5caac9c-5c04-49af-b3d0-e204f40345d5"), - ScopePath: to.Ptr("/subscriptions/a5caac9c-5c04-49af-b3d0-e204f40345d5/resourceGroups/myResourceGroup"), - }}, - Sources: []*armsecurity.AutomationSource{ - { - EventSource: to.Ptr(armsecurity.EventSourceAssessments), - RuleSets: []*armsecurity.AutomationRuleSet{ - { - Rules: []*armsecurity.AutomationTriggeringRule{ - { - ExpectedValue: to.Ptr("High"), - Operator: to.Ptr(armsecurity.OperatorEquals), - PropertyJPath: to.Ptr("properties.metadata.severity"), - PropertyType: to.Ptr(armsecurity.PropertyTypeString), - }}, - }}, - }}, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/Automations/PutDisableAutomation_example.json -func ExampleAutomationsClient_CreateOrUpdate_disableOrEnableASecurityAutomation() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAutomationsClient("a5caac9c-5c04-49af-b3d0-e204f40345d5", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdate(ctx, "exampleResourceGroup", "exampleAutomation", armsecurity.Automation{ - Location: to.Ptr("Central US"), - Etag: to.Ptr("etag value (must be supplied for update)"), - Tags: map[string]*string{}, - Properties: &armsecurity.AutomationProperties{ - Description: to.Ptr("An example of a security automation that triggers one LogicApp resource (myTest1) on any security assessment of type customAssessment"), - Actions: []armsecurity.AutomationActionClassification{ - &armsecurity.AutomationActionLogicApp{ - ActionType: to.Ptr(armsecurity.ActionTypeLogicApp), - LogicAppResourceID: to.Ptr("/subscriptions/e54a4a18-5b94-4f90-9471-bd3decad8a2e/resourceGroups/sample/providers/Microsoft.Logic/workflows/MyTest1"), - URI: to.Ptr("https://exampleTriggerUri1.com"), - }}, - IsEnabled: to.Ptr(false), - Scopes: []*armsecurity.AutomationScope{ - { - Description: to.Ptr("A description that helps to identify this scope - for example: security assessments that relate to the resource group myResourceGroup within the subscription a5caac9c-5c04-49af-b3d0-e204f40345d5"), - ScopePath: to.Ptr("/subscriptions/a5caac9c-5c04-49af-b3d0-e204f40345d5/resourceGroups/myResourceGroup"), - }}, - Sources: []*armsecurity.AutomationSource{ - { - EventSource: to.Ptr(armsecurity.EventSourceAssessments), - RuleSets: []*armsecurity.AutomationRuleSet{ - { - Rules: []*armsecurity.AutomationTriggeringRule{ - { - ExpectedValue: to.Ptr("customAssessment"), - Operator: to.Ptr(armsecurity.OperatorEquals), - PropertyJPath: to.Ptr("$.Entity.AssessmentType"), - PropertyType: to.Ptr(armsecurity.PropertyTypeString), - }}, - }}, - }}, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/Automations/DeleteAutomation_example.json -func ExampleAutomationsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAutomationsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, "myRg", "myAutomationName", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/Automations/ValidateAutomation_example.json -func ExampleAutomationsClient_Validate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAutomationsClient("a5caac9c-5c04-49af-b3d0-e204f40345d5", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Validate(ctx, "exampleResourceGroup", "exampleAutomation", armsecurity.Automation{ - Location: to.Ptr("Central US"), - Tags: map[string]*string{}, - Properties: &armsecurity.AutomationProperties{ - Description: to.Ptr("An example of a security automation that triggers one LogicApp resource (myTest1) on any security assessment of type customAssessment"), - Actions: []armsecurity.AutomationActionClassification{ - &armsecurity.AutomationActionLogicApp{ - ActionType: to.Ptr(armsecurity.ActionTypeLogicApp), - LogicAppResourceID: to.Ptr("/subscriptions/e54a4a18-5b94-4f90-9471-bd3decad8a2e/resourceGroups/sample/providers/Microsoft.Logic/workflows/MyTest1"), - URI: to.Ptr("https://exampleTriggerUri1.com"), - }}, - IsEnabled: to.Ptr(true), - Scopes: []*armsecurity.AutomationScope{ - { - Description: to.Ptr("A description that helps to identify this scope - for example: security assessments that relate to the resource group myResourceGroup within the subscription a5caac9c-5c04-49af-b3d0-e204f40345d5"), - ScopePath: to.Ptr("/subscriptions/a5caac9c-5c04-49af-b3d0-e204f40345d5/resourceGroups/myResourceGroup"), - }}, - Sources: []*armsecurity.AutomationSource{ - { - EventSource: to.Ptr(armsecurity.EventSourceAssessments), - RuleSets: []*armsecurity.AutomationRuleSet{ - { - Rules: []*armsecurity.AutomationTriggeringRule{ - { - ExpectedValue: to.Ptr("customAssessment"), - Operator: to.Ptr(armsecurity.OperatorEquals), - PropertyJPath: to.Ptr("$.Entity.AssessmentType"), - PropertyType: to.Ptr(armsecurity.PropertyTypeString), - }}, - }}, - }}, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/security/armsecurity/autoprovisioningsettings_client.go b/sdk/resourcemanager/security/armsecurity/autoprovisioningsettings_client.go index 67f530d9204f..6a16536326fe 100644 --- a/sdk/resourcemanager/security/armsecurity/autoprovisioningsettings_client.go +++ b/sdk/resourcemanager/security/armsecurity/autoprovisioningsettings_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,48 +24,40 @@ import ( // AutoProvisioningSettingsClient contains the methods for the AutoProvisioningSettings group. // Don't use this type directly, use NewAutoProvisioningSettingsClient() instead. type AutoProvisioningSettingsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewAutoProvisioningSettingsClient creates a new instance of AutoProvisioningSettingsClient with the specified values. -// subscriptionID - Azure subscription ID -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure subscription ID +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewAutoProvisioningSettingsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AutoProvisioningSettingsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".AutoProvisioningSettingsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &AutoProvisioningSettingsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Create - Details of a specific setting // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-08-01-preview -// settingName - Auto provisioning setting key -// setting - Auto provisioning setting key -// options - AutoProvisioningSettingsClientCreateOptions contains the optional parameters for the AutoProvisioningSettingsClient.Create -// method. +// - settingName - Auto provisioning setting key +// - setting - Auto provisioning setting key +// - options - AutoProvisioningSettingsClientCreateOptions contains the optional parameters for the AutoProvisioningSettingsClient.Create +// method. func (client *AutoProvisioningSettingsClient) Create(ctx context.Context, settingName string, setting AutoProvisioningSetting, options *AutoProvisioningSettingsClientCreateOptions) (AutoProvisioningSettingsClientCreateResponse, error) { req, err := client.createCreateRequest(ctx, settingName, setting, options) if err != nil { return AutoProvisioningSettingsClientCreateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AutoProvisioningSettingsClientCreateResponse{}, err } @@ -88,7 +78,7 @@ func (client *AutoProvisioningSettingsClient) createCreateRequest(ctx context.Co return nil, errors.New("parameter settingName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{settingName}", url.PathEscape(settingName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -110,16 +100,17 @@ func (client *AutoProvisioningSettingsClient) createHandleResponse(resp *http.Re // Get - Details of a specific setting // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-08-01-preview -// settingName - Auto provisioning setting key -// options - AutoProvisioningSettingsClientGetOptions contains the optional parameters for the AutoProvisioningSettingsClient.Get -// method. +// - settingName - Auto provisioning setting key +// - options - AutoProvisioningSettingsClientGetOptions contains the optional parameters for the AutoProvisioningSettingsClient.Get +// method. func (client *AutoProvisioningSettingsClient) Get(ctx context.Context, settingName string, options *AutoProvisioningSettingsClientGetOptions) (AutoProvisioningSettingsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, settingName, options) if err != nil { return AutoProvisioningSettingsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AutoProvisioningSettingsClientGetResponse{}, err } @@ -140,7 +131,7 @@ func (client *AutoProvisioningSettingsClient) getCreateRequest(ctx context.Conte return nil, errors.New("parameter settingName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{settingName}", url.PathEscape(settingName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -161,9 +152,10 @@ func (client *AutoProvisioningSettingsClient) getHandleResponse(resp *http.Respo } // NewListPager - Exposes the auto provisioning settings of the subscriptions +// // Generated from API version 2017-08-01-preview -// options - AutoProvisioningSettingsClientListOptions contains the optional parameters for the AutoProvisioningSettingsClient.List -// method. +// - options - AutoProvisioningSettingsClientListOptions contains the optional parameters for the AutoProvisioningSettingsClient.NewListPager +// method. func (client *AutoProvisioningSettingsClient) NewListPager(options *AutoProvisioningSettingsClientListOptions) *runtime.Pager[AutoProvisioningSettingsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[AutoProvisioningSettingsClientListResponse]{ More: func(page AutoProvisioningSettingsClientListResponse) bool { @@ -180,7 +172,7 @@ func (client *AutoProvisioningSettingsClient) NewListPager(options *AutoProvisio if err != nil { return AutoProvisioningSettingsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AutoProvisioningSettingsClientListResponse{}, err } @@ -199,7 +191,7 @@ func (client *AutoProvisioningSettingsClient) listCreateRequest(ctx context.Cont return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/security/armsecurity/autoprovisioningsettings_client_example_test.go b/sdk/resourcemanager/security/armsecurity/autoprovisioningsettings_client_example_test.go deleted file mode 100644 index 672174227791..000000000000 --- a/sdk/resourcemanager/security/armsecurity/autoprovisioningsettings_client_example_test.go +++ /dev/null @@ -1,87 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. - -package armsecurity_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2017-08-01-preview/examples/AutoProvisioningSettings/GetAutoProvisioningSettingsSubscription_example.json -func ExampleAutoProvisioningSettingsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAutoProvisioningSettingsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2017-08-01-preview/examples/AutoProvisioningSettings/GetAutoProvisioningSettingSubscription_example.json -func ExampleAutoProvisioningSettingsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAutoProvisioningSettingsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "default", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2017-08-01-preview/examples/AutoProvisioningSettings/CreateAutoProvisioningSettingsSubscription_example.json -func ExampleAutoProvisioningSettingsClient_Create() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewAutoProvisioningSettingsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Create(ctx, "default", armsecurity.AutoProvisioningSetting{ - Name: to.Ptr("default"), - Type: to.Ptr("Microsoft.Security/autoProvisioningSettings"), - ID: to.Ptr("/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/providers/Microsoft.Security/autoProvisioningSettings/default"), - Properties: &armsecurity.AutoProvisioningSettingProperties{ - AutoProvision: to.Ptr(armsecurity.AutoProvisionOn), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/security/armsecurity/autorest.md b/sdk/resourcemanager/security/armsecurity/autorest.md index 3311270df29b..47aabc7eb588 100644 --- a/sdk/resourcemanager/security/armsecurity/autorest.md +++ b/sdk/resourcemanager/security/armsecurity/autorest.md @@ -4,12 +4,11 @@ ``` yaml azure-arm: true -tag: package-composite-v3 require: -- https://github.com/Azure/azure-rest-api-specs/blob/af3f7994582c0cbd61a48b636907ad2ac95d332c/specification/security/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/af3f7994582c0cbd61a48b636907ad2ac95d332c/specification/security/resource-manager/readme.go.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/security/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/security/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 0.9.0 +module-version: 0.10.0 modelerfour: lenient-model-deduplication: true ``` \ No newline at end of file diff --git a/sdk/resourcemanager/security/armsecurity/client_factory.go b/sdk/resourcemanager/security/armsecurity/client_factory.go new file mode 100644 index 000000000000..1d3e787f1d1d --- /dev/null +++ b/sdk/resourcemanager/security/armsecurity/client_factory.go @@ -0,0 +1,339 @@ +//go:build go1.18 +// +build go1.18 + +// 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. +// DO NOT EDIT. + +package armsecurity + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" +) + +// ClientFactory is a client factory used to create any client in this module. +// Don't use this type directly, use NewClientFactory instead. +type ClientFactory struct { + subscriptionID string + credential azcore.TokenCredential + options *arm.ClientOptions +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - subscriptionID - Azure subscription ID +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + _, err := arm.NewClient(moduleName+".ClientFactory", moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, credential: credential, + options: options.Clone(), + }, nil +} + +func (c *ClientFactory) NewMdeOnboardingsClient() *MdeOnboardingsClient { + subClient, _ := NewMdeOnboardingsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewCustomAssessmentAutomationsClient() *CustomAssessmentAutomationsClient { + subClient, _ := NewCustomAssessmentAutomationsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewCustomEntityStoreAssignmentsClient() *CustomEntityStoreAssignmentsClient { + subClient, _ := NewCustomEntityStoreAssignmentsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewComplianceResultsClient() *ComplianceResultsClient { + subClient, _ := NewComplianceResultsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewPricingsClient() *PricingsClient { + subClient, _ := NewPricingsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewAdvancedThreatProtectionClient() *AdvancedThreatProtectionClient { + subClient, _ := NewAdvancedThreatProtectionClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewDeviceSecurityGroupsClient() *DeviceSecurityGroupsClient { + subClient, _ := NewDeviceSecurityGroupsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewIotSecuritySolutionClient() *IotSecuritySolutionClient { + subClient, _ := NewIotSecuritySolutionClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewIotSecuritySolutionAnalyticsClient() *IotSecuritySolutionAnalyticsClient { + subClient, _ := NewIotSecuritySolutionAnalyticsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewIotSecuritySolutionsAnalyticsAggregatedAlertClient() *IotSecuritySolutionsAnalyticsAggregatedAlertClient { + subClient, _ := NewIotSecuritySolutionsAnalyticsAggregatedAlertClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewIotSecuritySolutionsAnalyticsRecommendationClient() *IotSecuritySolutionsAnalyticsRecommendationClient { + subClient, _ := NewIotSecuritySolutionsAnalyticsRecommendationClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewLocationsClient() *LocationsClient { + subClient, _ := NewLocationsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + subClient, _ := NewOperationsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewTasksClient() *TasksClient { + subClient, _ := NewTasksClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewAutoProvisioningSettingsClient() *AutoProvisioningSettingsClient { + subClient, _ := NewAutoProvisioningSettingsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewCompliancesClient() *CompliancesClient { + subClient, _ := NewCompliancesClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewInformationProtectionPoliciesClient() *InformationProtectionPoliciesClient { + subClient, _ := NewInformationProtectionPoliciesClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewContactsClient() *ContactsClient { + subClient, _ := NewContactsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewWorkspaceSettingsClient() *WorkspaceSettingsClient { + subClient, _ := NewWorkspaceSettingsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewRegulatoryComplianceStandardsClient() *RegulatoryComplianceStandardsClient { + subClient, _ := NewRegulatoryComplianceStandardsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewRegulatoryComplianceControlsClient() *RegulatoryComplianceControlsClient { + subClient, _ := NewRegulatoryComplianceControlsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewRegulatoryComplianceAssessmentsClient() *RegulatoryComplianceAssessmentsClient { + subClient, _ := NewRegulatoryComplianceAssessmentsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewSubAssessmentsClient() *SubAssessmentsClient { + subClient, _ := NewSubAssessmentsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewAutomationsClient() *AutomationsClient { + subClient, _ := NewAutomationsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewAlertsSuppressionRulesClient() *AlertsSuppressionRulesClient { + subClient, _ := NewAlertsSuppressionRulesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewServerVulnerabilityAssessmentClient() *ServerVulnerabilityAssessmentClient { + subClient, _ := NewServerVulnerabilityAssessmentClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewAssessmentsMetadataClient() *AssessmentsMetadataClient { + subClient, _ := NewAssessmentsMetadataClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewAssessmentsClient() *AssessmentsClient { + subClient, _ := NewAssessmentsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewAdaptiveApplicationControlsClient() *AdaptiveApplicationControlsClient { + subClient, _ := NewAdaptiveApplicationControlsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewAdaptiveNetworkHardeningsClient() *AdaptiveNetworkHardeningsClient { + subClient, _ := NewAdaptiveNetworkHardeningsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewAllowedConnectionsClient() *AllowedConnectionsClient { + subClient, _ := NewAllowedConnectionsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewTopologyClient() *TopologyClient { + subClient, _ := NewTopologyClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewJitNetworkAccessPoliciesClient() *JitNetworkAccessPoliciesClient { + subClient, _ := NewJitNetworkAccessPoliciesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewDiscoveredSecuritySolutionsClient() *DiscoveredSecuritySolutionsClient { + subClient, _ := NewDiscoveredSecuritySolutionsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewSolutionsReferenceDataClient() *SolutionsReferenceDataClient { + subClient, _ := NewSolutionsReferenceDataClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewExternalSecuritySolutionsClient() *ExternalSecuritySolutionsClient { + subClient, _ := NewExternalSecuritySolutionsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewSecureScoresClient() *SecureScoresClient { + subClient, _ := NewSecureScoresClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewSecureScoreControlsClient() *SecureScoreControlsClient { + subClient, _ := NewSecureScoreControlsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewSecureScoreControlDefinitionsClient() *SecureScoreControlDefinitionsClient { + subClient, _ := NewSecureScoreControlDefinitionsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewSolutionsClient() *SolutionsClient { + subClient, _ := NewSolutionsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewAccountConnectorsClient() *AccountConnectorsClient { + subClient, _ := NewAccountConnectorsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewAlertsClient() *AlertsClient { + subClient, _ := NewAlertsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewSettingsClient() *SettingsClient { + subClient, _ := NewSettingsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewIngestionSettingsClient() *IngestionSettingsClient { + subClient, _ := NewIngestionSettingsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewSoftwareInventoriesClient() *SoftwareInventoriesClient { + subClient, _ := NewSoftwareInventoriesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewGovernanceRulesClient() *GovernanceRulesClient { + subClient, _ := NewGovernanceRulesClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewGovernanceAssignmentsClient() *GovernanceAssignmentsClient { + subClient, _ := NewGovernanceAssignmentsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewApplicationsClient() *ApplicationsClient { + subClient, _ := NewApplicationsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewApplicationClient() *ApplicationClient { + subClient, _ := NewApplicationClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewConnectorApplicationsClient() *ConnectorApplicationsClient { + subClient, _ := NewConnectorApplicationsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewConnectorApplicationClient() *ConnectorApplicationClient { + subClient, _ := NewConnectorApplicationClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewAPICollectionClient() *APICollectionClient { + subClient, _ := NewAPICollectionClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewAPICollectionOnboardingClient() *APICollectionOnboardingClient { + subClient, _ := NewAPICollectionOnboardingClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewAPICollectionOffboardingClient() *APICollectionOffboardingClient { + subClient, _ := NewAPICollectionOffboardingClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewHealthReportsClient() *HealthReportsClient { + subClient, _ := NewHealthReportsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewHealthReportClient() *HealthReportClient { + subClient, _ := NewHealthReportClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewSQLVulnerabilityAssessmentScansClient() *SQLVulnerabilityAssessmentScansClient { + subClient, _ := NewSQLVulnerabilityAssessmentScansClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewSQLVulnerabilityAssessmentScanResultsClient() *SQLVulnerabilityAssessmentScanResultsClient { + subClient, _ := NewSQLVulnerabilityAssessmentScanResultsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewSQLVulnerabilityAssessmentBaselineRulesClient() *SQLVulnerabilityAssessmentBaselineRulesClient { + subClient, _ := NewSQLVulnerabilityAssessmentBaselineRulesClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewConnectorsClient() *ConnectorsClient { + subClient, _ := NewConnectorsClient(c.subscriptionID, c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/security/armsecurity/complianceresults_client.go b/sdk/resourcemanager/security/armsecurity/complianceresults_client.go index ce13a606e7c6..725d412d6998 100644 --- a/sdk/resourcemanager/security/armsecurity/complianceresults_client.go +++ b/sdk/resourcemanager/security/armsecurity/complianceresults_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,44 +24,36 @@ import ( // ComplianceResultsClient contains the methods for the ComplianceResults group. // Don't use this type directly, use NewComplianceResultsClient() instead. type ComplianceResultsClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewComplianceResultsClient creates a new instance of ComplianceResultsClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewComplianceResultsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*ComplianceResultsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".ComplianceResultsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ComplianceResultsClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Security Compliance Result // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-08-01 -// resourceID - The identifier of the resource. -// complianceResultName - name of the desired assessment compliance result -// options - ComplianceResultsClientGetOptions contains the optional parameters for the ComplianceResultsClient.Get method. +// - resourceID - The identifier of the resource. +// - complianceResultName - name of the desired assessment compliance result +// - options - ComplianceResultsClientGetOptions contains the optional parameters for the ComplianceResultsClient.Get method. func (client *ComplianceResultsClient) Get(ctx context.Context, resourceID string, complianceResultName string, options *ComplianceResultsClientGetOptions) (ComplianceResultsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceID, complianceResultName, options) if err != nil { return ComplianceResultsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ComplianceResultsClientGetResponse{}, err } @@ -81,7 +71,7 @@ func (client *ComplianceResultsClient) getCreateRequest(ctx context.Context, res return nil, errors.New("parameter complianceResultName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{complianceResultName}", url.PathEscape(complianceResultName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -102,10 +92,12 @@ func (client *ComplianceResultsClient) getHandleResponse(resp *http.Response) (C } // NewListPager - Security compliance results in the subscription +// // Generated from API version 2017-08-01 -// scope - Scope of the query, can be subscription (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group -// (/providers/Microsoft.Management/managementGroups/mgName). -// options - ComplianceResultsClientListOptions contains the optional parameters for the ComplianceResultsClient.List method. +// - scope - Scope of the query, can be subscription (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group +// (/providers/Microsoft.Management/managementGroups/mgName). +// - options - ComplianceResultsClientListOptions contains the optional parameters for the ComplianceResultsClient.NewListPager +// method. func (client *ComplianceResultsClient) NewListPager(scope string, options *ComplianceResultsClientListOptions) *runtime.Pager[ComplianceResultsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[ComplianceResultsClientListResponse]{ More: func(page ComplianceResultsClientListResponse) bool { @@ -122,7 +114,7 @@ func (client *ComplianceResultsClient) NewListPager(scope string, options *Compl if err != nil { return ComplianceResultsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ComplianceResultsClientListResponse{}, err } @@ -138,7 +130,7 @@ func (client *ComplianceResultsClient) NewListPager(scope string, options *Compl func (client *ComplianceResultsClient) listCreateRequest(ctx context.Context, scope string, options *ComplianceResultsClientListOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.Security/complianceResults" urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/security/armsecurity/complianceresults_client_example_test.go b/sdk/resourcemanager/security/armsecurity/complianceresults_client_example_test.go deleted file mode 100644 index cf3f0ae0e018..000000000000 --- a/sdk/resourcemanager/security/armsecurity/complianceresults_client_example_test.go +++ /dev/null @@ -1,60 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. - -package armsecurity_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2017-08-01/examples/ComplianceResults/ListComplianceResults_example.json -func ExampleComplianceResultsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewComplianceResultsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23", nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2017-08-01/examples/ComplianceResults/GetComplianceResults_example.json -func ExampleComplianceResultsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewComplianceResultsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23", "DesignateMoreThanOneOwner", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/security/armsecurity/compliances_client.go b/sdk/resourcemanager/security/armsecurity/compliances_client.go index 0a4e34f3ebd8..392510456567 100644 --- a/sdk/resourcemanager/security/armsecurity/compliances_client.go +++ b/sdk/resourcemanager/security/armsecurity/compliances_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,45 +24,37 @@ import ( // CompliancesClient contains the methods for the Compliances group. // Don't use this type directly, use NewCompliancesClient() instead. type CompliancesClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewCompliancesClient creates a new instance of CompliancesClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewCompliancesClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*CompliancesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".CompliancesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &CompliancesClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Details of a specific Compliance. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-08-01-preview -// scope - Scope of the query, can be subscription (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group -// (/providers/Microsoft.Management/managementGroups/mgName). -// complianceName - name of the Compliance -// options - CompliancesClientGetOptions contains the optional parameters for the CompliancesClient.Get method. +// - scope - Scope of the query, can be subscription (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group +// (/providers/Microsoft.Management/managementGroups/mgName). +// - complianceName - name of the Compliance +// - options - CompliancesClientGetOptions contains the optional parameters for the CompliancesClient.Get method. func (client *CompliancesClient) Get(ctx context.Context, scope string, complianceName string, options *CompliancesClientGetOptions) (CompliancesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, scope, complianceName, options) if err != nil { return CompliancesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return CompliancesClientGetResponse{}, err } @@ -82,7 +72,7 @@ func (client *CompliancesClient) getCreateRequest(ctx context.Context, scope str return nil, errors.New("parameter complianceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{complianceName}", url.PathEscape(complianceName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -103,10 +93,11 @@ func (client *CompliancesClient) getHandleResponse(resp *http.Response) (Complia } // NewListPager - The Compliance scores of the specific management group. +// // Generated from API version 2017-08-01-preview -// scope - Scope of the query, can be subscription (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group -// (/providers/Microsoft.Management/managementGroups/mgName). -// options - CompliancesClientListOptions contains the optional parameters for the CompliancesClient.List method. +// - scope - Scope of the query, can be subscription (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group +// (/providers/Microsoft.Management/managementGroups/mgName). +// - options - CompliancesClientListOptions contains the optional parameters for the CompliancesClient.NewListPager method. func (client *CompliancesClient) NewListPager(scope string, options *CompliancesClientListOptions) *runtime.Pager[CompliancesClientListResponse] { return runtime.NewPager(runtime.PagingHandler[CompliancesClientListResponse]{ More: func(page CompliancesClientListResponse) bool { @@ -123,7 +114,7 @@ func (client *CompliancesClient) NewListPager(scope string, options *Compliances if err != nil { return CompliancesClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return CompliancesClientListResponse{}, err } @@ -139,7 +130,7 @@ func (client *CompliancesClient) NewListPager(scope string, options *Compliances func (client *CompliancesClient) listCreateRequest(ctx context.Context, scope string, options *CompliancesClientListOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.Security/compliances" urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/security/armsecurity/compliances_client_example_test.go b/sdk/resourcemanager/security/armsecurity/compliances_client_example_test.go deleted file mode 100644 index 3d845b0484d9..000000000000 --- a/sdk/resourcemanager/security/armsecurity/compliances_client_example_test.go +++ /dev/null @@ -1,60 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. - -package armsecurity_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2017-08-01-preview/examples/Compliances/GetCompliances_example.json -func ExampleCompliancesClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewCompliancesClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23", nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2017-08-01-preview/examples/Compliances/GetCompliance_example.json -func ExampleCompliancesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewCompliancesClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23", "2018-01-01Z", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/security/armsecurity/connectorapplication_client.go b/sdk/resourcemanager/security/armsecurity/connectorapplication_client.go index f31036330d1d..8f56c835f7b9 100644 --- a/sdk/resourcemanager/security/armsecurity/connectorapplication_client.go +++ b/sdk/resourcemanager/security/armsecurity/connectorapplication_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,50 +24,42 @@ import ( // ConnectorApplicationClient contains the methods for the SecurityConnectorApplication group. // Don't use this type directly, use NewConnectorApplicationClient() instead. type ConnectorApplicationClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewConnectorApplicationClient creates a new instance of ConnectorApplicationClient with the specified values. -// subscriptionID - Azure subscription ID -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure subscription ID +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewConnectorApplicationClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ConnectorApplicationClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".ConnectorApplicationClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ConnectorApplicationClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // CreateOrUpdate - Creates or update a security Application on the given security connector. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01-preview -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// securityConnectorName - The security connector name. -// applicationID - The security Application key - unique key for the standard application -// application - Application over a subscription scope -// options - ConnectorApplicationClientCreateOrUpdateOptions contains the optional parameters for the ConnectorApplicationClient.CreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - securityConnectorName - The security connector name. +// - applicationID - The security Application key - unique key for the standard application +// - application - Application over a subscription scope +// - options - ConnectorApplicationClientCreateOrUpdateOptions contains the optional parameters for the ConnectorApplicationClient.CreateOrUpdate +// method. func (client *ConnectorApplicationClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, securityConnectorName string, applicationID string, application Application, options *ConnectorApplicationClientCreateOrUpdateOptions) (ConnectorApplicationClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, securityConnectorName, applicationID, application, options) if err != nil { return ConnectorApplicationClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ConnectorApplicationClientCreateOrUpdateResponse{}, err } @@ -98,7 +88,7 @@ func (client *ConnectorApplicationClient) createOrUpdateCreateRequest(ctx contex return nil, errors.New("parameter applicationID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{applicationId}", url.PathEscape(applicationID)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -120,18 +110,19 @@ func (client *ConnectorApplicationClient) createOrUpdateHandleResponse(resp *htt // Delete - Delete an Application over a given scope // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01-preview -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// securityConnectorName - The security connector name. -// applicationID - The security Application key - unique key for the standard application -// options - ConnectorApplicationClientDeleteOptions contains the optional parameters for the ConnectorApplicationClient.Delete -// method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - securityConnectorName - The security connector name. +// - applicationID - The security Application key - unique key for the standard application +// - options - ConnectorApplicationClientDeleteOptions contains the optional parameters for the ConnectorApplicationClient.Delete +// method. func (client *ConnectorApplicationClient) Delete(ctx context.Context, resourceGroupName string, securityConnectorName string, applicationID string, options *ConnectorApplicationClientDeleteOptions) (ConnectorApplicationClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, securityConnectorName, applicationID, options) if err != nil { return ConnectorApplicationClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ConnectorApplicationClientDeleteResponse{}, err } @@ -160,7 +151,7 @@ func (client *ConnectorApplicationClient) deleteCreateRequest(ctx context.Contex return nil, errors.New("parameter applicationID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{applicationId}", url.PathEscape(applicationID)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -172,18 +163,19 @@ func (client *ConnectorApplicationClient) deleteCreateRequest(ctx context.Contex // Get - Get a specific application for the requested scope by applicationId // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01-preview -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// securityConnectorName - The security connector name. -// applicationID - The security Application key - unique key for the standard application -// options - ConnectorApplicationClientGetOptions contains the optional parameters for the ConnectorApplicationClient.Get -// method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - securityConnectorName - The security connector name. +// - applicationID - The security Application key - unique key for the standard application +// - options - ConnectorApplicationClientGetOptions contains the optional parameters for the ConnectorApplicationClient.Get +// method. func (client *ConnectorApplicationClient) Get(ctx context.Context, resourceGroupName string, securityConnectorName string, applicationID string, options *ConnectorApplicationClientGetOptions) (ConnectorApplicationClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, securityConnectorName, applicationID, options) if err != nil { return ConnectorApplicationClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ConnectorApplicationClientGetResponse{}, err } @@ -212,7 +204,7 @@ func (client *ConnectorApplicationClient) getCreateRequest(ctx context.Context, return nil, errors.New("parameter applicationID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{applicationId}", url.PathEscape(applicationID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/security/armsecurity/connectorapplication_client_example_test.go b/sdk/resourcemanager/security/armsecurity/connectorapplication_client_example_test.go deleted file mode 100644 index 55e790113bc9..000000000000 --- a/sdk/resourcemanager/security/armsecurity/connectorapplication_client_example_test.go +++ /dev/null @@ -1,89 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. - -package armsecurity_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2022-07-01-preview/examples/Applications/GetSecurityConnectorApplication_example.json -func ExampleConnectorApplicationClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewConnectorApplicationClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "gcpResourceGroup", "gcpconnector", "ad9a8e26-29d9-4829-bb30-e597a58cdbb8", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2022-07-01-preview/examples/Applications/PutSecurityConnectorApplication_example.json -func ExampleConnectorApplicationClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewConnectorApplicationClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdate(ctx, "gcpResourceGroup", "gcpconnector", "ad9a8e26-29d9-4829-bb30-e597a58cdbb8", armsecurity.Application{ - Properties: &armsecurity.ApplicationProperties{ - Description: to.Ptr("An application on critical GCP recommendations"), - ConditionSets: []interface{}{ - map[string]interface{}{ - "conditions": []interface{}{ - map[string]interface{}{ - "operator": "contains", - "property": "$.Id", - "value": "-prod-", - }, - }, - }}, - DisplayName: to.Ptr("GCP Admin's application"), - SourceResourceType: to.Ptr(armsecurity.ApplicationSourceResourceTypeAssessments), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2022-07-01-preview/examples/Applications/DeleteSecurityConnectorApplication_example.json -func ExampleConnectorApplicationClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewConnectorApplicationClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, "gcpResourceGroup", "gcpconnector", "ad9a8e26-29d9-4829-bb30-e597a58cdbb8", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/security/armsecurity/connectorapplications_client.go b/sdk/resourcemanager/security/armsecurity/connectorapplications_client.go index 91eb858bd1ba..57d1974c93d2 100644 --- a/sdk/resourcemanager/security/armsecurity/connectorapplications_client.go +++ b/sdk/resourcemanager/security/armsecurity/connectorapplications_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,41 +24,33 @@ import ( // ConnectorApplicationsClient contains the methods for the SecurityConnectorApplications group. // Don't use this type directly, use NewConnectorApplicationsClient() instead. type ConnectorApplicationsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewConnectorApplicationsClient creates a new instance of ConnectorApplicationsClient with the specified values. -// subscriptionID - Azure subscription ID -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure subscription ID +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewConnectorApplicationsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ConnectorApplicationsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".ConnectorApplicationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ConnectorApplicationsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListPager - Get a list of all relevant applications over a security connector level scope +// // Generated from API version 2022-07-01-preview -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// securityConnectorName - The security connector name. -// options - ConnectorApplicationsClientListOptions contains the optional parameters for the ConnectorApplicationsClient.List -// method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - securityConnectorName - The security connector name. +// - options - ConnectorApplicationsClientListOptions contains the optional parameters for the ConnectorApplicationsClient.NewListPager +// method. func (client *ConnectorApplicationsClient) NewListPager(resourceGroupName string, securityConnectorName string, options *ConnectorApplicationsClientListOptions) *runtime.Pager[ConnectorApplicationsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[ConnectorApplicationsClientListResponse]{ More: func(page ConnectorApplicationsClientListResponse) bool { @@ -77,7 +67,7 @@ func (client *ConnectorApplicationsClient) NewListPager(resourceGroupName string if err != nil { return ConnectorApplicationsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ConnectorApplicationsClientListResponse{}, err } @@ -104,7 +94,7 @@ func (client *ConnectorApplicationsClient) listCreateRequest(ctx context.Context return nil, errors.New("parameter securityConnectorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{securityConnectorName}", url.PathEscape(securityConnectorName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/security/armsecurity/connectorapplications_client_example_test.go b/sdk/resourcemanager/security/armsecurity/connectorapplications_client_example_test.go deleted file mode 100644 index 8275aaff3b2c..000000000000 --- a/sdk/resourcemanager/security/armsecurity/connectorapplications_client_example_test.go +++ /dev/null @@ -1,41 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. - -package armsecurity_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2022-07-01-preview/examples/Applications/ListBySecurityConnectorApplications_example.json -func ExampleConnectorApplicationsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewConnectorApplicationsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("gcpResourceGroup", "gcpconnector", nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/security/armsecurity/connectorgovernancerule_client.go b/sdk/resourcemanager/security/armsecurity/connectorgovernancerule_client.go deleted file mode 100644 index c0fb53be63e9..000000000000 --- a/sdk/resourcemanager/security/armsecurity/connectorgovernancerule_client.go +++ /dev/null @@ -1,125 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. -// DO NOT EDIT. - -package armsecurity - -import ( - "context" - "errors" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" - "net/url" - "strings" -) - -// ConnectorGovernanceRuleClient contains the methods for the SecurityConnectorGovernanceRule group. -// Don't use this type directly, use NewConnectorGovernanceRuleClient() instead. -type ConnectorGovernanceRuleClient struct { - host string - subscriptionID string - pl runtime.Pipeline -} - -// NewConnectorGovernanceRuleClient creates a new instance of ConnectorGovernanceRuleClient with the specified values. -// subscriptionID - Azure subscription ID -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. -func NewConnectorGovernanceRuleClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ConnectorGovernanceRuleClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) - if err != nil { - return nil, err - } - client := &ConnectorGovernanceRuleClient{ - subscriptionID: subscriptionID, - host: ep, - pl: pl, - } - return client, nil -} - -// NewListPager - Get a list of all relevant governanceRules over a security connector level scope -// Generated from API version 2022-01-01-preview -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// securityConnectorName - The security connector name. -// options - ConnectorGovernanceRuleClientListOptions contains the optional parameters for the ConnectorGovernanceRuleClient.List -// method. -func (client *ConnectorGovernanceRuleClient) NewListPager(resourceGroupName string, securityConnectorName string, options *ConnectorGovernanceRuleClientListOptions) *runtime.Pager[ConnectorGovernanceRuleClientListResponse] { - return runtime.NewPager(runtime.PagingHandler[ConnectorGovernanceRuleClientListResponse]{ - More: func(page ConnectorGovernanceRuleClientListResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *ConnectorGovernanceRuleClientListResponse) (ConnectorGovernanceRuleClientListResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listCreateRequest(ctx, resourceGroupName, securityConnectorName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) - } - if err != nil { - return ConnectorGovernanceRuleClientListResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return ConnectorGovernanceRuleClientListResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ConnectorGovernanceRuleClientListResponse{}, runtime.NewResponseError(resp) - } - return client.listHandleResponse(resp) - }, - }) -} - -// listCreateRequest creates the List request. -func (client *ConnectorGovernanceRuleClient) listCreateRequest(ctx context.Context, resourceGroupName string, securityConnectorName string, options *ConnectorGovernanceRuleClientListOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/providers/Microsoft.Security/governanceRules" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if securityConnectorName == "" { - return nil, errors.New("parameter securityConnectorName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{securityConnectorName}", url.PathEscape(securityConnectorName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listHandleResponse handles the List response. -func (client *ConnectorGovernanceRuleClient) listHandleResponse(resp *http.Response) (ConnectorGovernanceRuleClientListResponse, error) { - result := ConnectorGovernanceRuleClientListResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.GovernanceRuleList); err != nil { - return ConnectorGovernanceRuleClientListResponse{}, err - } - return result, nil -} diff --git a/sdk/resourcemanager/security/armsecurity/connectorgovernancerule_client_example_test.go b/sdk/resourcemanager/security/armsecurity/connectorgovernancerule_client_example_test.go deleted file mode 100644 index c76ebbe2b505..000000000000 --- a/sdk/resourcemanager/security/armsecurity/connectorgovernancerule_client_example_test.go +++ /dev/null @@ -1,41 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. - -package armsecurity_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/ListBySecurityConnectorGovernanceRules_example.json -func ExampleConnectorGovernanceRuleClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewConnectorGovernanceRuleClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("gcpResourceGroup", "gcpconnector", nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/security/armsecurity/connectorgovernancerules_client.go b/sdk/resourcemanager/security/armsecurity/connectorgovernancerules_client.go deleted file mode 100644 index 142381cac5e5..000000000000 --- a/sdk/resourcemanager/security/armsecurity/connectorgovernancerules_client.go +++ /dev/null @@ -1,233 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. -// DO NOT EDIT. - -package armsecurity - -import ( - "context" - "errors" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" - "net/url" - "strings" -) - -// ConnectorGovernanceRulesClient contains the methods for the SecurityConnectorGovernanceRules group. -// Don't use this type directly, use NewConnectorGovernanceRulesClient() instead. -type ConnectorGovernanceRulesClient struct { - host string - subscriptionID string - pl runtime.Pipeline -} - -// NewConnectorGovernanceRulesClient creates a new instance of ConnectorGovernanceRulesClient with the specified values. -// subscriptionID - Azure subscription ID -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. -func NewConnectorGovernanceRulesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ConnectorGovernanceRulesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) - if err != nil { - return nil, err - } - client := &ConnectorGovernanceRulesClient{ - subscriptionID: subscriptionID, - host: ep, - pl: pl, - } - return client, nil -} - -// CreateOrUpdate - Creates or update a security GovernanceRule on the given security connector. -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-01-01-preview -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// securityConnectorName - The security connector name. -// ruleID - The security GovernanceRule key - unique key for the standard GovernanceRule -// governanceRule - GovernanceRule over a subscription scope -// options - ConnectorGovernanceRulesClientCreateOrUpdateOptions contains the optional parameters for the ConnectorGovernanceRulesClient.CreateOrUpdate -// method. -func (client *ConnectorGovernanceRulesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, securityConnectorName string, ruleID string, governanceRule GovernanceRule, options *ConnectorGovernanceRulesClientCreateOrUpdateOptions) (ConnectorGovernanceRulesClientCreateOrUpdateResponse, error) { - req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, securityConnectorName, ruleID, governanceRule, options) - if err != nil { - return ConnectorGovernanceRulesClientCreateOrUpdateResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return ConnectorGovernanceRulesClientCreateOrUpdateResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return ConnectorGovernanceRulesClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) - } - return client.createOrUpdateHandleResponse(resp) -} - -// createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *ConnectorGovernanceRulesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, securityConnectorName string, ruleID string, governanceRule GovernanceRule, options *ConnectorGovernanceRulesClientCreateOrUpdateOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/providers/Microsoft.Security/governanceRules/{ruleId}" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if securityConnectorName == "" { - return nil, errors.New("parameter securityConnectorName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{securityConnectorName}", url.PathEscape(securityConnectorName)) - if ruleID == "" { - return nil, errors.New("parameter ruleID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{ruleId}", url.PathEscape(ruleID)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, governanceRule) -} - -// createOrUpdateHandleResponse handles the CreateOrUpdate response. -func (client *ConnectorGovernanceRulesClient) createOrUpdateHandleResponse(resp *http.Response) (ConnectorGovernanceRulesClientCreateOrUpdateResponse, error) { - result := ConnectorGovernanceRulesClientCreateOrUpdateResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.GovernanceRule); err != nil { - return ConnectorGovernanceRulesClientCreateOrUpdateResponse{}, err - } - return result, nil -} - -// Delete - Delete a GovernanceRule over a given scope -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-01-01-preview -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// securityConnectorName - The security connector name. -// ruleID - The security GovernanceRule key - unique key for the standard GovernanceRule -// options - ConnectorGovernanceRulesClientDeleteOptions contains the optional parameters for the ConnectorGovernanceRulesClient.Delete -// method. -func (client *ConnectorGovernanceRulesClient) Delete(ctx context.Context, resourceGroupName string, securityConnectorName string, ruleID string, options *ConnectorGovernanceRulesClientDeleteOptions) (ConnectorGovernanceRulesClientDeleteResponse, error) { - req, err := client.deleteCreateRequest(ctx, resourceGroupName, securityConnectorName, ruleID, options) - if err != nil { - return ConnectorGovernanceRulesClientDeleteResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return ConnectorGovernanceRulesClientDeleteResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { - return ConnectorGovernanceRulesClientDeleteResponse{}, runtime.NewResponseError(resp) - } - return ConnectorGovernanceRulesClientDeleteResponse{}, nil -} - -// deleteCreateRequest creates the Delete request. -func (client *ConnectorGovernanceRulesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, securityConnectorName string, ruleID string, options *ConnectorGovernanceRulesClientDeleteOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/providers/Microsoft.Security/governanceRules/{ruleId}" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if securityConnectorName == "" { - return nil, errors.New("parameter securityConnectorName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{securityConnectorName}", url.PathEscape(securityConnectorName)) - if ruleID == "" { - return nil, errors.New("parameter ruleID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{ruleId}", url.PathEscape(ruleID)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - return req, nil -} - -// Get - Get a specific governanceRule for the requested scope by ruleId -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-01-01-preview -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// securityConnectorName - The security connector name. -// ruleID - The security GovernanceRule key - unique key for the standard GovernanceRule -// options - ConnectorGovernanceRulesClientGetOptions contains the optional parameters for the ConnectorGovernanceRulesClient.Get -// method. -func (client *ConnectorGovernanceRulesClient) Get(ctx context.Context, resourceGroupName string, securityConnectorName string, ruleID string, options *ConnectorGovernanceRulesClientGetOptions) (ConnectorGovernanceRulesClientGetResponse, error) { - req, err := client.getCreateRequest(ctx, resourceGroupName, securityConnectorName, ruleID, options) - if err != nil { - return ConnectorGovernanceRulesClientGetResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return ConnectorGovernanceRulesClientGetResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ConnectorGovernanceRulesClientGetResponse{}, runtime.NewResponseError(resp) - } - return client.getHandleResponse(resp) -} - -// getCreateRequest creates the Get request. -func (client *ConnectorGovernanceRulesClient) getCreateRequest(ctx context.Context, resourceGroupName string, securityConnectorName string, ruleID string, options *ConnectorGovernanceRulesClientGetOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/providers/Microsoft.Security/governanceRules/{ruleId}" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if securityConnectorName == "" { - return nil, errors.New("parameter securityConnectorName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{securityConnectorName}", url.PathEscape(securityConnectorName)) - if ruleID == "" { - return nil, errors.New("parameter ruleID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{ruleId}", url.PathEscape(ruleID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// getHandleResponse handles the Get response. -func (client *ConnectorGovernanceRulesClient) getHandleResponse(resp *http.Response) (ConnectorGovernanceRulesClientGetResponse, error) { - result := ConnectorGovernanceRulesClientGetResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.GovernanceRule); err != nil { - return ConnectorGovernanceRulesClientGetResponse{}, err - } - return result, nil -} diff --git a/sdk/resourcemanager/security/armsecurity/connectorgovernancerules_client_example_test.go b/sdk/resourcemanager/security/armsecurity/connectorgovernancerules_client_example_test.go deleted file mode 100644 index 03efeb59a645..000000000000 --- a/sdk/resourcemanager/security/armsecurity/connectorgovernancerules_client_example_test.go +++ /dev/null @@ -1,102 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. - -package armsecurity_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/GetSecurityConnectorGovernanceRule_example.json -func ExampleConnectorGovernanceRulesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewConnectorGovernanceRulesClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "gcpResourceGroup", "gcpconnector", "ad9a8e26-29d9-4829-bb30-e597a58cdbb8", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/PutSecurityConnectorGovernanceRule_example.json -func ExampleConnectorGovernanceRulesClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewConnectorGovernanceRulesClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdate(ctx, "gcpResourceGroup", "gcpconnector", "ad9a8e26-29d9-4829-bb30-e597a58cdbb8", armsecurity.GovernanceRule{ - Properties: &armsecurity.GovernanceRuleProperties{ - Description: to.Ptr("A rule on critical GCP recommendations"), - ConditionSets: []interface{}{ - map[string]interface{}{ - "conditions": []interface{}{ - map[string]interface{}{ - "operator": "In", - "property": "$.AssessmentKey", - "value": "[\"b1cd27e0-4ecc-4246-939f-49c426d9d72f\", \"fe83f80b-073d-4ccf-93d9-6797eb870201\"]", - }, - }, - }}, - DisplayName: to.Ptr("GCP Admin's rule"), - GovernanceEmailNotification: &armsecurity.GovernanceRuleEmailNotification{ - DisableManagerEmailNotification: to.Ptr(true), - DisableOwnerEmailNotification: to.Ptr(false), - }, - IsDisabled: to.Ptr(false), - IsGracePeriod: to.Ptr(true), - OwnerSource: &armsecurity.GovernanceRuleOwnerSource{ - Type: to.Ptr(armsecurity.GovernanceRuleOwnerSourceTypeManually), - Value: to.Ptr("user@contoso.com"), - }, - RemediationTimeframe: to.Ptr("7.00:00:00"), - RulePriority: to.Ptr[int32](200), - RuleType: to.Ptr(armsecurity.GovernanceRuleTypeIntegrated), - SourceResourceType: to.Ptr(armsecurity.GovernanceRuleSourceResourceTypeAssessments), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/DeleteSecurityConnectorGovernanceRule_example.json -func ExampleConnectorGovernanceRulesClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewConnectorGovernanceRulesClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, "gcpResourceGroup", "gcpconnector", "ad9a8e26-29d9-4829-bb30-e597a58cdbb8", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/security/armsecurity/connectorgovernancerulesexecutestatus_client.go b/sdk/resourcemanager/security/armsecurity/connectorgovernancerulesexecutestatus_client.go deleted file mode 100644 index 1183625ebaef..000000000000 --- a/sdk/resourcemanager/security/armsecurity/connectorgovernancerulesexecutestatus_client.go +++ /dev/null @@ -1,129 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. -// DO NOT EDIT. - -package armsecurity - -import ( - "context" - "errors" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" - "net/url" - "strings" -) - -// ConnectorGovernanceRulesExecuteStatusClient contains the methods for the SecurityConnectorGovernanceRulesExecuteStatus group. -// Don't use this type directly, use NewConnectorGovernanceRulesExecuteStatusClient() instead. -type ConnectorGovernanceRulesExecuteStatusClient struct { - host string - subscriptionID string - pl runtime.Pipeline -} - -// NewConnectorGovernanceRulesExecuteStatusClient creates a new instance of ConnectorGovernanceRulesExecuteStatusClient with the specified values. -// subscriptionID - Azure subscription ID -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. -func NewConnectorGovernanceRulesExecuteStatusClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ConnectorGovernanceRulesExecuteStatusClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) - if err != nil { - return nil, err - } - client := &ConnectorGovernanceRulesExecuteStatusClient{ - subscriptionID: subscriptionID, - host: ep, - pl: pl, - } - return client, nil -} - -// BeginGet - Get a specific governanceRule execution status for the requested scope by ruleId and operationId -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-01-01-preview -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// securityConnectorName - The security connector name. -// ruleID - The security GovernanceRule key - unique key for the standard GovernanceRule -// operationID - The security GovernanceRule execution key - unique key for the execution of GovernanceRule -// options - ConnectorGovernanceRulesExecuteStatusClientBeginGetOptions contains the optional parameters for the ConnectorGovernanceRulesExecuteStatusClient.BeginGet -// method. -func (client *ConnectorGovernanceRulesExecuteStatusClient) BeginGet(ctx context.Context, resourceGroupName string, securityConnectorName string, ruleID string, operationID string, options *ConnectorGovernanceRulesExecuteStatusClientBeginGetOptions) (*runtime.Poller[ConnectorGovernanceRulesExecuteStatusClientGetResponse], error) { - if options == nil || options.ResumeToken == "" { - resp, err := client.get(ctx, resourceGroupName, securityConnectorName, ruleID, operationID, options) - if err != nil { - return nil, err - } - return runtime.NewPoller[ConnectorGovernanceRulesExecuteStatusClientGetResponse](resp, client.pl, nil) - } else { - return runtime.NewPollerFromResumeToken[ConnectorGovernanceRulesExecuteStatusClientGetResponse](options.ResumeToken, client.pl, nil) - } -} - -// Get - Get a specific governanceRule execution status for the requested scope by ruleId and operationId -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-01-01-preview -func (client *ConnectorGovernanceRulesExecuteStatusClient) get(ctx context.Context, resourceGroupName string, securityConnectorName string, ruleID string, operationID string, options *ConnectorGovernanceRulesExecuteStatusClientBeginGetOptions) (*http.Response, error) { - req, err := client.getCreateRequest(ctx, resourceGroupName, securityConnectorName, ruleID, operationID, options) - if err != nil { - return nil, err - } - resp, err := client.pl.Do(req) - if err != nil { - return nil, err - } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) - } - return resp, nil -} - -// getCreateRequest creates the Get request. -func (client *ConnectorGovernanceRulesExecuteStatusClient) getCreateRequest(ctx context.Context, resourceGroupName string, securityConnectorName string, ruleID string, operationID string, options *ConnectorGovernanceRulesExecuteStatusClientBeginGetOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/providers/Microsoft.Security/governanceRules/{ruleId}/operationResults/{operationId}" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if securityConnectorName == "" { - return nil, errors.New("parameter securityConnectorName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{securityConnectorName}", url.PathEscape(securityConnectorName)) - if ruleID == "" { - return nil, errors.New("parameter ruleID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{ruleId}", url.PathEscape(ruleID)) - if operationID == "" { - return nil, errors.New("parameter operationID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} diff --git a/sdk/resourcemanager/security/armsecurity/connectorgovernancerulesexecutestatus_client_example_test.go b/sdk/resourcemanager/security/armsecurity/connectorgovernancerulesexecutestatus_client_example_test.go deleted file mode 100644 index cdc322f86875..000000000000 --- a/sdk/resourcemanager/security/armsecurity/connectorgovernancerulesexecutestatus_client_example_test.go +++ /dev/null @@ -1,40 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. - -package armsecurity_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/GetSecurityConnectorGovernanceRuleExecuteStatus_example.json -func ExampleConnectorGovernanceRulesExecuteStatusClient_BeginGet() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewConnectorGovernanceRulesExecuteStatusClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginGet(ctx, "gcpResourceGroup", "gcpconnector", "ad9a8e26-29d9-4829-bb30-e597a58cdbb8", "58b33f4f-c8c7-4b01-99cc-d437db4d40dd", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/security/armsecurity/connectors_client.go b/sdk/resourcemanager/security/armsecurity/connectors_client.go index 8a435d88f991..b9be8a328758 100644 --- a/sdk/resourcemanager/security/armsecurity/connectors_client.go +++ b/sdk/resourcemanager/security/armsecurity/connectors_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,31 +24,22 @@ import ( // ConnectorsClient contains the methods for the SecurityConnectors group. // Don't use this type directly, use NewConnectorsClient() instead. type ConnectorsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewConnectorsClient creates a new instance of ConnectorsClient with the specified values. -// subscriptionID - Azure subscription ID -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure subscription ID +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewConnectorsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ConnectorsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".ConnectorsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ConnectorsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -58,18 +47,19 @@ func NewConnectorsClient(subscriptionID string, credential azcore.TokenCredentia // CreateOrUpdate - Creates or updates a security connector. If a security connector is already created and a subsequent request // is issued for the same security connector id, then it will be updated. // If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-08-01-preview -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// securityConnectorName - The security connector name. -// securityConnector - The security connector resource -// options - ConnectorsClientCreateOrUpdateOptions contains the optional parameters for the ConnectorsClient.CreateOrUpdate -// method. +// +// Generated from API version 2023-03-01-preview +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - securityConnectorName - The security connector name. +// - securityConnector - The security connector resource +// - options - ConnectorsClientCreateOrUpdateOptions contains the optional parameters for the ConnectorsClient.CreateOrUpdate +// method. func (client *ConnectorsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, securityConnectorName string, securityConnector Connector, options *ConnectorsClientCreateOrUpdateOptions) (ConnectorsClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, securityConnectorName, securityConnector, options) if err != nil { return ConnectorsClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ConnectorsClientCreateOrUpdateResponse{}, err } @@ -94,12 +84,12 @@ func (client *ConnectorsClient) createOrUpdateCreateRequest(ctx context.Context, return nil, errors.New("parameter securityConnectorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{securityConnectorName}", url.PathEscape(securityConnectorName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, runtime.MarshalAsJSON(req, securityConnector) @@ -116,16 +106,17 @@ func (client *ConnectorsClient) createOrUpdateHandleResponse(resp *http.Response // Delete - Deletes a security connector. // If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-08-01-preview -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// securityConnectorName - The security connector name. -// options - ConnectorsClientDeleteOptions contains the optional parameters for the ConnectorsClient.Delete method. +// +// Generated from API version 2023-03-01-preview +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - securityConnectorName - The security connector name. +// - options - ConnectorsClientDeleteOptions contains the optional parameters for the ConnectorsClient.Delete method. func (client *ConnectorsClient) Delete(ctx context.Context, resourceGroupName string, securityConnectorName string, options *ConnectorsClientDeleteOptions) (ConnectorsClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, securityConnectorName, options) if err != nil { return ConnectorsClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ConnectorsClientDeleteResponse{}, err } @@ -150,12 +141,12 @@ func (client *ConnectorsClient) deleteCreateRequest(ctx context.Context, resourc return nil, errors.New("parameter securityConnectorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{securityConnectorName}", url.PathEscape(securityConnectorName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -163,16 +154,17 @@ func (client *ConnectorsClient) deleteCreateRequest(ctx context.Context, resourc // Get - Retrieves details of a specific security connector // If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-08-01-preview -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// securityConnectorName - The security connector name. -// options - ConnectorsClientGetOptions contains the optional parameters for the ConnectorsClient.Get method. +// +// Generated from API version 2023-03-01-preview +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - securityConnectorName - The security connector name. +// - options - ConnectorsClientGetOptions contains the optional parameters for the ConnectorsClient.Get method. func (client *ConnectorsClient) Get(ctx context.Context, resourceGroupName string, securityConnectorName string, options *ConnectorsClientGetOptions) (ConnectorsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, securityConnectorName, options) if err != nil { return ConnectorsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ConnectorsClientGetResponse{}, err } @@ -197,12 +189,12 @@ func (client *ConnectorsClient) getCreateRequest(ctx context.Context, resourceGr return nil, errors.New("parameter securityConnectorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{securityConnectorName}", url.PathEscape(securityConnectorName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -219,8 +211,9 @@ func (client *ConnectorsClient) getHandleResponse(resp *http.Response) (Connecto // NewListPager - Lists all the security connectors in the specified subscription. Use the 'nextLink' property in the response // to get the next page of security connectors for the specified subscription. -// Generated from API version 2022-08-01-preview -// options - ConnectorsClientListOptions contains the optional parameters for the ConnectorsClient.List method. +// +// Generated from API version 2023-03-01-preview +// - options - ConnectorsClientListOptions contains the optional parameters for the ConnectorsClient.NewListPager method. func (client *ConnectorsClient) NewListPager(options *ConnectorsClientListOptions) *runtime.Pager[ConnectorsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[ConnectorsClientListResponse]{ More: func(page ConnectorsClientListResponse) bool { @@ -237,7 +230,7 @@ func (client *ConnectorsClient) NewListPager(options *ConnectorsClientListOption if err != nil { return ConnectorsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ConnectorsClientListResponse{}, err } @@ -256,12 +249,12 @@ func (client *ConnectorsClient) listCreateRequest(ctx context.Context, options * return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -278,10 +271,11 @@ func (client *ConnectorsClient) listHandleResponse(resp *http.Response) (Connect // NewListByResourceGroupPager - Lists all the security connectors in the specified resource group. Use the 'nextLink' property // in the response to get the next page of security connectors for the specified resource group. -// Generated from API version 2022-08-01-preview -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// options - ConnectorsClientListByResourceGroupOptions contains the optional parameters for the ConnectorsClient.ListByResourceGroup -// method. +// +// Generated from API version 2023-03-01-preview +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - options - ConnectorsClientListByResourceGroupOptions contains the optional parameters for the ConnectorsClient.NewListByResourceGroupPager +// method. func (client *ConnectorsClient) NewListByResourceGroupPager(resourceGroupName string, options *ConnectorsClientListByResourceGroupOptions) *runtime.Pager[ConnectorsClientListByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[ConnectorsClientListByResourceGroupResponse]{ More: func(page ConnectorsClientListByResourceGroupResponse) bool { @@ -298,7 +292,7 @@ func (client *ConnectorsClient) NewListByResourceGroupPager(resourceGroupName st if err != nil { return ConnectorsClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ConnectorsClientListByResourceGroupResponse{}, err } @@ -321,12 +315,12 @@ func (client *ConnectorsClient) listByResourceGroupCreateRequest(ctx context.Con return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -343,17 +337,18 @@ func (client *ConnectorsClient) listByResourceGroupHandleResponse(resp *http.Res // Update - Updates a security connector // If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-08-01-preview -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// securityConnectorName - The security connector name. -// securityConnector - The security connector resource -// options - ConnectorsClientUpdateOptions contains the optional parameters for the ConnectorsClient.Update method. +// +// Generated from API version 2023-03-01-preview +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - securityConnectorName - The security connector name. +// - securityConnector - The security connector resource +// - options - ConnectorsClientUpdateOptions contains the optional parameters for the ConnectorsClient.Update method. func (client *ConnectorsClient) Update(ctx context.Context, resourceGroupName string, securityConnectorName string, securityConnector Connector, options *ConnectorsClientUpdateOptions) (ConnectorsClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, securityConnectorName, securityConnector, options) if err != nil { return ConnectorsClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ConnectorsClientUpdateResponse{}, err } @@ -378,12 +373,12 @@ func (client *ConnectorsClient) updateCreateRequest(ctx context.Context, resourc return nil, errors.New("parameter securityConnectorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{securityConnectorName}", url.PathEscape(securityConnectorName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, runtime.MarshalAsJSON(req, securityConnector) diff --git a/sdk/resourcemanager/security/armsecurity/connectors_client_example_test.go b/sdk/resourcemanager/security/armsecurity/connectors_client_example_test.go deleted file mode 100644 index 0183a2fdfe71..000000000000 --- a/sdk/resourcemanager/security/armsecurity/connectors_client_example_test.go +++ /dev/null @@ -1,176 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. - -package armsecurity_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2022-08-01-preview/examples/SecurityConnectors/GetSecurityConnectorsSubscription_example.json -func ExampleConnectorsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewConnectorsClient("a5caac9c-5c04-49af-b3d0-e204f40345d5", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2022-08-01-preview/examples/SecurityConnectors/GetSecurityConnectorsResourceGroup_example.json -func ExampleConnectorsClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewConnectorsClient("a5caac9c-5c04-49af-b3d0-e204f40345d5", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByResourceGroupPager("exampleResourceGroup", nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2022-08-01-preview/examples/SecurityConnectors/GetSecurityConnectorSingleResource_example.json -func ExampleConnectorsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewConnectorsClient("a5caac9c-5c04-49af-b3d0-e204f40345d5", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "exampleResourceGroup", "exampleSecurityConnectorName", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2022-08-01-preview/examples/SecurityConnectors/PutSecurityConnector_example.json -func ExampleConnectorsClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewConnectorsClient("a5caac9c-5c04-49af-b3d0-e204f40345d5", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdate(ctx, "exampleResourceGroup", "exampleSecurityConnectorName", armsecurity.Connector{ - Location: to.Ptr("Central US"), - Etag: to.Ptr("etag value (must be supplied for update)"), - Tags: map[string]*string{}, - Properties: &armsecurity.ConnectorProperties{ - EnvironmentData: &armsecurity.AwsEnvironmentData{ - EnvironmentType: to.Ptr(armsecurity.EnvironmentTypeAwsAccount), - }, - EnvironmentName: to.Ptr(armsecurity.CloudNameAWS), - HierarchyIdentifier: to.Ptr("exampleHierarchyId"), - Offerings: []armsecurity.CloudOfferingClassification{ - &armsecurity.CspmMonitorAwsOffering{ - OfferingType: to.Ptr(armsecurity.OfferingTypeCspmMonitorAws), - NativeCloudConnection: &armsecurity.CspmMonitorAwsOfferingNativeCloudConnection{ - CloudRoleArn: to.Ptr("arn:aws:iam::00000000:role/ASCMonitor"), - }, - }}, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2022-08-01-preview/examples/SecurityConnectors/PatchSecurityConnector_example.json -func ExampleConnectorsClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewConnectorsClient("a5caac9c-5c04-49af-b3d0-e204f40345d5", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Update(ctx, "exampleResourceGroup", "exampleSecurityConnectorName", armsecurity.Connector{ - Location: to.Ptr("Central US"), - Etag: to.Ptr("etag value (must be supplied for update)"), - Tags: map[string]*string{}, - Properties: &armsecurity.ConnectorProperties{ - EnvironmentData: &armsecurity.AwsEnvironmentData{ - EnvironmentType: to.Ptr(armsecurity.EnvironmentTypeAwsAccount), - }, - EnvironmentName: to.Ptr(armsecurity.CloudNameAWS), - HierarchyIdentifier: to.Ptr("exampleHierarchyId"), - Offerings: []armsecurity.CloudOfferingClassification{ - &armsecurity.CspmMonitorAwsOffering{ - OfferingType: to.Ptr(armsecurity.OfferingTypeCspmMonitorAws), - NativeCloudConnection: &armsecurity.CspmMonitorAwsOfferingNativeCloudConnection{ - CloudRoleArn: to.Ptr("arn:aws:iam::00000000:role/ASCMonitor"), - }, - }}, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2022-08-01-preview/examples/SecurityConnectors/DeleteSecurityConnector_example.json -func ExampleConnectorsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewConnectorsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, "myRg", "mySecurityConnectorName", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/security/armsecurity/constants.go b/sdk/resourcemanager/security/armsecurity/constants.go index 8f1ef25f8fc1..ac3ded6d8a24 100644 --- a/sdk/resourcemanager/security/armsecurity/constants.go +++ b/sdk/resourcemanager/security/armsecurity/constants.go @@ -11,7 +11,7 @@ package armsecurity const ( moduleName = "armsecurity" - moduleVersion = "v0.9.0" + moduleVersion = "v0.10.0" ) // AADConnectivityState - The connectivity state of the external AAD solution @@ -381,6 +381,7 @@ const ( CloudNameAzure CloudName = "Azure" CloudNameAzureDevOps CloudName = "AzureDevOps" CloudNameGCP CloudName = "GCP" + CloudNameGitLab CloudName = "GitLab" CloudNameGithub CloudName = "Github" ) @@ -391,10 +392,29 @@ func PossibleCloudNameValues() []CloudName { CloudNameAzure, CloudNameAzureDevOps, CloudNameGCP, + CloudNameGitLab, CloudNameGithub, } } +// Code - The operation status code. +type Code string + +const ( + // CodeFailed - Extension was not created/updated successfully. See operation status message for more details. + CodeFailed Code = "Failed" + // CodeSucceeded - Extension was created/updated successfully. + CodeSucceeded Code = "Succeeded" +) + +// PossibleCodeValues returns the possible values for the Code const type. +func PossibleCodeValues() []Code { + return []Code{ + CodeFailed, + CodeSucceeded, + } +} + // ConfigurationStatus - The configuration status of the machines group or machine or rule type ConfigurationStatus string @@ -566,6 +586,7 @@ const ( EnvironmentTypeAzureDevOpsScope EnvironmentType = "AzureDevOpsScope" EnvironmentTypeGcpProject EnvironmentType = "GcpProject" EnvironmentTypeGithubScope EnvironmentType = "GithubScope" + EnvironmentTypeGitlabScope EnvironmentType = "GitlabScope" ) // PossibleEnvironmentTypeValues returns the possible values for the EnvironmentType const type. @@ -575,6 +596,7 @@ func PossibleEnvironmentTypeValues() []EnvironmentType { EnvironmentTypeAzureDevOpsScope, EnvironmentTypeGcpProject, EnvironmentTypeGithubScope, + EnvironmentTypeGitlabScope, } } @@ -901,6 +923,24 @@ func PossibleIntentValues() []Intent { } } +// IsEnabled - Indicates whether the extension is enabled. +type IsEnabled string + +const ( + // IsEnabledFalse - Indicates the extension is disabled + IsEnabledFalse IsEnabled = "False" + // IsEnabledTrue - Indicates the extension is enabled + IsEnabledTrue IsEnabled = "True" +) + +// PossibleIsEnabledValues returns the possible values for the IsEnabled const type. +func PossibleIsEnabledValues() []IsEnabled { + return []IsEnabled{ + IsEnabledFalse, + IsEnabledTrue, + } +} + // Kind - The kind of alert simulation. type Kind string @@ -944,6 +984,7 @@ const ( OfferingTypeCspmMonitorAws OfferingType = "CspmMonitorAws" OfferingTypeCspmMonitorAzureDevOps OfferingType = "CspmMonitorAzureDevOps" OfferingTypeCspmMonitorGcp OfferingType = "CspmMonitorGcp" + OfferingTypeCspmMonitorGitLab OfferingType = "CspmMonitorGitLab" OfferingTypeCspmMonitorGithub OfferingType = "CspmMonitorGithub" OfferingTypeDefenderCspmAws OfferingType = "DefenderCspmAws" OfferingTypeDefenderCspmGcp OfferingType = "DefenderCspmGcp" @@ -952,6 +993,7 @@ const ( OfferingTypeDefenderForDatabasesAws OfferingType = "DefenderForDatabasesAws" OfferingTypeDefenderForDatabasesGcp OfferingType = "DefenderForDatabasesGcp" OfferingTypeDefenderForDevOpsAzureDevOps OfferingType = "DefenderForDevOpsAzureDevOps" + OfferingTypeDefenderForDevOpsGitLab OfferingType = "DefenderForDevOpsGitLab" OfferingTypeDefenderForDevOpsGithub OfferingType = "DefenderForDevOpsGithub" OfferingTypeDefenderForServersAws OfferingType = "DefenderForServersAws" OfferingTypeDefenderForServersGcp OfferingType = "DefenderForServersGcp" @@ -964,6 +1006,7 @@ func PossibleOfferingTypeValues() []OfferingType { OfferingTypeCspmMonitorAws, OfferingTypeCspmMonitorAzureDevOps, OfferingTypeCspmMonitorGcp, + OfferingTypeCspmMonitorGitLab, OfferingTypeCspmMonitorGithub, OfferingTypeDefenderCspmAws, OfferingTypeDefenderCspmGcp, @@ -972,6 +1015,7 @@ func PossibleOfferingTypeValues() []OfferingType { OfferingTypeDefenderForDatabasesAws, OfferingTypeDefenderForDatabasesGcp, OfferingTypeDefenderForDevOpsAzureDevOps, + OfferingTypeDefenderForDevOpsGitLab, OfferingTypeDefenderForDevOpsGithub, OfferingTypeDefenderForServersAws, OfferingTypeDefenderForServersGcp, @@ -979,6 +1023,27 @@ func PossibleOfferingTypeValues() []OfferingType { } } +// OperationResult - The status of the long run operation result of governance rule +type OperationResult string + +const ( + // OperationResultCanceled - The operation canceled + OperationResultCanceled OperationResult = "Canceled" + // OperationResultFailed - The operation failed + OperationResultFailed OperationResult = "Failed" + // OperationResultSucceeded - The operation succeeded + OperationResultSucceeded OperationResult = "Succeeded" +) + +// PossibleOperationResultValues returns the possible values for the OperationResult const type. +func PossibleOperationResultValues() []OperationResult { + return []OperationResult{ + OperationResultCanceled, + OperationResultFailed, + OperationResultSucceeded, + } +} + // Operator - A valid comparer operator to use. A case-insensitive comparison will be applied for String PropertyType. type Operator string @@ -1059,9 +1124,9 @@ func PossiblePermissionPropertyValues() []PermissionProperty { } } -// PricingTier - The pricing tier value. Microsoft Defender for Cloud is provided in two pricing tiers: free and standard, -// with the standard tier available with a trial period. The standard tier offers advanced -// security capabilities, while the free tier offers basic security features. +// PricingTier - The pricing tier value. Microsoft Defender for Cloud is provided in two pricing tiers: free and standard. +// The standard tier offers advanced security capabilities, while the free tier offers basic +// security features. type PricingTier string const ( @@ -1500,7 +1565,7 @@ func PossibleScanTriggerTypeValues() []ScanTriggerType { } } -// ScanningMode - The scanning mode for the vm scan. +// ScanningMode - The scanning mode for the VM scan. type ScanningMode string const ( @@ -1514,6 +1579,26 @@ func PossibleScanningModeValues() []ScanningMode { } } +// ScopeName - The resource scope of the health report +type ScopeName string + +const ( + ScopeNameClusters ScopeName = "Clusters" + ScopeNameConnectors ScopeName = "Connectors" + ScopeNameUnknown ScopeName = "Unknown" + ScopeNameVirtualMachines ScopeName = "VirtualMachines" +) + +// PossibleScopeNameValues returns the possible values for the ScopeName const type. +func PossibleScopeNameValues() []ScopeName { + return []ScopeName{ + ScopeNameClusters, + ScopeNameConnectors, + ScopeNameUnknown, + ScopeNameVirtualMachines, + } +} + // SecurityFamily - The security family of the discovered solution type SecurityFamily string @@ -1731,6 +1816,24 @@ func PossibleStatusValues() []Status { } } +// StatusName - The status of the health report +type StatusName string + +const ( + StatusNameHealthy StatusName = "Healthy" + StatusNameNotApplicable StatusName = "NotApplicable" + StatusNameNotHealthy StatusName = "NotHealthy" +) + +// PossibleStatusNameValues returns the possible values for the StatusName const type. +func PossibleStatusNameValues() []StatusName { + return []StatusName{ + StatusNameHealthy, + StatusNameNotApplicable, + StatusNameNotHealthy, + } +} + // StatusReason - A description of why the status has its value type StatusReason string diff --git a/sdk/resourcemanager/security/armsecurity/contacts_client.go b/sdk/resourcemanager/security/armsecurity/contacts_client.go index c5a1de914b3f..76d05611b605 100644 --- a/sdk/resourcemanager/security/armsecurity/contacts_client.go +++ b/sdk/resourcemanager/security/armsecurity/contacts_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,47 +24,39 @@ import ( // ContactsClient contains the methods for the SecurityContacts group. // Don't use this type directly, use NewContactsClient() instead. type ContactsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewContactsClient creates a new instance of ContactsClient with the specified values. -// subscriptionID - Azure subscription ID -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure subscription ID +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewContactsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ContactsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".ContactsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ContactsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Create - Create security contact configurations for the subscription // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-01-01-preview -// securityContactName - Name of the security contact object -// securityContact - Security contact object -// options - ContactsClientCreateOptions contains the optional parameters for the ContactsClient.Create method. +// - securityContactName - Name of the security contact object +// - securityContact - Security contact object +// - options - ContactsClientCreateOptions contains the optional parameters for the ContactsClient.Create method. func (client *ContactsClient) Create(ctx context.Context, securityContactName string, securityContact Contact, options *ContactsClientCreateOptions) (ContactsClientCreateResponse, error) { req, err := client.createCreateRequest(ctx, securityContactName, securityContact, options) if err != nil { return ContactsClientCreateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ContactsClientCreateResponse{}, err } @@ -87,7 +77,7 @@ func (client *ContactsClient) createCreateRequest(ctx context.Context, securityC return nil, errors.New("parameter securityContactName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{securityContactName}", url.PathEscape(securityContactName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -109,15 +99,16 @@ func (client *ContactsClient) createHandleResponse(resp *http.Response) (Contact // Delete - Delete security contact configurations for the subscription // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-01-01-preview -// securityContactName - Name of the security contact object -// options - ContactsClientDeleteOptions contains the optional parameters for the ContactsClient.Delete method. +// - securityContactName - Name of the security contact object +// - options - ContactsClientDeleteOptions contains the optional parameters for the ContactsClient.Delete method. func (client *ContactsClient) Delete(ctx context.Context, securityContactName string, options *ContactsClientDeleteOptions) (ContactsClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, securityContactName, options) if err != nil { return ContactsClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ContactsClientDeleteResponse{}, err } @@ -138,7 +129,7 @@ func (client *ContactsClient) deleteCreateRequest(ctx context.Context, securityC return nil, errors.New("parameter securityContactName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{securityContactName}", url.PathEscape(securityContactName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -151,15 +142,16 @@ func (client *ContactsClient) deleteCreateRequest(ctx context.Context, securityC // Get - Get Default Security contact configurations for the subscription // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-01-01-preview -// securityContactName - Name of the security contact object -// options - ContactsClientGetOptions contains the optional parameters for the ContactsClient.Get method. +// - securityContactName - Name of the security contact object +// - options - ContactsClientGetOptions contains the optional parameters for the ContactsClient.Get method. func (client *ContactsClient) Get(ctx context.Context, securityContactName string, options *ContactsClientGetOptions) (ContactsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, securityContactName, options) if err != nil { return ContactsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ContactsClientGetResponse{}, err } @@ -180,7 +172,7 @@ func (client *ContactsClient) getCreateRequest(ctx context.Context, securityCont return nil, errors.New("parameter securityContactName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{securityContactName}", url.PathEscape(securityContactName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -201,8 +193,9 @@ func (client *ContactsClient) getHandleResponse(resp *http.Response) (ContactsCl } // NewListPager - List all security contact configurations for the subscription +// // Generated from API version 2020-01-01-preview -// options - ContactsClientListOptions contains the optional parameters for the ContactsClient.List method. +// - options - ContactsClientListOptions contains the optional parameters for the ContactsClient.NewListPager method. func (client *ContactsClient) NewListPager(options *ContactsClientListOptions) *runtime.Pager[ContactsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[ContactsClientListResponse]{ More: func(page ContactsClientListResponse) bool { @@ -219,7 +212,7 @@ func (client *ContactsClient) NewListPager(options *ContactsClientListOptions) * if err != nil { return ContactsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ContactsClientListResponse{}, err } @@ -238,7 +231,7 @@ func (client *ContactsClient) listCreateRequest(ctx context.Context, options *Co return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/security/armsecurity/contacts_client_example_test.go b/sdk/resourcemanager/security/armsecurity/contacts_client_example_test.go deleted file mode 100644 index db4a4e4d86f6..000000000000 --- a/sdk/resourcemanager/security/armsecurity/contacts_client_example_test.go +++ /dev/null @@ -1,111 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. - -package armsecurity_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2020-01-01-preview/examples/SecurityContacts/GetSecurityContactsSubscription_example.json -func ExampleContactsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewContactsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2020-01-01-preview/examples/SecurityContacts/GetSecurityContact_example.json -func ExampleContactsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewContactsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "default", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2020-01-01-preview/examples/SecurityContacts/CreateSecurityContact_example.json -func ExampleContactsClient_Create() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewContactsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Create(ctx, "default", armsecurity.Contact{ - Properties: &armsecurity.ContactProperties{ - AlertNotifications: &armsecurity.ContactPropertiesAlertNotifications{ - MinimalSeverity: to.Ptr(armsecurity.MinimalSeverityLow), - State: to.Ptr(armsecurity.State("On")), - }, - Emails: to.Ptr("john@contoso.com;jane@contoso.com"), - NotificationsByRole: &armsecurity.ContactPropertiesNotificationsByRole{ - Roles: []*armsecurity.Roles{ - to.Ptr(armsecurity.RolesOwner)}, - State: to.Ptr(armsecurity.State("On")), - }, - Phone: to.Ptr("(214)275-4038"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2020-01-01-preview/examples/SecurityContacts/DeleteSecurityContact_example.json -func ExampleContactsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewContactsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, "default", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/security/armsecurity/customassessmentautomations_client.go b/sdk/resourcemanager/security/armsecurity/customassessmentautomations_client.go index 4118f564ad4e..1e5e40822e54 100644 --- a/sdk/resourcemanager/security/armsecurity/customassessmentautomations_client.go +++ b/sdk/resourcemanager/security/armsecurity/customassessmentautomations_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,31 +24,22 @@ import ( // CustomAssessmentAutomationsClient contains the methods for the CustomAssessmentAutomations group. // Don't use this type directly, use NewCustomAssessmentAutomationsClient() instead. type CustomAssessmentAutomationsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewCustomAssessmentAutomationsClient creates a new instance of CustomAssessmentAutomationsClient with the specified values. -// subscriptionID - Azure subscription ID -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure subscription ID +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewCustomAssessmentAutomationsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*CustomAssessmentAutomationsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".CustomAssessmentAutomationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &CustomAssessmentAutomationsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -58,18 +47,19 @@ func NewCustomAssessmentAutomationsClient(subscriptionID string, credential azco // Create - Creates or updates a custom assessment automation for the provided subscription. Please note that providing an // existing custom assessment automation will replace the existing record. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-07-01-preview -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// customAssessmentAutomationName - Name of the Custom Assessment Automation. -// customAssessmentAutomationBody - Custom Assessment Automation body -// options - CustomAssessmentAutomationsClientCreateOptions contains the optional parameters for the CustomAssessmentAutomationsClient.Create -// method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - customAssessmentAutomationName - Name of the Custom Assessment Automation. +// - customAssessmentAutomationBody - Custom Assessment Automation body +// - options - CustomAssessmentAutomationsClientCreateOptions contains the optional parameters for the CustomAssessmentAutomationsClient.Create +// method. func (client *CustomAssessmentAutomationsClient) Create(ctx context.Context, resourceGroupName string, customAssessmentAutomationName string, customAssessmentAutomationBody CustomAssessmentAutomationRequest, options *CustomAssessmentAutomationsClientCreateOptions) (CustomAssessmentAutomationsClientCreateResponse, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, customAssessmentAutomationName, customAssessmentAutomationBody, options) if err != nil { return CustomAssessmentAutomationsClientCreateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return CustomAssessmentAutomationsClientCreateResponse{}, err } @@ -94,7 +84,7 @@ func (client *CustomAssessmentAutomationsClient) createCreateRequest(ctx context return nil, errors.New("parameter customAssessmentAutomationName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{customAssessmentAutomationName}", url.PathEscape(customAssessmentAutomationName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -116,17 +106,18 @@ func (client *CustomAssessmentAutomationsClient) createHandleResponse(resp *http // Delete - Deletes a custom assessment automation by name for a provided subscription // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-07-01-preview -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// customAssessmentAutomationName - Name of the Custom Assessment Automation. -// options - CustomAssessmentAutomationsClientDeleteOptions contains the optional parameters for the CustomAssessmentAutomationsClient.Delete -// method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - customAssessmentAutomationName - Name of the Custom Assessment Automation. +// - options - CustomAssessmentAutomationsClientDeleteOptions contains the optional parameters for the CustomAssessmentAutomationsClient.Delete +// method. func (client *CustomAssessmentAutomationsClient) Delete(ctx context.Context, resourceGroupName string, customAssessmentAutomationName string, options *CustomAssessmentAutomationsClientDeleteOptions) (CustomAssessmentAutomationsClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, customAssessmentAutomationName, options) if err != nil { return CustomAssessmentAutomationsClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return CustomAssessmentAutomationsClientDeleteResponse{}, err } @@ -151,7 +142,7 @@ func (client *CustomAssessmentAutomationsClient) deleteCreateRequest(ctx context return nil, errors.New("parameter customAssessmentAutomationName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{customAssessmentAutomationName}", url.PathEscape(customAssessmentAutomationName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -164,17 +155,18 @@ func (client *CustomAssessmentAutomationsClient) deleteCreateRequest(ctx context // Get - Gets a single custom assessment automation by name for the provided subscription and resource group. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-07-01-preview -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// customAssessmentAutomationName - Name of the Custom Assessment Automation. -// options - CustomAssessmentAutomationsClientGetOptions contains the optional parameters for the CustomAssessmentAutomationsClient.Get -// method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - customAssessmentAutomationName - Name of the Custom Assessment Automation. +// - options - CustomAssessmentAutomationsClientGetOptions contains the optional parameters for the CustomAssessmentAutomationsClient.Get +// method. func (client *CustomAssessmentAutomationsClient) Get(ctx context.Context, resourceGroupName string, customAssessmentAutomationName string, options *CustomAssessmentAutomationsClientGetOptions) (CustomAssessmentAutomationsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, customAssessmentAutomationName, options) if err != nil { return CustomAssessmentAutomationsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return CustomAssessmentAutomationsClientGetResponse{}, err } @@ -199,7 +191,7 @@ func (client *CustomAssessmentAutomationsClient) getCreateRequest(ctx context.Co return nil, errors.New("parameter customAssessmentAutomationName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{customAssessmentAutomationName}", url.PathEscape(customAssessmentAutomationName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -220,10 +212,11 @@ func (client *CustomAssessmentAutomationsClient) getHandleResponse(resp *http.Re } // NewListByResourceGroupPager - List custom assessment automations by provided subscription and resource group +// // Generated from API version 2021-07-01-preview -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// options - CustomAssessmentAutomationsClientListByResourceGroupOptions contains the optional parameters for the CustomAssessmentAutomationsClient.ListByResourceGroup -// method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - options - CustomAssessmentAutomationsClientListByResourceGroupOptions contains the optional parameters for the CustomAssessmentAutomationsClient.NewListByResourceGroupPager +// method. func (client *CustomAssessmentAutomationsClient) NewListByResourceGroupPager(resourceGroupName string, options *CustomAssessmentAutomationsClientListByResourceGroupOptions) *runtime.Pager[CustomAssessmentAutomationsClientListByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[CustomAssessmentAutomationsClientListByResourceGroupResponse]{ More: func(page CustomAssessmentAutomationsClientListByResourceGroupResponse) bool { @@ -240,7 +233,7 @@ func (client *CustomAssessmentAutomationsClient) NewListByResourceGroupPager(res if err != nil { return CustomAssessmentAutomationsClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return CustomAssessmentAutomationsClientListByResourceGroupResponse{}, err } @@ -263,7 +256,7 @@ func (client *CustomAssessmentAutomationsClient) listByResourceGroupCreateReques return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -284,9 +277,10 @@ func (client *CustomAssessmentAutomationsClient) listByResourceGroupHandleRespon } // NewListBySubscriptionPager - List custom assessment automations by provided subscription +// // Generated from API version 2021-07-01-preview -// options - CustomAssessmentAutomationsClientListBySubscriptionOptions contains the optional parameters for the CustomAssessmentAutomationsClient.ListBySubscription -// method. +// - options - CustomAssessmentAutomationsClientListBySubscriptionOptions contains the optional parameters for the CustomAssessmentAutomationsClient.NewListBySubscriptionPager +// method. func (client *CustomAssessmentAutomationsClient) NewListBySubscriptionPager(options *CustomAssessmentAutomationsClientListBySubscriptionOptions) *runtime.Pager[CustomAssessmentAutomationsClientListBySubscriptionResponse] { return runtime.NewPager(runtime.PagingHandler[CustomAssessmentAutomationsClientListBySubscriptionResponse]{ More: func(page CustomAssessmentAutomationsClientListBySubscriptionResponse) bool { @@ -303,7 +297,7 @@ func (client *CustomAssessmentAutomationsClient) NewListBySubscriptionPager(opti if err != nil { return CustomAssessmentAutomationsClientListBySubscriptionResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return CustomAssessmentAutomationsClientListBySubscriptionResponse{}, err } @@ -322,7 +316,7 @@ func (client *CustomAssessmentAutomationsClient) listBySubscriptionCreateRequest return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/security/armsecurity/customassessmentautomations_client_example_test.go b/sdk/resourcemanager/security/armsecurity/customassessmentautomations_client_example_test.go deleted file mode 100644 index c23b5581ce1a..000000000000 --- a/sdk/resourcemanager/security/armsecurity/customassessmentautomations_client_example_test.go +++ /dev/null @@ -1,130 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. - -package armsecurity_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2021-07-01-preview/examples/CustomAssessmentAutomations/customAssessmentAutomationGet_example.json -func ExampleCustomAssessmentAutomationsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewCustomAssessmentAutomationsClient("e5d1b86c-3051-44d5-8802-aa65d45a279b", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "TestResourceGroup", "MyCustomAssessmentAutomation", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2021-07-01-preview/examples/CustomAssessmentAutomations/customAssessmentAutomationCreate_example.json -func ExampleCustomAssessmentAutomationsClient_Create() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewCustomAssessmentAutomationsClient("e5d1b86c-3051-44d5-8802-aa65d45a279b", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Create(ctx, "TestResourceGroup", "MyCustomAssessmentAutomation", armsecurity.CustomAssessmentAutomationRequest{ - Properties: &armsecurity.CustomAssessmentAutomationRequestProperties{ - Description: to.Ptr("Data should be encrypted"), - CompressedQuery: to.Ptr("DQAKAEkAYQBtAF8ARwByAG8AdQBwAA0ACgB8ACAAZQB4AHQAZQBuAGQAIABIAGUAYQBsAHQAaABTAHQAYQB0AHUAcwAgAD0AIABpAGYAZgAoAHQAbwBzAHQAcgBpAG4AZwAoAFIAZQBjAG8AcgBkAC4AVQBzAGUAcgBOAGEAbQBlACkAIABjAG8AbgB0AGEAaQBuAHMAIAAnAHUAcwBlAHIAJwAsACAAJwBVAE4ASABFAEEATABUAEgAWQAnACwAIAAnAEgARQBBAEwAVABIAFkAJwApAA0ACgA="), - DisplayName: to.Ptr("Password Policy"), - RemediationDescription: to.Ptr("Encrypt store by..."), - Severity: to.Ptr(armsecurity.SeverityEnumMedium), - SupportedCloud: to.Ptr(armsecurity.SupportedCloudEnumAWS), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2021-07-01-preview/examples/CustomAssessmentAutomations/customAssessmentAutomationDelete_example.json -func ExampleCustomAssessmentAutomationsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewCustomAssessmentAutomationsClient("e5d1b86c-3051-44d5-8802-aa65d45a279b", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, "TestResourceGroup", "MyCustomAssessmentAutomation", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2021-07-01-preview/examples/CustomAssessmentAutomations/customAssessmentAutomationListByResourceGroup_example.json -func ExampleCustomAssessmentAutomationsClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewCustomAssessmentAutomationsClient("e5d1b86c-3051-44d5-8802-aa65d45a279b", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByResourceGroupPager("TestResourceGroup", nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2021-07-01-preview/examples/CustomAssessmentAutomations/customAssessmentAutomationListBySubscription_example.json -func ExampleCustomAssessmentAutomationsClient_NewListBySubscriptionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewCustomAssessmentAutomationsClient("e5d1b86c-3051-44d5-8802-aa65d45a279b", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListBySubscriptionPager(nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/security/armsecurity/customentitystoreassignments_client.go b/sdk/resourcemanager/security/armsecurity/customentitystoreassignments_client.go index f70eb6f9945b..72e9617744f9 100644 --- a/sdk/resourcemanager/security/armsecurity/customentitystoreassignments_client.go +++ b/sdk/resourcemanager/security/armsecurity/customentitystoreassignments_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,49 +24,41 @@ import ( // CustomEntityStoreAssignmentsClient contains the methods for the CustomEntityStoreAssignments group. // Don't use this type directly, use NewCustomEntityStoreAssignmentsClient() instead. type CustomEntityStoreAssignmentsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewCustomEntityStoreAssignmentsClient creates a new instance of CustomEntityStoreAssignmentsClient with the specified values. -// subscriptionID - Azure subscription ID -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure subscription ID +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewCustomEntityStoreAssignmentsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*CustomEntityStoreAssignmentsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".CustomEntityStoreAssignmentsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &CustomEntityStoreAssignmentsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Create - Creates a custom entity store assignment for the provided subscription, if not already exists. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-07-01-preview -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// customEntityStoreAssignmentName - Name of the custom entity store assignment. Generated name is GUID. -// customEntityStoreAssignmentRequestBody - Custom entity store assignment body -// options - CustomEntityStoreAssignmentsClientCreateOptions contains the optional parameters for the CustomEntityStoreAssignmentsClient.Create -// method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - customEntityStoreAssignmentName - Name of the custom entity store assignment. Generated name is GUID. +// - customEntityStoreAssignmentRequestBody - Custom entity store assignment body +// - options - CustomEntityStoreAssignmentsClientCreateOptions contains the optional parameters for the CustomEntityStoreAssignmentsClient.Create +// method. func (client *CustomEntityStoreAssignmentsClient) Create(ctx context.Context, resourceGroupName string, customEntityStoreAssignmentName string, customEntityStoreAssignmentRequestBody CustomEntityStoreAssignmentRequest, options *CustomEntityStoreAssignmentsClientCreateOptions) (CustomEntityStoreAssignmentsClientCreateResponse, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, customEntityStoreAssignmentName, customEntityStoreAssignmentRequestBody, options) if err != nil { return CustomEntityStoreAssignmentsClientCreateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return CustomEntityStoreAssignmentsClientCreateResponse{}, err } @@ -93,7 +83,7 @@ func (client *CustomEntityStoreAssignmentsClient) createCreateRequest(ctx contex return nil, errors.New("parameter customEntityStoreAssignmentName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{customEntityStoreAssignmentName}", url.PathEscape(customEntityStoreAssignmentName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -115,17 +105,18 @@ func (client *CustomEntityStoreAssignmentsClient) createHandleResponse(resp *htt // Delete - Delete a custom entity store assignment by name for a provided subscription // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-07-01-preview -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// customEntityStoreAssignmentName - Name of the custom entity store assignment. Generated name is GUID. -// options - CustomEntityStoreAssignmentsClientDeleteOptions contains the optional parameters for the CustomEntityStoreAssignmentsClient.Delete -// method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - customEntityStoreAssignmentName - Name of the custom entity store assignment. Generated name is GUID. +// - options - CustomEntityStoreAssignmentsClientDeleteOptions contains the optional parameters for the CustomEntityStoreAssignmentsClient.Delete +// method. func (client *CustomEntityStoreAssignmentsClient) Delete(ctx context.Context, resourceGroupName string, customEntityStoreAssignmentName string, options *CustomEntityStoreAssignmentsClientDeleteOptions) (CustomEntityStoreAssignmentsClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, customEntityStoreAssignmentName, options) if err != nil { return CustomEntityStoreAssignmentsClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return CustomEntityStoreAssignmentsClientDeleteResponse{}, err } @@ -150,7 +141,7 @@ func (client *CustomEntityStoreAssignmentsClient) deleteCreateRequest(ctx contex return nil, errors.New("parameter customEntityStoreAssignmentName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{customEntityStoreAssignmentName}", url.PathEscape(customEntityStoreAssignmentName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -163,17 +154,18 @@ func (client *CustomEntityStoreAssignmentsClient) deleteCreateRequest(ctx contex // Get - Gets a single custom entity store assignment by name for the provided subscription and resource group. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-07-01-preview -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// customEntityStoreAssignmentName - Name of the custom entity store assignment. Generated name is GUID. -// options - CustomEntityStoreAssignmentsClientGetOptions contains the optional parameters for the CustomEntityStoreAssignmentsClient.Get -// method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - customEntityStoreAssignmentName - Name of the custom entity store assignment. Generated name is GUID. +// - options - CustomEntityStoreAssignmentsClientGetOptions contains the optional parameters for the CustomEntityStoreAssignmentsClient.Get +// method. func (client *CustomEntityStoreAssignmentsClient) Get(ctx context.Context, resourceGroupName string, customEntityStoreAssignmentName string, options *CustomEntityStoreAssignmentsClientGetOptions) (CustomEntityStoreAssignmentsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, customEntityStoreAssignmentName, options) if err != nil { return CustomEntityStoreAssignmentsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return CustomEntityStoreAssignmentsClientGetResponse{}, err } @@ -198,7 +190,7 @@ func (client *CustomEntityStoreAssignmentsClient) getCreateRequest(ctx context.C return nil, errors.New("parameter customEntityStoreAssignmentName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{customEntityStoreAssignmentName}", url.PathEscape(customEntityStoreAssignmentName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -219,10 +211,11 @@ func (client *CustomEntityStoreAssignmentsClient) getHandleResponse(resp *http.R } // NewListByResourceGroupPager - List custom entity store assignments by a provided subscription and resource group +// // Generated from API version 2021-07-01-preview -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// options - CustomEntityStoreAssignmentsClientListByResourceGroupOptions contains the optional parameters for the CustomEntityStoreAssignmentsClient.ListByResourceGroup -// method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - options - CustomEntityStoreAssignmentsClientListByResourceGroupOptions contains the optional parameters for the CustomEntityStoreAssignmentsClient.NewListByResourceGroupPager +// method. func (client *CustomEntityStoreAssignmentsClient) NewListByResourceGroupPager(resourceGroupName string, options *CustomEntityStoreAssignmentsClientListByResourceGroupOptions) *runtime.Pager[CustomEntityStoreAssignmentsClientListByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[CustomEntityStoreAssignmentsClientListByResourceGroupResponse]{ More: func(page CustomEntityStoreAssignmentsClientListByResourceGroupResponse) bool { @@ -239,7 +232,7 @@ func (client *CustomEntityStoreAssignmentsClient) NewListByResourceGroupPager(re if err != nil { return CustomEntityStoreAssignmentsClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return CustomEntityStoreAssignmentsClientListByResourceGroupResponse{}, err } @@ -262,7 +255,7 @@ func (client *CustomEntityStoreAssignmentsClient) listByResourceGroupCreateReque return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -283,9 +276,10 @@ func (client *CustomEntityStoreAssignmentsClient) listByResourceGroupHandleRespo } // NewListBySubscriptionPager - List custom entity store assignments by provided subscription +// // Generated from API version 2021-07-01-preview -// options - CustomEntityStoreAssignmentsClientListBySubscriptionOptions contains the optional parameters for the CustomEntityStoreAssignmentsClient.ListBySubscription -// method. +// - options - CustomEntityStoreAssignmentsClientListBySubscriptionOptions contains the optional parameters for the CustomEntityStoreAssignmentsClient.NewListBySubscriptionPager +// method. func (client *CustomEntityStoreAssignmentsClient) NewListBySubscriptionPager(options *CustomEntityStoreAssignmentsClientListBySubscriptionOptions) *runtime.Pager[CustomEntityStoreAssignmentsClientListBySubscriptionResponse] { return runtime.NewPager(runtime.PagingHandler[CustomEntityStoreAssignmentsClientListBySubscriptionResponse]{ More: func(page CustomEntityStoreAssignmentsClientListBySubscriptionResponse) bool { @@ -302,7 +296,7 @@ func (client *CustomEntityStoreAssignmentsClient) NewListBySubscriptionPager(opt if err != nil { return CustomEntityStoreAssignmentsClientListBySubscriptionResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return CustomEntityStoreAssignmentsClientListBySubscriptionResponse{}, err } @@ -321,7 +315,7 @@ func (client *CustomEntityStoreAssignmentsClient) listBySubscriptionCreateReques return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/security/armsecurity/customentitystoreassignments_client_example_test.go b/sdk/resourcemanager/security/armsecurity/customentitystoreassignments_client_example_test.go deleted file mode 100644 index bb836af261f7..000000000000 --- a/sdk/resourcemanager/security/armsecurity/customentitystoreassignments_client_example_test.go +++ /dev/null @@ -1,125 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. - -package armsecurity_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2021-07-01-preview/examples/CustomEntityStoreAssignments/customEntityStoreAssignmentGet_example.json -func ExampleCustomEntityStoreAssignmentsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewCustomEntityStoreAssignmentsClient("e5d1b86c-3051-44d5-8802-aa65d45a279b", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "TestResourceGroup", "33e7cc6e-a139-4723-a0e5-76993aee0771", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2021-07-01-preview/examples/CustomEntityStoreAssignments/customEntityStoreAssignmentCreate_example.json -func ExampleCustomEntityStoreAssignmentsClient_Create() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewCustomEntityStoreAssignmentsClient("e5d1b86c-3051-44d5-8802-aa65d45a279b", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Create(ctx, "TestResourceGroup", "33e7cc6e-a139-4723-a0e5-76993aee0771", armsecurity.CustomEntityStoreAssignmentRequest{ - Properties: &armsecurity.CustomEntityStoreAssignmentRequestProperties{ - Principal: to.Ptr("aaduser=f3923a3e-ad57-4752-b1a9-fbf3c8e5e082;72f988bf-86f1-41af-91ab-2d7cd011db47"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2021-07-01-preview/examples/CustomEntityStoreAssignments/customEntityStoreAssignmentDelete_example.json -func ExampleCustomEntityStoreAssignmentsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewCustomEntityStoreAssignmentsClient("e5d1b86c-3051-44d5-8802-aa65d45a279b", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, "TestResourceGroup", "33e7cc6e-a139-4723-a0e5-76993aee0771", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2021-07-01-preview/examples/CustomEntityStoreAssignments/customEntityStoreAssignmentListByResourceGroup_example.json -func ExampleCustomEntityStoreAssignmentsClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewCustomEntityStoreAssignmentsClient("e5d1b86c-3051-44d5-8802-aa65d45a279b", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByResourceGroupPager("TestResourceGroup", nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2021-07-01-preview/examples/CustomEntityStoreAssignments/customEntityStoreAssignmentListBySubscription_example.json -func ExampleCustomEntityStoreAssignmentsClient_NewListBySubscriptionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewCustomEntityStoreAssignmentsClient("e5d1b86c-3051-44d5-8802-aa65d45a279b", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListBySubscriptionPager(nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/security/armsecurity/date_type.go b/sdk/resourcemanager/security/armsecurity/date_type.go index 9a4998edc1db..6837d033fb82 100644 --- a/sdk/resourcemanager/security/armsecurity/date_type.go +++ b/sdk/resourcemanager/security/armsecurity/date_type.go @@ -35,7 +35,7 @@ func (d *dateType) UnmarshalJSON(data []byte) (err error) { return err } -func populateDateType(m map[string]interface{}, k string, t *time.Time) { +func populateDateType(m map[string]any, k string, t *time.Time) { if t == nil { return } else if azcore.IsNullValue(t) { diff --git a/sdk/resourcemanager/security/armsecurity/devicesecuritygroups_client.go b/sdk/resourcemanager/security/armsecurity/devicesecuritygroups_client.go index 07201bebd162..5e6648e6a7d6 100644 --- a/sdk/resourcemanager/security/armsecurity/devicesecuritygroups_client.go +++ b/sdk/resourcemanager/security/armsecurity/devicesecuritygroups_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,47 +24,39 @@ import ( // DeviceSecurityGroupsClient contains the methods for the DeviceSecurityGroups group. // Don't use this type directly, use NewDeviceSecurityGroupsClient() instead. type DeviceSecurityGroupsClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewDeviceSecurityGroupsClient creates a new instance of DeviceSecurityGroupsClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewDeviceSecurityGroupsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*DeviceSecurityGroupsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".DeviceSecurityGroupsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &DeviceSecurityGroupsClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } // CreateOrUpdate - Use this method to creates or updates the device security group on a specified IoT Hub resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-08-01 -// resourceID - The identifier of the resource. -// deviceSecurityGroupName - The name of the device security group. Note that the name of the device security group is case -// insensitive. -// deviceSecurityGroup - Security group object. -// options - DeviceSecurityGroupsClientCreateOrUpdateOptions contains the optional parameters for the DeviceSecurityGroupsClient.CreateOrUpdate -// method. +// - resourceID - The identifier of the resource. +// - deviceSecurityGroupName - The name of the device security group. Note that the name of the device security group is case +// insensitive. +// - deviceSecurityGroup - Security group object. +// - options - DeviceSecurityGroupsClientCreateOrUpdateOptions contains the optional parameters for the DeviceSecurityGroupsClient.CreateOrUpdate +// method. func (client *DeviceSecurityGroupsClient) CreateOrUpdate(ctx context.Context, resourceID string, deviceSecurityGroupName string, deviceSecurityGroup DeviceSecurityGroup, options *DeviceSecurityGroupsClientCreateOrUpdateOptions) (DeviceSecurityGroupsClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceID, deviceSecurityGroupName, deviceSecurityGroup, options) if err != nil { return DeviceSecurityGroupsClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DeviceSecurityGroupsClientCreateOrUpdateResponse{}, err } @@ -84,7 +74,7 @@ func (client *DeviceSecurityGroupsClient) createOrUpdateCreateRequest(ctx contex return nil, errors.New("parameter deviceSecurityGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{deviceSecurityGroupName}", url.PathEscape(deviceSecurityGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -106,18 +96,19 @@ func (client *DeviceSecurityGroupsClient) createOrUpdateHandleResponse(resp *htt // Delete - User this method to deletes the device security group. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-08-01 -// resourceID - The identifier of the resource. -// deviceSecurityGroupName - The name of the device security group. Note that the name of the device security group is case -// insensitive. -// options - DeviceSecurityGroupsClientDeleteOptions contains the optional parameters for the DeviceSecurityGroupsClient.Delete -// method. +// - resourceID - The identifier of the resource. +// - deviceSecurityGroupName - The name of the device security group. Note that the name of the device security group is case +// insensitive. +// - options - DeviceSecurityGroupsClientDeleteOptions contains the optional parameters for the DeviceSecurityGroupsClient.Delete +// method. func (client *DeviceSecurityGroupsClient) Delete(ctx context.Context, resourceID string, deviceSecurityGroupName string, options *DeviceSecurityGroupsClientDeleteOptions) (DeviceSecurityGroupsClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceID, deviceSecurityGroupName, options) if err != nil { return DeviceSecurityGroupsClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DeviceSecurityGroupsClientDeleteResponse{}, err } @@ -135,7 +126,7 @@ func (client *DeviceSecurityGroupsClient) deleteCreateRequest(ctx context.Contex return nil, errors.New("parameter deviceSecurityGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{deviceSecurityGroupName}", url.PathEscape(deviceSecurityGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -148,18 +139,19 @@ func (client *DeviceSecurityGroupsClient) deleteCreateRequest(ctx context.Contex // Get - Use this method to get the device security group for the specified IoT Hub resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-08-01 -// resourceID - The identifier of the resource. -// deviceSecurityGroupName - The name of the device security group. Note that the name of the device security group is case -// insensitive. -// options - DeviceSecurityGroupsClientGetOptions contains the optional parameters for the DeviceSecurityGroupsClient.Get -// method. +// - resourceID - The identifier of the resource. +// - deviceSecurityGroupName - The name of the device security group. Note that the name of the device security group is case +// insensitive. +// - options - DeviceSecurityGroupsClientGetOptions contains the optional parameters for the DeviceSecurityGroupsClient.Get +// method. func (client *DeviceSecurityGroupsClient) Get(ctx context.Context, resourceID string, deviceSecurityGroupName string, options *DeviceSecurityGroupsClientGetOptions) (DeviceSecurityGroupsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceID, deviceSecurityGroupName, options) if err != nil { return DeviceSecurityGroupsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DeviceSecurityGroupsClientGetResponse{}, err } @@ -177,7 +169,7 @@ func (client *DeviceSecurityGroupsClient) getCreateRequest(ctx context.Context, return nil, errors.New("parameter deviceSecurityGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{deviceSecurityGroupName}", url.PathEscape(deviceSecurityGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -198,10 +190,11 @@ func (client *DeviceSecurityGroupsClient) getHandleResponse(resp *http.Response) } // NewListPager - Use this method get the list of device security groups for the specified IoT Hub resource. +// // Generated from API version 2019-08-01 -// resourceID - The identifier of the resource. -// options - DeviceSecurityGroupsClientListOptions contains the optional parameters for the DeviceSecurityGroupsClient.List -// method. +// - resourceID - The identifier of the resource. +// - options - DeviceSecurityGroupsClientListOptions contains the optional parameters for the DeviceSecurityGroupsClient.NewListPager +// method. func (client *DeviceSecurityGroupsClient) NewListPager(resourceID string, options *DeviceSecurityGroupsClientListOptions) *runtime.Pager[DeviceSecurityGroupsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[DeviceSecurityGroupsClientListResponse]{ More: func(page DeviceSecurityGroupsClientListResponse) bool { @@ -218,7 +211,7 @@ func (client *DeviceSecurityGroupsClient) NewListPager(resourceID string, option if err != nil { return DeviceSecurityGroupsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DeviceSecurityGroupsClientListResponse{}, err } @@ -234,7 +227,7 @@ func (client *DeviceSecurityGroupsClient) NewListPager(resourceID string, option func (client *DeviceSecurityGroupsClient) listCreateRequest(ctx context.Context, resourceID string, options *DeviceSecurityGroupsClientListOptions) (*policy.Request, error) { urlPath := "/{resourceId}/providers/Microsoft.Security/deviceSecurityGroups" urlPath = strings.ReplaceAll(urlPath, "{resourceId}", resourceID) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/security/armsecurity/devicesecuritygroups_client_example_test.go b/sdk/resourcemanager/security/armsecurity/devicesecuritygroups_client_example_test.go deleted file mode 100644 index 5f0d6a23eda5..000000000000 --- a/sdk/resourcemanager/security/armsecurity/devicesecuritygroups_client_example_test.go +++ /dev/null @@ -1,108 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. - -package armsecurity_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/DeviceSecurityGroups/ListDeviceSecurityGroups_example.json -func ExampleDeviceSecurityGroupsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewDeviceSecurityGroupsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/SampleRG/providers/Microsoft.Devices/iotHubs/sampleiothub", nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/DeviceSecurityGroups/GetDeviceSecurityGroups_example.json -func ExampleDeviceSecurityGroupsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewDeviceSecurityGroupsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/SampleRG/providers/Microsoft.Devices/iotHubs/sampleiothub", "samplesecuritygroup", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/DeviceSecurityGroups/PutDeviceSecurityGroups_example.json -func ExampleDeviceSecurityGroupsClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewDeviceSecurityGroupsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdate(ctx, "subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/SampleRG/providers/Microsoft.Devices/iotHubs/sampleiothub", "samplesecuritygroup", armsecurity.DeviceSecurityGroup{ - Properties: &armsecurity.DeviceSecurityGroupProperties{ - TimeWindowRules: []armsecurity.TimeWindowCustomAlertRuleClassification{ - &armsecurity.ActiveConnectionsNotInAllowedRange{ - IsEnabled: to.Ptr(true), - RuleType: to.Ptr("ActiveConnectionsNotInAllowedRange"), - MaxThreshold: to.Ptr[int32](30), - MinThreshold: to.Ptr[int32](0), - TimeWindowSize: to.Ptr("PT05M"), - }}, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/DeviceSecurityGroups/DeleteDeviceSecurityGroups_example.json -func ExampleDeviceSecurityGroupsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewDeviceSecurityGroupsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, "subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/SampleRG/providers/Microsoft.Devices/iotHubs/sampleiothub", "samplesecuritygroup", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/security/armsecurity/discoveredsecuritysolutions_client.go b/sdk/resourcemanager/security/armsecurity/discoveredsecuritysolutions_client.go index 37900587ad97..9baefc82af9c 100644 --- a/sdk/resourcemanager/security/armsecurity/discoveredsecuritysolutions_client.go +++ b/sdk/resourcemanager/security/armsecurity/discoveredsecuritysolutions_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,49 +24,41 @@ import ( // DiscoveredSecuritySolutionsClient contains the methods for the DiscoveredSecuritySolutions group. // Don't use this type directly, use NewDiscoveredSecuritySolutionsClient() instead. type DiscoveredSecuritySolutionsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewDiscoveredSecuritySolutionsClient creates a new instance of DiscoveredSecuritySolutionsClient with the specified values. -// subscriptionID - Azure subscription ID -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure subscription ID +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewDiscoveredSecuritySolutionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DiscoveredSecuritySolutionsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".DiscoveredSecuritySolutionsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &DiscoveredSecuritySolutionsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Gets a specific discovered Security Solution. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-01-01 -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations -// discoveredSecuritySolutionName - Name of a discovered security solution. -// options - DiscoveredSecuritySolutionsClientGetOptions contains the optional parameters for the DiscoveredSecuritySolutionsClient.Get -// method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations +// - discoveredSecuritySolutionName - Name of a discovered security solution. +// - options - DiscoveredSecuritySolutionsClientGetOptions contains the optional parameters for the DiscoveredSecuritySolutionsClient.Get +// method. func (client *DiscoveredSecuritySolutionsClient) Get(ctx context.Context, resourceGroupName string, ascLocation string, discoveredSecuritySolutionName string, options *DiscoveredSecuritySolutionsClientGetOptions) (DiscoveredSecuritySolutionsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, ascLocation, discoveredSecuritySolutionName, options) if err != nil { return DiscoveredSecuritySolutionsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DiscoveredSecuritySolutionsClientGetResponse{}, err } @@ -97,7 +87,7 @@ func (client *DiscoveredSecuritySolutionsClient) getCreateRequest(ctx context.Co return nil, errors.New("parameter discoveredSecuritySolutionName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{discoveredSecuritySolutionName}", url.PathEscape(discoveredSecuritySolutionName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -118,9 +108,10 @@ func (client *DiscoveredSecuritySolutionsClient) getHandleResponse(resp *http.Re } // NewListPager - Gets a list of discovered Security Solutions for the subscription. +// // Generated from API version 2020-01-01 -// options - DiscoveredSecuritySolutionsClientListOptions contains the optional parameters for the DiscoveredSecuritySolutionsClient.List -// method. +// - options - DiscoveredSecuritySolutionsClientListOptions contains the optional parameters for the DiscoveredSecuritySolutionsClient.NewListPager +// method. func (client *DiscoveredSecuritySolutionsClient) NewListPager(options *DiscoveredSecuritySolutionsClientListOptions) *runtime.Pager[DiscoveredSecuritySolutionsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[DiscoveredSecuritySolutionsClientListResponse]{ More: func(page DiscoveredSecuritySolutionsClientListResponse) bool { @@ -137,7 +128,7 @@ func (client *DiscoveredSecuritySolutionsClient) NewListPager(options *Discovere if err != nil { return DiscoveredSecuritySolutionsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DiscoveredSecuritySolutionsClientListResponse{}, err } @@ -156,7 +147,7 @@ func (client *DiscoveredSecuritySolutionsClient) listCreateRequest(ctx context.C return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -177,10 +168,11 @@ func (client *DiscoveredSecuritySolutionsClient) listHandleResponse(resp *http.R } // NewListByHomeRegionPager - Gets a list of discovered Security Solutions for the subscription and location. +// // Generated from API version 2020-01-01 -// ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations -// options - DiscoveredSecuritySolutionsClientListByHomeRegionOptions contains the optional parameters for the DiscoveredSecuritySolutionsClient.ListByHomeRegion -// method. +// - ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations +// - options - DiscoveredSecuritySolutionsClientListByHomeRegionOptions contains the optional parameters for the DiscoveredSecuritySolutionsClient.NewListByHomeRegionPager +// method. func (client *DiscoveredSecuritySolutionsClient) NewListByHomeRegionPager(ascLocation string, options *DiscoveredSecuritySolutionsClientListByHomeRegionOptions) *runtime.Pager[DiscoveredSecuritySolutionsClientListByHomeRegionResponse] { return runtime.NewPager(runtime.PagingHandler[DiscoveredSecuritySolutionsClientListByHomeRegionResponse]{ More: func(page DiscoveredSecuritySolutionsClientListByHomeRegionResponse) bool { @@ -197,7 +189,7 @@ func (client *DiscoveredSecuritySolutionsClient) NewListByHomeRegionPager(ascLoc if err != nil { return DiscoveredSecuritySolutionsClientListByHomeRegionResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DiscoveredSecuritySolutionsClientListByHomeRegionResponse{}, err } @@ -220,7 +212,7 @@ func (client *DiscoveredSecuritySolutionsClient) listByHomeRegionCreateRequest(c return nil, errors.New("parameter ascLocation cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{ascLocation}", url.PathEscape(ascLocation)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/security/armsecurity/discoveredsecuritysolutions_client_example_test.go b/sdk/resourcemanager/security/armsecurity/discoveredsecuritysolutions_client_example_test.go deleted file mode 100644 index 36927b810e3f..000000000000 --- a/sdk/resourcemanager/security/armsecurity/discoveredsecuritysolutions_client_example_test.go +++ /dev/null @@ -1,84 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. - -package armsecurity_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/DiscoveredSecuritySolutions/GetDiscoveredSecuritySolutionsSubscription_example.json -func ExampleDiscoveredSecuritySolutionsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewDiscoveredSecuritySolutionsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/DiscoveredSecuritySolutions/GetDiscoveredSecuritySolutionsSubscriptionLocation_example.json -func ExampleDiscoveredSecuritySolutionsClient_NewListByHomeRegionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewDiscoveredSecuritySolutionsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByHomeRegionPager("centralus", nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/DiscoveredSecuritySolutions/GetDiscoveredSecuritySolutionResourceGroupLocation_example.json -func ExampleDiscoveredSecuritySolutionsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewDiscoveredSecuritySolutionsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "myRg2", "centralus", "paloalto7", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/security/armsecurity/externalsecuritysolutions_client.go b/sdk/resourcemanager/security/armsecurity/externalsecuritysolutions_client.go index a710174214bd..2824a069a91d 100644 --- a/sdk/resourcemanager/security/armsecurity/externalsecuritysolutions_client.go +++ b/sdk/resourcemanager/security/armsecurity/externalsecuritysolutions_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,49 +24,41 @@ import ( // ExternalSecuritySolutionsClient contains the methods for the ExternalSecuritySolutions group. // Don't use this type directly, use NewExternalSecuritySolutionsClient() instead. type ExternalSecuritySolutionsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewExternalSecuritySolutionsClient creates a new instance of ExternalSecuritySolutionsClient with the specified values. -// subscriptionID - Azure subscription ID -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure subscription ID +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewExternalSecuritySolutionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ExternalSecuritySolutionsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".ExternalSecuritySolutionsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ExternalSecuritySolutionsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Gets a specific external Security Solution. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-01-01 -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations -// externalSecuritySolutionsName - Name of an external security solution. -// options - ExternalSecuritySolutionsClientGetOptions contains the optional parameters for the ExternalSecuritySolutionsClient.Get -// method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations +// - externalSecuritySolutionsName - Name of an external security solution. +// - options - ExternalSecuritySolutionsClientGetOptions contains the optional parameters for the ExternalSecuritySolutionsClient.Get +// method. func (client *ExternalSecuritySolutionsClient) Get(ctx context.Context, resourceGroupName string, ascLocation string, externalSecuritySolutionsName string, options *ExternalSecuritySolutionsClientGetOptions) (ExternalSecuritySolutionsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, ascLocation, externalSecuritySolutionsName, options) if err != nil { return ExternalSecuritySolutionsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ExternalSecuritySolutionsClientGetResponse{}, err } @@ -97,7 +87,7 @@ func (client *ExternalSecuritySolutionsClient) getCreateRequest(ctx context.Cont return nil, errors.New("parameter externalSecuritySolutionsName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{externalSecuritySolutionsName}", url.PathEscape(externalSecuritySolutionsName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -118,9 +108,10 @@ func (client *ExternalSecuritySolutionsClient) getHandleResponse(resp *http.Resp } // NewListPager - Gets a list of external security solutions for the subscription. +// // Generated from API version 2020-01-01 -// options - ExternalSecuritySolutionsClientListOptions contains the optional parameters for the ExternalSecuritySolutionsClient.List -// method. +// - options - ExternalSecuritySolutionsClientListOptions contains the optional parameters for the ExternalSecuritySolutionsClient.NewListPager +// method. func (client *ExternalSecuritySolutionsClient) NewListPager(options *ExternalSecuritySolutionsClientListOptions) *runtime.Pager[ExternalSecuritySolutionsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[ExternalSecuritySolutionsClientListResponse]{ More: func(page ExternalSecuritySolutionsClientListResponse) bool { @@ -137,7 +128,7 @@ func (client *ExternalSecuritySolutionsClient) NewListPager(options *ExternalSec if err != nil { return ExternalSecuritySolutionsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ExternalSecuritySolutionsClientListResponse{}, err } @@ -156,7 +147,7 @@ func (client *ExternalSecuritySolutionsClient) listCreateRequest(ctx context.Con return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -177,10 +168,11 @@ func (client *ExternalSecuritySolutionsClient) listHandleResponse(resp *http.Res } // NewListByHomeRegionPager - Gets a list of external Security Solutions for the subscription and location. +// // Generated from API version 2020-01-01 -// ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations -// options - ExternalSecuritySolutionsClientListByHomeRegionOptions contains the optional parameters for the ExternalSecuritySolutionsClient.ListByHomeRegion -// method. +// - ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations +// - options - ExternalSecuritySolutionsClientListByHomeRegionOptions contains the optional parameters for the ExternalSecuritySolutionsClient.NewListByHomeRegionPager +// method. func (client *ExternalSecuritySolutionsClient) NewListByHomeRegionPager(ascLocation string, options *ExternalSecuritySolutionsClientListByHomeRegionOptions) *runtime.Pager[ExternalSecuritySolutionsClientListByHomeRegionResponse] { return runtime.NewPager(runtime.PagingHandler[ExternalSecuritySolutionsClientListByHomeRegionResponse]{ More: func(page ExternalSecuritySolutionsClientListByHomeRegionResponse) bool { @@ -197,7 +189,7 @@ func (client *ExternalSecuritySolutionsClient) NewListByHomeRegionPager(ascLocat if err != nil { return ExternalSecuritySolutionsClientListByHomeRegionResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ExternalSecuritySolutionsClientListByHomeRegionResponse{}, err } @@ -220,7 +212,7 @@ func (client *ExternalSecuritySolutionsClient) listByHomeRegionCreateRequest(ctx return nil, errors.New("parameter ascLocation cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{ascLocation}", url.PathEscape(ascLocation)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/security/armsecurity/externalsecuritysolutions_client_example_test.go b/sdk/resourcemanager/security/armsecurity/externalsecuritysolutions_client_example_test.go deleted file mode 100644 index ac257b74a868..000000000000 --- a/sdk/resourcemanager/security/armsecurity/externalsecuritysolutions_client_example_test.go +++ /dev/null @@ -1,84 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. - -package armsecurity_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/ExternalSecuritySolutions/GetExternalSecuritySolutionsSubscription_example.json -func ExampleExternalSecuritySolutionsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewExternalSecuritySolutionsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/ExternalSecuritySolutions/GetExternalSecuritySolutionsSubscriptionLocation_example.json -func ExampleExternalSecuritySolutionsClient_NewListByHomeRegionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewExternalSecuritySolutionsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByHomeRegionPager("centralus", nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/ExternalSecuritySolutions/GetExternalSecuritySolution_example.json -func ExampleExternalSecuritySolutionsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewExternalSecuritySolutionsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "defaultresourcegroup-eus", "centralus", "aad_defaultworkspace-20ff7fc3-e762-44dd-bd96-b71116dcdc23-eus", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/security/armsecurity/go.mod b/sdk/resourcemanager/security/armsecurity/go.mod index 1bcbad76149d..62630a6a7cb5 100644 --- a/sdk/resourcemanager/security/armsecurity/go.mod +++ b/sdk/resourcemanager/security/armsecurity/go.mod @@ -2,20 +2,12 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurit go 1.18 -require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.0 -) +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v0.7.0 // indirect - github.com/golang-jwt/jwt/v4 v4.4.2 // indirect - github.com/google/uuid v1.1.1 // indirect - github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 // indirect - golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 // indirect - golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect - golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect - golang.org/x/text v0.3.7 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.1.2 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + golang.org/x/net v0.7.0 // indirect + golang.org/x/text v0.7.0 // indirect + gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect ) diff --git a/sdk/resourcemanager/security/armsecurity/go.sum b/sdk/resourcemanager/security/armsecurity/go.sum index 8c0539b73123..f54c298864a1 100644 --- a/sdk/resourcemanager/security/armsecurity/go.sum +++ b/sdk/resourcemanager/security/armsecurity/go.sum @@ -1,30 +1,15 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 h1:sVPhtT2qjO86rTUaWMr4WoES4TkjGnzcioXcnHV9s5k= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.0 h1:t/W5MYAuQy81cvM8VUNfRLzhtKpXhVUAN7Cd7KVbTyc= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.0/go.mod h1:NBanQUfSWiWn3QEpWDTCU0IjBECKOYvl2R8xdRtMtiM= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 h1:jp0dGvZ7ZK0mgqnTSClMxa5xuRL7NZgHameVYF6BurY= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= -github.com/AzureAD/microsoft-authentication-library-for-go v0.7.0 h1:VgSJlZH5u0k2qxSpqyghcFQKmvYckj46uymKK5XzkBM= -github.com/AzureAD/microsoft-authentication-library-for-go v0.7.0/go.mod h1:BDJ5qMFKx9DugEg3+uQSDCdbYPr5s9vBTrL9P8TpqOU= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 h1:rTnT/Jrcm+figWlYz4Ixzt0SJVR2cMC8lvZcimipiEY= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0/go.mod h1:ON4tFdPTwRcgWEaVDrN3584Ef+b7GgSJaXxe5fW9t4M= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.1.2 h1:+5VZ72z0Qan5Bog5C+ZkgSqUbeVUd9wgtHOrIKuc5b8= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.1.2/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= -github.com/golang-jwt/jwt/v4 v4.4.2 h1:rcc4lwaZgFMCZ5jxF9ABolDcIHdBytAFgqFPbSJQAYs= -github.com/golang-jwt/jwt/v4 v4.4.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= -github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= -github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= -github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 h1:Qj1ukM4GlMWXNdMBuXcXfz/Kw9s1qm0CLY32QxuSImI= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4/go.mod h1:N6UoU20jOqggOuDwUaBQpluzLNDqif3kq9z2wpdYEfQ= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 h1:Tgea0cVUD0ivh5ADBX4WwuI12DUd2to3nCYe2eayMIw= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/resourcemanager/security/armsecurity/governanceassignments_client.go b/sdk/resourcemanager/security/armsecurity/governanceassignments_client.go index 09945ef5d0b5..8829044848f2 100644 --- a/sdk/resourcemanager/security/armsecurity/governanceassignments_client.go +++ b/sdk/resourcemanager/security/armsecurity/governanceassignments_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,48 +24,41 @@ import ( // GovernanceAssignmentsClient contains the methods for the GovernanceAssignments group. // Don't use this type directly, use NewGovernanceAssignmentsClient() instead. type GovernanceAssignmentsClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewGovernanceAssignmentsClient creates a new instance of GovernanceAssignmentsClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewGovernanceAssignmentsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*GovernanceAssignmentsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".GovernanceAssignmentsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &GovernanceAssignmentsClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } -// CreateOrUpdate - Creates or update a security GovernanceAssignment on the given subscription. +// CreateOrUpdate - Creates or updates a governance assignment on the given subscription. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-01-preview -// scope - Scope of the query, can be subscription (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group -// (/providers/Microsoft.Management/managementGroups/mgName). -// assessmentName - The Assessment Key - Unique key for the assessment type -// assignmentKey - The security governance assignment key - the assessment key of the required governance assignment -// governanceAssignment - GovernanceAssignment over a subscription scope -// options - GovernanceAssignmentsClientCreateOrUpdateOptions contains the optional parameters for the GovernanceAssignmentsClient.CreateOrUpdate -// method. +// - scope - The scope of the Governance assignments. Valid scopes are: subscription (format: 'subscriptions/{subscriptionId}'), +// or security connector (format: +// 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})' +// - assessmentName - The Assessment Key - A unique key for the assessment type +// - assignmentKey - The governance assignment key - the assessment key of the required governance assignment +// - governanceAssignment - Governance assignment over a subscription scope +// - options - GovernanceAssignmentsClientCreateOrUpdateOptions contains the optional parameters for the GovernanceAssignmentsClient.CreateOrUpdate +// method. func (client *GovernanceAssignmentsClient) CreateOrUpdate(ctx context.Context, scope string, assessmentName string, assignmentKey string, governanceAssignment GovernanceAssignment, options *GovernanceAssignmentsClientCreateOrUpdateOptions) (GovernanceAssignmentsClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, scope, assessmentName, assignmentKey, governanceAssignment, options) if err != nil { return GovernanceAssignmentsClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return GovernanceAssignmentsClientCreateOrUpdateResponse{}, err } @@ -80,7 +71,10 @@ func (client *GovernanceAssignmentsClient) CreateOrUpdate(ctx context.Context, s // createOrUpdateCreateRequest creates the CreateOrUpdate request. func (client *GovernanceAssignmentsClient) createOrUpdateCreateRequest(ctx context.Context, scope string, assessmentName string, assignmentKey string, governanceAssignment GovernanceAssignment, options *GovernanceAssignmentsClientCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.Security/assessments/{assessmentName}/governanceAssignments/{assignmentKey}" - urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) + if scope == "" { + return nil, errors.New("parameter scope cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scope}", url.PathEscape(scope)) if assessmentName == "" { return nil, errors.New("parameter assessmentName cannot be empty") } @@ -89,7 +83,7 @@ func (client *GovernanceAssignmentsClient) createOrUpdateCreateRequest(ctx conte return nil, errors.New("parameter assignmentKey cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{assignmentKey}", url.PathEscape(assignmentKey)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -111,19 +105,21 @@ func (client *GovernanceAssignmentsClient) createOrUpdateHandleResponse(resp *ht // Delete - Delete a GovernanceAssignment over a given scope // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-01-preview -// scope - Scope of the query, can be subscription (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group -// (/providers/Microsoft.Management/managementGroups/mgName). -// assessmentName - The Assessment Key - Unique key for the assessment type -// assignmentKey - The security governance assignment key - the assessment key of the required governance assignment -// options - GovernanceAssignmentsClientDeleteOptions contains the optional parameters for the GovernanceAssignmentsClient.Delete -// method. +// - scope - The scope of the Governance assignments. Valid scopes are: subscription (format: 'subscriptions/{subscriptionId}'), +// or security connector (format: +// 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})' +// - assessmentName - The Assessment Key - A unique key for the assessment type +// - assignmentKey - The governance assignment key - the assessment key of the required governance assignment +// - options - GovernanceAssignmentsClientDeleteOptions contains the optional parameters for the GovernanceAssignmentsClient.Delete +// method. func (client *GovernanceAssignmentsClient) Delete(ctx context.Context, scope string, assessmentName string, assignmentKey string, options *GovernanceAssignmentsClientDeleteOptions) (GovernanceAssignmentsClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, scope, assessmentName, assignmentKey, options) if err != nil { return GovernanceAssignmentsClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return GovernanceAssignmentsClientDeleteResponse{}, err } @@ -136,7 +132,10 @@ func (client *GovernanceAssignmentsClient) Delete(ctx context.Context, scope str // deleteCreateRequest creates the Delete request. func (client *GovernanceAssignmentsClient) deleteCreateRequest(ctx context.Context, scope string, assessmentName string, assignmentKey string, options *GovernanceAssignmentsClientDeleteOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.Security/assessments/{assessmentName}/governanceAssignments/{assignmentKey}" - urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) + if scope == "" { + return nil, errors.New("parameter scope cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scope}", url.PathEscape(scope)) if assessmentName == "" { return nil, errors.New("parameter assessmentName cannot be empty") } @@ -145,7 +144,7 @@ func (client *GovernanceAssignmentsClient) deleteCreateRequest(ctx context.Conte return nil, errors.New("parameter assignmentKey cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{assignmentKey}", url.PathEscape(assignmentKey)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -157,19 +156,21 @@ func (client *GovernanceAssignmentsClient) deleteCreateRequest(ctx context.Conte // Get - Get a specific governanceAssignment for the requested scope by AssignmentKey // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-01-preview -// scope - Scope of the query, can be subscription (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group -// (/providers/Microsoft.Management/managementGroups/mgName). -// assessmentName - The Assessment Key - Unique key for the assessment type -// assignmentKey - The security governance assignment key - the assessment key of the required governance assignment -// options - GovernanceAssignmentsClientGetOptions contains the optional parameters for the GovernanceAssignmentsClient.Get -// method. +// - scope - The scope of the Governance assignments. Valid scopes are: subscription (format: 'subscriptions/{subscriptionId}'), +// or security connector (format: +// 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})' +// - assessmentName - The Assessment Key - A unique key for the assessment type +// - assignmentKey - The governance assignment key - the assessment key of the required governance assignment +// - options - GovernanceAssignmentsClientGetOptions contains the optional parameters for the GovernanceAssignmentsClient.Get +// method. func (client *GovernanceAssignmentsClient) Get(ctx context.Context, scope string, assessmentName string, assignmentKey string, options *GovernanceAssignmentsClientGetOptions) (GovernanceAssignmentsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, scope, assessmentName, assignmentKey, options) if err != nil { return GovernanceAssignmentsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return GovernanceAssignmentsClientGetResponse{}, err } @@ -182,7 +183,10 @@ func (client *GovernanceAssignmentsClient) Get(ctx context.Context, scope string // getCreateRequest creates the Get request. func (client *GovernanceAssignmentsClient) getCreateRequest(ctx context.Context, scope string, assessmentName string, assignmentKey string, options *GovernanceAssignmentsClientGetOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.Security/assessments/{assessmentName}/governanceAssignments/{assignmentKey}" - urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) + if scope == "" { + return nil, errors.New("parameter scope cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scope}", url.PathEscape(scope)) if assessmentName == "" { return nil, errors.New("parameter assessmentName cannot be empty") } @@ -191,7 +195,7 @@ func (client *GovernanceAssignmentsClient) getCreateRequest(ctx context.Context, return nil, errors.New("parameter assignmentKey cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{assignmentKey}", url.PathEscape(assignmentKey)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -211,13 +215,15 @@ func (client *GovernanceAssignmentsClient) getHandleResponse(resp *http.Response return result, nil } -// NewListPager - Get security governanceAssignments on all your resources inside a scope +// NewListPager - Get governance assignments on all of your resources inside a scope +// // Generated from API version 2022-01-01-preview -// scope - Scope of the query, can be subscription (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group -// (/providers/Microsoft.Management/managementGroups/mgName). -// assessmentName - The Assessment Key - Unique key for the assessment type -// options - GovernanceAssignmentsClientListOptions contains the optional parameters for the GovernanceAssignmentsClient.List -// method. +// - scope - The scope of the Governance assignments. Valid scopes are: subscription (format: 'subscriptions/{subscriptionId}'), +// or security connector (format: +// 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})' +// - assessmentName - The Assessment Key - A unique key for the assessment type +// - options - GovernanceAssignmentsClientListOptions contains the optional parameters for the GovernanceAssignmentsClient.NewListPager +// method. func (client *GovernanceAssignmentsClient) NewListPager(scope string, assessmentName string, options *GovernanceAssignmentsClientListOptions) *runtime.Pager[GovernanceAssignmentsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[GovernanceAssignmentsClientListResponse]{ More: func(page GovernanceAssignmentsClientListResponse) bool { @@ -234,7 +240,7 @@ func (client *GovernanceAssignmentsClient) NewListPager(scope string, assessment if err != nil { return GovernanceAssignmentsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return GovernanceAssignmentsClientListResponse{}, err } @@ -249,12 +255,15 @@ func (client *GovernanceAssignmentsClient) NewListPager(scope string, assessment // listCreateRequest creates the List request. func (client *GovernanceAssignmentsClient) listCreateRequest(ctx context.Context, scope string, assessmentName string, options *GovernanceAssignmentsClientListOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.Security/assessments/{assessmentName}/governanceAssignments" - urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) + if scope == "" { + return nil, errors.New("parameter scope cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scope}", url.PathEscape(scope)) if assessmentName == "" { return nil, errors.New("parameter assessmentName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{assessmentName}", url.PathEscape(assessmentName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/security/armsecurity/governanceassignments_client_example_test.go b/sdk/resourcemanager/security/armsecurity/governanceassignments_client_example_test.go deleted file mode 100644 index fa60f7b5d251..000000000000 --- a/sdk/resourcemanager/security/armsecurity/governanceassignments_client_example_test.go +++ /dev/null @@ -1,118 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. - -package armsecurity_test - -import ( - "context" - "log" - - "time" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceAssignments/ListGovernanceAssignments_example.json -func ExampleGovernanceAssignmentsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewGovernanceAssignmentsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("subscriptions/c32e05d9-7207-4e22-bdf4-4f7d9c72e5fd", "6b9421dd-5555-2251-9b3d-2be58e2f82cd", nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceAssignments/GetGovernanceAssignment_example.json -func ExampleGovernanceAssignmentsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewGovernanceAssignmentsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "subscriptions/c32e05d9-7207-4e22-bdf4-4f7d9c72e5fd/resourceGroups/compute_servers/providers/Microsoft.Compute/virtualMachines/win2012", "6b9421dd-5555-2251-9b3d-2be58e2f82cd", "6634ff9f-127b-4bf2-8e6e-b1737f5e789c", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceAssignments/PutGovernanceAssignment_example.json -func ExampleGovernanceAssignmentsClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewGovernanceAssignmentsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdate(ctx, "subscriptions/c32e05d9-7207-4e22-bdf4-4f7d9c72e5fd/resourceGroups/compute_servers/providers/Microsoft.Compute/virtualMachines/win2012", "6b9421dd-5555-2251-9b3d-2be58e2f82cd", "6634ff9f-127b-4bf2-8e6e-b1737f5e789c", armsecurity.GovernanceAssignment{ - Properties: &armsecurity.GovernanceAssignmentProperties{ - AdditionalData: &armsecurity.GovernanceAssignmentAdditionalData{ - TicketLink: to.Ptr("https://snow.com"), - TicketNumber: to.Ptr[int32](123123), - TicketStatus: to.Ptr("Active"), - }, - GovernanceEmailNotification: &armsecurity.GovernanceEmailNotification{ - DisableManagerEmailNotification: to.Ptr(false), - DisableOwnerEmailNotification: to.Ptr(false), - }, - IsGracePeriod: to.Ptr(true), - Owner: to.Ptr("user@contoso.com"), - RemediationDueDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-01-07T13:00:00.0000000Z"); return t }()), - RemediationEta: &armsecurity.RemediationEta{ - Eta: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-01-08T13:00:00.0000000Z"); return t }()), - Justification: to.Ptr("Justification of ETA"), - }, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceAssignments/DeleteGovernanceAssignment_example.json -func ExampleGovernanceAssignmentsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewGovernanceAssignmentsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, "subscriptions/c32e05d9-7207-4e22-bdf4-4f7d9c72e5fd/resourceGroups/compute_servers/providers/Microsoft.Compute/virtualMachines/win2012", "6b9421dd-5555-2251-9b3d-2be58e2f82cd", "6634ff9f-127b-4bf2-8e6e-b1737f5e789c", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/security/armsecurity/governancerule_client.go b/sdk/resourcemanager/security/armsecurity/governancerule_client.go deleted file mode 100644 index 7db7da579719..000000000000 --- a/sdk/resourcemanager/security/armsecurity/governancerule_client.go +++ /dev/null @@ -1,114 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. -// DO NOT EDIT. - -package armsecurity - -import ( - "context" - "errors" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" - "net/url" - "strings" -) - -// GovernanceRuleClient contains the methods for the GovernanceRule group. -// Don't use this type directly, use NewGovernanceRuleClient() instead. -type GovernanceRuleClient struct { - host string - subscriptionID string - pl runtime.Pipeline -} - -// NewGovernanceRuleClient creates a new instance of GovernanceRuleClient with the specified values. -// subscriptionID - Azure subscription ID -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. -func NewGovernanceRuleClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*GovernanceRuleClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) - if err != nil { - return nil, err - } - client := &GovernanceRuleClient{ - subscriptionID: subscriptionID, - host: ep, - pl: pl, - } - return client, nil -} - -// NewListPager - Get a list of all relevant governanceRules over a subscription level scope -// Generated from API version 2022-01-01-preview -// options - GovernanceRuleClientListOptions contains the optional parameters for the GovernanceRuleClient.List method. -func (client *GovernanceRuleClient) NewListPager(options *GovernanceRuleClientListOptions) *runtime.Pager[GovernanceRuleClientListResponse] { - return runtime.NewPager(runtime.PagingHandler[GovernanceRuleClientListResponse]{ - More: func(page GovernanceRuleClientListResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *GovernanceRuleClientListResponse) (GovernanceRuleClientListResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listCreateRequest(ctx, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) - } - if err != nil { - return GovernanceRuleClientListResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return GovernanceRuleClientListResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return GovernanceRuleClientListResponse{}, runtime.NewResponseError(resp) - } - return client.listHandleResponse(resp) - }, - }) -} - -// listCreateRequest creates the List request. -func (client *GovernanceRuleClient) listCreateRequest(ctx context.Context, options *GovernanceRuleClientListOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Security/governanceRules" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listHandleResponse handles the List response. -func (client *GovernanceRuleClient) listHandleResponse(resp *http.Response) (GovernanceRuleClientListResponse, error) { - result := GovernanceRuleClientListResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.GovernanceRuleList); err != nil { - return GovernanceRuleClientListResponse{}, err - } - return result, nil -} diff --git a/sdk/resourcemanager/security/armsecurity/governancerule_client_example_test.go b/sdk/resourcemanager/security/armsecurity/governancerule_client_example_test.go deleted file mode 100644 index 989a01b64165..000000000000 --- a/sdk/resourcemanager/security/armsecurity/governancerule_client_example_test.go +++ /dev/null @@ -1,41 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. - -package armsecurity_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/ListBySubscriptionGovernanceRules_example.json -func ExampleGovernanceRuleClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewGovernanceRuleClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/security/armsecurity/governancerules_client.go b/sdk/resourcemanager/security/armsecurity/governancerules_client.go index b8f65daca535..4377ee18c5bd 100644 --- a/sdk/resourcemanager/security/armsecurity/governancerules_client.go +++ b/sdk/resourcemanager/security/armsecurity/governancerules_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,48 +24,41 @@ import ( // GovernanceRulesClient contains the methods for the GovernanceRules group. // Don't use this type directly, use NewGovernanceRulesClient() instead. type GovernanceRulesClient struct { - host string - subscriptionID string - pl runtime.Pipeline + internal *arm.Client } // NewGovernanceRulesClient creates a new instance of GovernanceRulesClient with the specified values. -// subscriptionID - Azure subscription ID -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. -func NewGovernanceRulesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*GovernanceRulesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewGovernanceRulesClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*GovernanceRulesClient, error) { + cl, err := arm.NewClient(moduleName+".GovernanceRulesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &GovernanceRulesClient{ - subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } -// CreateOrUpdate - Creates or update a security GovernanceRule on the given subscription. +// CreateOrUpdate - Creates or updates a governance rule over a given scope // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-01-preview -// ruleID - The security GovernanceRule key - unique key for the standard GovernanceRule -// governanceRule - GovernanceRule over a subscription scope -// options - GovernanceRulesClientCreateOrUpdateOptions contains the optional parameters for the GovernanceRulesClient.CreateOrUpdate -// method. -func (client *GovernanceRulesClient) CreateOrUpdate(ctx context.Context, ruleID string, governanceRule GovernanceRule, options *GovernanceRulesClientCreateOrUpdateOptions) (GovernanceRulesClientCreateOrUpdateResponse, error) { - req, err := client.createOrUpdateCreateRequest(ctx, ruleID, governanceRule, options) +// - scope - The scope of the Governance rules. Valid scopes are: management group (format: 'providers/Microsoft.Management/managementGroups/{managementGroup}'), +// subscription (format: +// 'subscriptions/{subscriptionId}'), or security connector (format: +// 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})' +// - ruleID - The governance rule key - unique key for the standard governance rule (GUID) +// - governanceRule - Governance rule over a given scope +// - options - GovernanceRulesClientCreateOrUpdateOptions contains the optional parameters for the GovernanceRulesClient.CreateOrUpdate +// method. +func (client *GovernanceRulesClient) CreateOrUpdate(ctx context.Context, scope string, ruleID string, governanceRule GovernanceRule, options *GovernanceRulesClientCreateOrUpdateOptions) (GovernanceRulesClientCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, scope, ruleID, governanceRule, options) if err != nil { return GovernanceRulesClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return GovernanceRulesClientCreateOrUpdateResponse{}, err } @@ -78,17 +69,17 @@ func (client *GovernanceRulesClient) CreateOrUpdate(ctx context.Context, ruleID } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *GovernanceRulesClient) createOrUpdateCreateRequest(ctx context.Context, ruleID string, governanceRule GovernanceRule, options *GovernanceRulesClientCreateOrUpdateOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Security/governanceRules/{ruleId}" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") +func (client *GovernanceRulesClient) createOrUpdateCreateRequest(ctx context.Context, scope string, ruleID string, governanceRule GovernanceRule, options *GovernanceRulesClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/{scope}/providers/Microsoft.Security/governanceRules/{ruleId}" + if scope == "" { + return nil, errors.New("parameter scope cannot be empty") } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + urlPath = strings.ReplaceAll(urlPath, "{scope}", url.PathEscape(scope)) if ruleID == "" { return nil, errors.New("parameter ruleID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{ruleId}", url.PathEscape(ruleID)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -108,38 +99,62 @@ func (client *GovernanceRulesClient) createOrUpdateHandleResponse(resp *http.Res return result, nil } -// Delete - Delete a GovernanceRule over a given scope +// BeginDelete - Delete a Governance rule over a given scope // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-01-preview -// ruleID - The security GovernanceRule key - unique key for the standard GovernanceRule -// options - GovernanceRulesClientDeleteOptions contains the optional parameters for the GovernanceRulesClient.Delete method. -func (client *GovernanceRulesClient) Delete(ctx context.Context, ruleID string, options *GovernanceRulesClientDeleteOptions) (GovernanceRulesClientDeleteResponse, error) { - req, err := client.deleteCreateRequest(ctx, ruleID, options) +// - scope - The scope of the Governance rules. Valid scopes are: management group (format: 'providers/Microsoft.Management/managementGroups/{managementGroup}'), +// subscription (format: +// 'subscriptions/{subscriptionId}'), or security connector (format: +// 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})' +// - ruleID - The governance rule key - unique key for the standard governance rule (GUID) +// - options - GovernanceRulesClientBeginDeleteOptions contains the optional parameters for the GovernanceRulesClient.BeginDelete +// method. +func (client *GovernanceRulesClient) BeginDelete(ctx context.Context, scope string, ruleID string, options *GovernanceRulesClientBeginDeleteOptions) (*runtime.Poller[GovernanceRulesClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, scope, ruleID, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[GovernanceRulesClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + } else { + return runtime.NewPollerFromResumeToken[GovernanceRulesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Delete - Delete a Governance rule over a given scope +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-01-01-preview +func (client *GovernanceRulesClient) deleteOperation(ctx context.Context, scope string, ruleID string, options *GovernanceRulesClientBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, scope, ruleID, options) if err != nil { - return GovernanceRulesClientDeleteResponse{}, err + return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { - return GovernanceRulesClientDeleteResponse{}, err + return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { - return GovernanceRulesClientDeleteResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, runtime.NewResponseError(resp) } - return GovernanceRulesClientDeleteResponse{}, nil + return resp, nil } // deleteCreateRequest creates the Delete request. -func (client *GovernanceRulesClient) deleteCreateRequest(ctx context.Context, ruleID string, options *GovernanceRulesClientDeleteOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Security/governanceRules/{ruleId}" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") +func (client *GovernanceRulesClient) deleteCreateRequest(ctx context.Context, scope string, ruleID string, options *GovernanceRulesClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/{scope}/providers/Microsoft.Security/governanceRules/{ruleId}" + if scope == "" { + return nil, errors.New("parameter scope cannot be empty") } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + urlPath = strings.ReplaceAll(urlPath, "{scope}", url.PathEscape(scope)) if ruleID == "" { return nil, errors.New("parameter ruleID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{ruleId}", url.PathEscape(ruleID)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -149,17 +164,91 @@ func (client *GovernanceRulesClient) deleteCreateRequest(ctx context.Context, ru return req, nil } -// Get - Get a specific governanceRule for the requested scope by ruleId +// BeginExecute - Execute a governance rule // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-01-preview -// ruleID - The security GovernanceRule key - unique key for the standard GovernanceRule -// options - GovernanceRulesClientGetOptions contains the optional parameters for the GovernanceRulesClient.Get method. -func (client *GovernanceRulesClient) Get(ctx context.Context, ruleID string, options *GovernanceRulesClientGetOptions) (GovernanceRulesClientGetResponse, error) { - req, err := client.getCreateRequest(ctx, ruleID, options) +// - scope - The scope of the Governance rules. Valid scopes are: management group (format: 'providers/Microsoft.Management/managementGroups/{managementGroup}'), +// subscription (format: +// 'subscriptions/{subscriptionId}'), or security connector (format: +// 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})' +// - ruleID - The governance rule key - unique key for the standard governance rule (GUID) +// - options - GovernanceRulesClientBeginExecuteOptions contains the optional parameters for the GovernanceRulesClient.BeginExecute +// method. +func (client *GovernanceRulesClient) BeginExecute(ctx context.Context, scope string, ruleID string, options *GovernanceRulesClientBeginExecuteOptions) (*runtime.Poller[GovernanceRulesClientExecuteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.execute(ctx, scope, ruleID, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[GovernanceRulesClientExecuteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + } else { + return runtime.NewPollerFromResumeToken[GovernanceRulesClientExecuteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Execute - Execute a governance rule +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-01-01-preview +func (client *GovernanceRulesClient) execute(ctx context.Context, scope string, ruleID string, options *GovernanceRulesClientBeginExecuteOptions) (*http.Response, error) { + req, err := client.executeCreateRequest(ctx, scope, ruleID, options) + if err != nil { + return nil, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusAccepted) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// executeCreateRequest creates the Execute request. +func (client *GovernanceRulesClient) executeCreateRequest(ctx context.Context, scope string, ruleID string, options *GovernanceRulesClientBeginExecuteOptions) (*policy.Request, error) { + urlPath := "/{scope}/providers/Microsoft.Security/governanceRules/{ruleId}/execute" + if scope == "" { + return nil, errors.New("parameter scope cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scope}", url.PathEscape(scope)) + if ruleID == "" { + return nil, errors.New("parameter ruleID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{ruleId}", url.PathEscape(ruleID)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-01-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if options != nil && options.ExecuteGovernanceRuleParams != nil { + return req, runtime.MarshalAsJSON(req, *options.ExecuteGovernanceRuleParams) + } + return req, nil +} + +// Get - Get a specific governance rule for the requested scope by ruleId +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-01-01-preview +// - scope - The scope of the Governance rules. Valid scopes are: management group (format: 'providers/Microsoft.Management/managementGroups/{managementGroup}'), +// subscription (format: +// 'subscriptions/{subscriptionId}'), or security connector (format: +// 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})' +// - ruleID - The governance rule key - unique key for the standard governance rule (GUID) +// - options - GovernanceRulesClientGetOptions contains the optional parameters for the GovernanceRulesClient.Get method. +func (client *GovernanceRulesClient) Get(ctx context.Context, scope string, ruleID string, options *GovernanceRulesClientGetOptions) (GovernanceRulesClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, scope, ruleID, options) if err != nil { return GovernanceRulesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return GovernanceRulesClientGetResponse{}, err } @@ -170,17 +259,17 @@ func (client *GovernanceRulesClient) Get(ctx context.Context, ruleID string, opt } // getCreateRequest creates the Get request. -func (client *GovernanceRulesClient) getCreateRequest(ctx context.Context, ruleID string, options *GovernanceRulesClientGetOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Security/governanceRules/{ruleId}" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") +func (client *GovernanceRulesClient) getCreateRequest(ctx context.Context, scope string, ruleID string, options *GovernanceRulesClientGetOptions) (*policy.Request, error) { + urlPath := "/{scope}/providers/Microsoft.Security/governanceRules/{ruleId}" + if scope == "" { + return nil, errors.New("parameter scope cannot be empty") } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + urlPath = strings.ReplaceAll(urlPath, "{scope}", url.PathEscape(scope)) if ruleID == "" { return nil, errors.New("parameter ruleID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{ruleId}", url.PathEscape(ruleID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -200,64 +289,51 @@ func (client *GovernanceRulesClient) getHandleResponse(resp *http.Response) (Gov return result, nil } -// BeginRuleIDExecuteSingleSecurityConnector - Execute a security GovernanceRule on the given security connector. -// If the operation fails it returns an *azcore.ResponseError type. +// NewListPager - Get a list of all relevant governance rules over a scope +// // Generated from API version 2022-01-01-preview -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// securityConnectorName - The security connector name. -// ruleID - The security GovernanceRule key - unique key for the standard GovernanceRule -// options - GovernanceRulesClientBeginRuleIDExecuteSingleSecurityConnectorOptions contains the optional parameters for the -// GovernanceRulesClient.BeginRuleIDExecuteSingleSecurityConnector method. -func (client *GovernanceRulesClient) BeginRuleIDExecuteSingleSecurityConnector(ctx context.Context, resourceGroupName string, securityConnectorName string, ruleID string, options *GovernanceRulesClientBeginRuleIDExecuteSingleSecurityConnectorOptions) (*runtime.Poller[GovernanceRulesClientRuleIDExecuteSingleSecurityConnectorResponse], error) { - if options == nil || options.ResumeToken == "" { - resp, err := client.ruleIDExecuteSingleSecurityConnector(ctx, resourceGroupName, securityConnectorName, ruleID, options) - if err != nil { - return nil, err - } - return runtime.NewPoller[GovernanceRulesClientRuleIDExecuteSingleSecurityConnectorResponse](resp, client.pl, nil) - } else { - return runtime.NewPollerFromResumeToken[GovernanceRulesClientRuleIDExecuteSingleSecurityConnectorResponse](options.ResumeToken, client.pl, nil) - } +// - scope - The scope of the Governance rules. Valid scopes are: management group (format: 'providers/Microsoft.Management/managementGroups/{managementGroup}'), +// subscription (format: +// 'subscriptions/{subscriptionId}'), or security connector (format: +// 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})' +// - options - GovernanceRulesClientListOptions contains the optional parameters for the GovernanceRulesClient.NewListPager +// method. +func (client *GovernanceRulesClient) NewListPager(scope string, options *GovernanceRulesClientListOptions) *runtime.Pager[GovernanceRulesClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[GovernanceRulesClientListResponse]{ + More: func(page GovernanceRulesClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *GovernanceRulesClientListResponse) (GovernanceRulesClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, scope, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return GovernanceRulesClientListResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return GovernanceRulesClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return GovernanceRulesClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) } -// RuleIDExecuteSingleSecurityConnector - Execute a security GovernanceRule on the given security connector. -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-01-01-preview -func (client *GovernanceRulesClient) ruleIDExecuteSingleSecurityConnector(ctx context.Context, resourceGroupName string, securityConnectorName string, ruleID string, options *GovernanceRulesClientBeginRuleIDExecuteSingleSecurityConnectorOptions) (*http.Response, error) { - req, err := client.ruleIDExecuteSingleSecurityConnectorCreateRequest(ctx, resourceGroupName, securityConnectorName, ruleID, options) - if err != nil { - return nil, err - } - resp, err := client.pl.Do(req) - if err != nil { - return nil, err - } - if !runtime.HasStatusCode(resp, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) - } - return resp, nil -} - -// ruleIDExecuteSingleSecurityConnectorCreateRequest creates the RuleIDExecuteSingleSecurityConnector request. -func (client *GovernanceRulesClient) ruleIDExecuteSingleSecurityConnectorCreateRequest(ctx context.Context, resourceGroupName string, securityConnectorName string, ruleID string, options *GovernanceRulesClientBeginRuleIDExecuteSingleSecurityConnectorOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/providers/Microsoft.Security/governanceRules/{ruleId}/execute" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if securityConnectorName == "" { - return nil, errors.New("parameter securityConnectorName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{securityConnectorName}", url.PathEscape(securityConnectorName)) - if ruleID == "" { - return nil, errors.New("parameter ruleID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{ruleId}", url.PathEscape(ruleID)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) +// listCreateRequest creates the List request. +func (client *GovernanceRulesClient) listCreateRequest(ctx context.Context, scope string, options *GovernanceRulesClientListOptions) (*policy.Request, error) { + urlPath := "/{scope}/providers/Microsoft.Security/governanceRules" + if scope == "" { + return nil, errors.New("parameter scope cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scope}", url.PathEscape(scope)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -265,60 +341,61 @@ func (client *GovernanceRulesClient) ruleIDExecuteSingleSecurityConnectorCreateR reqQP.Set("api-version", "2022-01-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - if options != nil && options.ExecuteGovernanceRuleParams != nil { - return req, runtime.MarshalAsJSON(req, *options.ExecuteGovernanceRuleParams) - } return req, nil } -// BeginRuleIDExecuteSingleSubscription - Execute a security GovernanceRule on the given subscription. -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-01-01-preview -// ruleID - The security GovernanceRule key - unique key for the standard GovernanceRule -// options - GovernanceRulesClientBeginRuleIDExecuteSingleSubscriptionOptions contains the optional parameters for the GovernanceRulesClient.BeginRuleIDExecuteSingleSubscription -// method. -func (client *GovernanceRulesClient) BeginRuleIDExecuteSingleSubscription(ctx context.Context, ruleID string, options *GovernanceRulesClientBeginRuleIDExecuteSingleSubscriptionOptions) (*runtime.Poller[GovernanceRulesClientRuleIDExecuteSingleSubscriptionResponse], error) { - if options == nil || options.ResumeToken == "" { - resp, err := client.ruleIDExecuteSingleSubscription(ctx, ruleID, options) - if err != nil { - return nil, err - } - return runtime.NewPoller[GovernanceRulesClientRuleIDExecuteSingleSubscriptionResponse](resp, client.pl, nil) - } else { - return runtime.NewPollerFromResumeToken[GovernanceRulesClientRuleIDExecuteSingleSubscriptionResponse](options.ResumeToken, client.pl, nil) +// listHandleResponse handles the List response. +func (client *GovernanceRulesClient) listHandleResponse(resp *http.Response) (GovernanceRulesClientListResponse, error) { + result := GovernanceRulesClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.GovernanceRuleList); err != nil { + return GovernanceRulesClientListResponse{}, err } + return result, nil } -// RuleIDExecuteSingleSubscription - Execute a security GovernanceRule on the given subscription. +// OperationResults - Get governance rules long run operation result for the requested scope by ruleId and operationId // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-01-preview -func (client *GovernanceRulesClient) ruleIDExecuteSingleSubscription(ctx context.Context, ruleID string, options *GovernanceRulesClientBeginRuleIDExecuteSingleSubscriptionOptions) (*http.Response, error) { - req, err := client.ruleIDExecuteSingleSubscriptionCreateRequest(ctx, ruleID, options) +// - scope - The scope of the Governance rules. Valid scopes are: management group (format: 'providers/Microsoft.Management/managementGroups/{managementGroup}'), +// subscription (format: +// 'subscriptions/{subscriptionId}'), or security connector (format: +// 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})' +// - ruleID - The governance rule key - unique key for the standard governance rule (GUID) +// - operationID - The governance rule long running operation unique key +// - options - GovernanceRulesClientOperationResultsOptions contains the optional parameters for the GovernanceRulesClient.OperationResults +// method. +func (client *GovernanceRulesClient) OperationResults(ctx context.Context, scope string, ruleID string, operationID string, options *GovernanceRulesClientOperationResultsOptions) (GovernanceRulesClientOperationResultsResponse, error) { + req, err := client.operationResultsCreateRequest(ctx, scope, ruleID, operationID, options) if err != nil { - return nil, err + return GovernanceRulesClientOperationResultsResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { - return nil, err + return GovernanceRulesClientOperationResultsResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { + return GovernanceRulesClientOperationResultsResponse{}, runtime.NewResponseError(resp) } - return resp, nil + return client.operationResultsHandleResponse(resp) } -// ruleIDExecuteSingleSubscriptionCreateRequest creates the RuleIDExecuteSingleSubscription request. -func (client *GovernanceRulesClient) ruleIDExecuteSingleSubscriptionCreateRequest(ctx context.Context, ruleID string, options *GovernanceRulesClientBeginRuleIDExecuteSingleSubscriptionOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Security/governanceRules/{ruleId}/execute" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") +// operationResultsCreateRequest creates the OperationResults request. +func (client *GovernanceRulesClient) operationResultsCreateRequest(ctx context.Context, scope string, ruleID string, operationID string, options *GovernanceRulesClientOperationResultsOptions) (*policy.Request, error) { + urlPath := "/{scope}/providers/Microsoft.Security/governanceRules/{ruleId}/operationResults/{operationId}" + if scope == "" { + return nil, errors.New("parameter scope cannot be empty") } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + urlPath = strings.ReplaceAll(urlPath, "{scope}", url.PathEscape(scope)) if ruleID == "" { return nil, errors.New("parameter ruleID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{ruleId}", url.PathEscape(ruleID)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + if operationID == "" { + return nil, errors.New("parameter operationID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -326,8 +403,17 @@ func (client *GovernanceRulesClient) ruleIDExecuteSingleSubscriptionCreateReques reqQP.Set("api-version", "2022-01-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - if options != nil && options.ExecuteGovernanceRuleParams != nil { - return req, runtime.MarshalAsJSON(req, *options.ExecuteGovernanceRuleParams) - } return req, nil } + +// operationResultsHandleResponse handles the OperationResults response. +func (client *GovernanceRulesClient) operationResultsHandleResponse(resp *http.Response) (GovernanceRulesClientOperationResultsResponse, error) { + result := GovernanceRulesClientOperationResultsResponse{} + if val := resp.Header.Get("location"); val != "" { + result.Location = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.OperationResultAutoGenerated); err != nil { + return GovernanceRulesClientOperationResultsResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/security/armsecurity/governancerules_client_example_test.go b/sdk/resourcemanager/security/armsecurity/governancerules_client_example_test.go deleted file mode 100644 index 44f38d51d6bf..000000000000 --- a/sdk/resourcemanager/security/armsecurity/governancerules_client_example_test.go +++ /dev/null @@ -1,144 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. - -package armsecurity_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/GetGovernanceRule_example.json -func ExampleGovernanceRulesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewGovernanceRulesClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "ad9a8e26-29d9-4829-bb30-e597a58cdbb8", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/PutGovernanceRule_example.json -func ExampleGovernanceRulesClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewGovernanceRulesClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdate(ctx, "ad9a8e26-29d9-4829-bb30-e597a58cdbb8", armsecurity.GovernanceRule{ - Properties: &armsecurity.GovernanceRuleProperties{ - Description: to.Ptr("A rule on critical recommendations"), - ConditionSets: []interface{}{ - map[string]interface{}{ - "conditions": []interface{}{ - map[string]interface{}{ - "operator": "In", - "property": "$.AssessmentKey", - "value": "[\"b1cd27e0-4ecc-4246-939f-49c426d9d72f\", \"fe83f80b-073d-4ccf-93d9-6797eb870201\"]", - }, - }, - }}, - DisplayName: to.Ptr("Admin's rule"), - GovernanceEmailNotification: &armsecurity.GovernanceRuleEmailNotification{ - DisableManagerEmailNotification: to.Ptr(false), - DisableOwnerEmailNotification: to.Ptr(false), - }, - IsDisabled: to.Ptr(false), - IsGracePeriod: to.Ptr(true), - OwnerSource: &armsecurity.GovernanceRuleOwnerSource{ - Type: to.Ptr(armsecurity.GovernanceRuleOwnerSourceTypeManually), - Value: to.Ptr("user@contoso.com"), - }, - RemediationTimeframe: to.Ptr("7.00:00:00"), - RulePriority: to.Ptr[int32](200), - RuleType: to.Ptr(armsecurity.GovernanceRuleTypeIntegrated), - SourceResourceType: to.Ptr(armsecurity.GovernanceRuleSourceResourceTypeAssessments), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/DeleteGovernanceRule_example.json -func ExampleGovernanceRulesClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewGovernanceRulesClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, "ad9a8e26-29d9-4829-bb30-e597a58cdbb8", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/PostGovernanceRule_example.json -func ExampleGovernanceRulesClient_BeginRuleIDExecuteSingleSubscription() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewGovernanceRulesClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginRuleIDExecuteSingleSubscription(ctx, "ad9a8e26-29d9-4829-bb30-e597a58cdbb8", &armsecurity.GovernanceRulesClientBeginRuleIDExecuteSingleSubscriptionOptions{ExecuteGovernanceRuleParams: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/PostSecurityConnectorGovernanceRule_example.json -func ExampleGovernanceRulesClient_BeginRuleIDExecuteSingleSecurityConnector() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewGovernanceRulesClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginRuleIDExecuteSingleSecurityConnector(ctx, "gcpResourceGroup", "gcpconnector", "ad9a8e26-29d9-4829-bb30-e597a58cdbb8", &armsecurity.GovernanceRulesClientBeginRuleIDExecuteSingleSecurityConnectorOptions{ExecuteGovernanceRuleParams: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} diff --git a/sdk/resourcemanager/security/armsecurity/healthreport_client.go b/sdk/resourcemanager/security/armsecurity/healthreport_client.go new file mode 100644 index 000000000000..781f34614bce --- /dev/null +++ b/sdk/resourcemanager/security/armsecurity/healthreport_client.go @@ -0,0 +1,92 @@ +//go:build go1.18 +// +build go1.18 + +// 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. +// DO NOT EDIT. + +package armsecurity + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// HealthReportClient contains the methods for the HealthReport group. +// Don't use this type directly, use NewHealthReportClient() instead. +type HealthReportClient struct { + internal *arm.Client +} + +// NewHealthReportClient creates a new instance of HealthReportClient with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewHealthReportClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*HealthReportClient, error) { + cl, err := arm.NewClient(moduleName+".HealthReportClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &HealthReportClient{ + internal: cl, + } + return client, nil +} + +// Get - Get health report of resource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-02-01-preview +// - resourceID - The identifier of the resource. +// - healthReportName - The health report Key - Unique key for the health report type +// - options - HealthReportClientGetOptions contains the optional parameters for the HealthReportClient.Get method. +func (client *HealthReportClient) Get(ctx context.Context, resourceID string, healthReportName string, options *HealthReportClientGetOptions) (HealthReportClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceID, healthReportName, options) + if err != nil { + return HealthReportClientGetResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return HealthReportClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return HealthReportClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *HealthReportClient) getCreateRequest(ctx context.Context, resourceID string, healthReportName string, options *HealthReportClientGetOptions) (*policy.Request, error) { + urlPath := "/{resourceId}/providers/Microsoft.Security/healthReports/{healthReportName}" + urlPath = strings.ReplaceAll(urlPath, "{resourceId}", resourceID) + if healthReportName == "" { + return nil, errors.New("parameter healthReportName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{healthReportName}", url.PathEscape(healthReportName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-02-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *HealthReportClient) getHandleResponse(resp *http.Response) (HealthReportClientGetResponse, error) { + result := HealthReportClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.HealthReport); err != nil { + return HealthReportClientGetResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/security/armsecurity/healthreports_client.go b/sdk/resourcemanager/security/armsecurity/healthreports_client.go new file mode 100644 index 000000000000..12bb83ab50f2 --- /dev/null +++ b/sdk/resourcemanager/security/armsecurity/healthreports_client.go @@ -0,0 +1,99 @@ +//go:build go1.18 +// +build go1.18 + +// 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. +// DO NOT EDIT. + +package armsecurity + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "strings" +) + +// HealthReportsClient contains the methods for the HealthReports group. +// Don't use this type directly, use NewHealthReportsClient() instead. +type HealthReportsClient struct { + internal *arm.Client +} + +// NewHealthReportsClient creates a new instance of HealthReportsClient with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewHealthReportsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*HealthReportsClient, error) { + cl, err := arm.NewClient(moduleName+".HealthReportsClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &HealthReportsClient{ + internal: cl, + } + return client, nil +} + +// NewListPager - Get a list of all health reports inside a scope. Valid scopes are: subscription (format: 'subscriptions/{subscriptionId}'), +// or security connector (format: +// 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})' +// +// Generated from API version 2023-02-01-preview +// - scope - The scope at which the operation is performed. +// - options - HealthReportsClientListOptions contains the optional parameters for the HealthReportsClient.NewListPager method. +func (client *HealthReportsClient) NewListPager(scope string, options *HealthReportsClientListOptions) *runtime.Pager[HealthReportsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[HealthReportsClientListResponse]{ + More: func(page HealthReportsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *HealthReportsClientListResponse) (HealthReportsClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, scope, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return HealthReportsClientListResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return HealthReportsClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return HealthReportsClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *HealthReportsClient) listCreateRequest(ctx context.Context, scope string, options *HealthReportsClientListOptions) (*policy.Request, error) { + urlPath := "/{scope}/providers/Microsoft.Security/healthReports" + urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-02-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *HealthReportsClient) listHandleResponse(resp *http.Response) (HealthReportsClientListResponse, error) { + result := HealthReportsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.HealthReportsList); err != nil { + return HealthReportsClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/security/armsecurity/informationprotectionpolicies_client.go b/sdk/resourcemanager/security/armsecurity/informationprotectionpolicies_client.go index 599e9491c74b..a6a3bbcefbba 100644 --- a/sdk/resourcemanager/security/armsecurity/informationprotectionpolicies_client.go +++ b/sdk/resourcemanager/security/armsecurity/informationprotectionpolicies_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,47 +24,39 @@ import ( // InformationProtectionPoliciesClient contains the methods for the InformationProtectionPolicies group. // Don't use this type directly, use NewInformationProtectionPoliciesClient() instead. type InformationProtectionPoliciesClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewInformationProtectionPoliciesClient creates a new instance of InformationProtectionPoliciesClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewInformationProtectionPoliciesClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*InformationProtectionPoliciesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".InformationProtectionPoliciesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &InformationProtectionPoliciesClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } // CreateOrUpdate - Details of the information protection policy. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-08-01-preview -// scope - Scope of the query, can be subscription (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group -// (/providers/Microsoft.Management/managementGroups/mgName). -// informationProtectionPolicyName - Name of the information protection policy. -// informationProtectionPolicy - Information protection policy. -// options - InformationProtectionPoliciesClientCreateOrUpdateOptions contains the optional parameters for the InformationProtectionPoliciesClient.CreateOrUpdate -// method. +// - scope - Scope of the query, can be subscription (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group +// (/providers/Microsoft.Management/managementGroups/mgName). +// - informationProtectionPolicyName - Name of the information protection policy. +// - informationProtectionPolicy - Information protection policy. +// - options - InformationProtectionPoliciesClientCreateOrUpdateOptions contains the optional parameters for the InformationProtectionPoliciesClient.CreateOrUpdate +// method. func (client *InformationProtectionPoliciesClient) CreateOrUpdate(ctx context.Context, scope string, informationProtectionPolicyName InformationProtectionPolicyName, informationProtectionPolicy InformationProtectionPolicy, options *InformationProtectionPoliciesClientCreateOrUpdateOptions) (InformationProtectionPoliciesClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, scope, informationProtectionPolicyName, informationProtectionPolicy, options) if err != nil { return InformationProtectionPoliciesClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return InformationProtectionPoliciesClientCreateOrUpdateResponse{}, err } @@ -84,7 +74,7 @@ func (client *InformationProtectionPoliciesClient) createOrUpdateCreateRequest(c return nil, errors.New("parameter informationProtectionPolicyName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{informationProtectionPolicyName}", url.PathEscape(string(informationProtectionPolicyName))) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -106,18 +96,19 @@ func (client *InformationProtectionPoliciesClient) createOrUpdateHandleResponse( // Get - Details of the information protection policy. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-08-01-preview -// scope - Scope of the query, can be subscription (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group -// (/providers/Microsoft.Management/managementGroups/mgName). -// informationProtectionPolicyName - Name of the information protection policy. -// options - InformationProtectionPoliciesClientGetOptions contains the optional parameters for the InformationProtectionPoliciesClient.Get -// method. +// - scope - Scope of the query, can be subscription (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group +// (/providers/Microsoft.Management/managementGroups/mgName). +// - informationProtectionPolicyName - Name of the information protection policy. +// - options - InformationProtectionPoliciesClientGetOptions contains the optional parameters for the InformationProtectionPoliciesClient.Get +// method. func (client *InformationProtectionPoliciesClient) Get(ctx context.Context, scope string, informationProtectionPolicyName InformationProtectionPolicyName, options *InformationProtectionPoliciesClientGetOptions) (InformationProtectionPoliciesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, scope, informationProtectionPolicyName, options) if err != nil { return InformationProtectionPoliciesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return InformationProtectionPoliciesClientGetResponse{}, err } @@ -135,7 +126,7 @@ func (client *InformationProtectionPoliciesClient) getCreateRequest(ctx context. return nil, errors.New("parameter informationProtectionPolicyName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{informationProtectionPolicyName}", url.PathEscape(string(informationProtectionPolicyName))) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -156,11 +147,12 @@ func (client *InformationProtectionPoliciesClient) getHandleResponse(resp *http. } // NewListPager - Information protection policies of a specific management group. +// // Generated from API version 2017-08-01-preview -// scope - Scope of the query, can be subscription (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group -// (/providers/Microsoft.Management/managementGroups/mgName). -// options - InformationProtectionPoliciesClientListOptions contains the optional parameters for the InformationProtectionPoliciesClient.List -// method. +// - scope - Scope of the query, can be subscription (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group +// (/providers/Microsoft.Management/managementGroups/mgName). +// - options - InformationProtectionPoliciesClientListOptions contains the optional parameters for the InformationProtectionPoliciesClient.NewListPager +// method. func (client *InformationProtectionPoliciesClient) NewListPager(scope string, options *InformationProtectionPoliciesClientListOptions) *runtime.Pager[InformationProtectionPoliciesClientListResponse] { return runtime.NewPager(runtime.PagingHandler[InformationProtectionPoliciesClientListResponse]{ More: func(page InformationProtectionPoliciesClientListResponse) bool { @@ -177,7 +169,7 @@ func (client *InformationProtectionPoliciesClient) NewListPager(scope string, op if err != nil { return InformationProtectionPoliciesClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return InformationProtectionPoliciesClientListResponse{}, err } @@ -193,7 +185,7 @@ func (client *InformationProtectionPoliciesClient) NewListPager(scope string, op func (client *InformationProtectionPoliciesClient) listCreateRequest(ctx context.Context, scope string, options *InformationProtectionPoliciesClientListOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.Security/informationProtectionPolicies" urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/security/armsecurity/informationprotectionpolicies_client_example_test.go b/sdk/resourcemanager/security/armsecurity/informationprotectionpolicies_client_example_test.go deleted file mode 100644 index 4348e8472f64..000000000000 --- a/sdk/resourcemanager/security/armsecurity/informationprotectionpolicies_client_example_test.go +++ /dev/null @@ -1,147 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. - -package armsecurity_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2017-08-01-preview/examples/InformationProtectionPolicies/GetCustomInformationProtectionPolicy_example.json -func ExampleInformationProtectionPoliciesClient_Get_getTheCustomizedInformationProtectionPolicyForAManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewInformationProtectionPoliciesClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "providers/Microsoft.Management/managementGroups/148059f7-faf3-49a6-ba35-85122112291e", armsecurity.InformationProtectionPolicyNameCustom, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2017-08-01-preview/examples/InformationProtectionPolicies/GetEffectiveInformationProtectionPolicy_example.json -func ExampleInformationProtectionPoliciesClient_Get_getTheEffectiveInformationProtectionPolicyForAManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewInformationProtectionPoliciesClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "providers/Microsoft.Management/managementGroups/148059f7-faf3-49a6-ba35-85122112291e", armsecurity.InformationProtectionPolicyNameEffective, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2017-08-01-preview/examples/InformationProtectionPolicies/CreateOrUpdateInformationProtectionPolicy_example.json -func ExampleInformationProtectionPoliciesClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewInformationProtectionPoliciesClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdate(ctx, "providers/Microsoft.Management/managementGroups/148059f7-faf3-49a6-ba35-85122112291e", armsecurity.InformationProtectionPolicyNameCustom, armsecurity.InformationProtectionPolicy{ - Properties: &armsecurity.InformationProtectionPolicyProperties{ - InformationTypes: map[string]*armsecurity.InformationType{ - "3bf35491-99b8-41f2-86d5-c1200a7df658": { - Custom: to.Ptr(true), - DisplayName: to.Ptr("Custom"), - Enabled: to.Ptr(true), - Keywords: []*armsecurity.InformationProtectionKeyword{ - { - CanBeNumeric: to.Ptr(true), - Custom: to.Ptr(true), - Pattern: to.Ptr("%custom%"), - }}, - Order: to.Ptr[int32](1400), - RecommendedLabelID: to.Ptr("7aa516c7-5a53-4857-bc6e-6808c6acd542"), - }, - "7fb9419d-2473-4ad8-8e11-b25cc8cf6a07": { - Custom: to.Ptr(false), - DisplayName: to.Ptr("Networking"), - Enabled: to.Ptr(true), - Keywords: []*armsecurity.InformationProtectionKeyword{ - { - CanBeNumeric: to.Ptr(false), - Custom: to.Ptr(true), - Pattern: to.Ptr("%networking%"), - }}, - Order: to.Ptr[int32](100), - RecommendedLabelID: to.Ptr("575739d2-3d53-4df0-9042-4c7772d5c7b1"), - }, - }, - Labels: map[string]*armsecurity.SensitivityLabel{ - "1345da73-bc5a-4a8f-b7dd-3820eb713da8": { - DisplayName: to.Ptr("Public"), - Enabled: to.Ptr(true), - Order: to.Ptr[int32](100), - }, - "575739d2-3d53-4df0-9042-4c7772d5c7b1": { - DisplayName: to.Ptr("Confidential"), - Enabled: to.Ptr(true), - Order: to.Ptr[int32](300), - }, - "7aa516c7-5a53-4857-bc6e-6808c6acd542": { - DisplayName: to.Ptr("General"), - Enabled: to.Ptr(true), - Order: to.Ptr[int32](200), - }, - }, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2017-08-01-preview/examples/InformationProtectionPolicies/ListInformationProtectionPolicies_example.json -func ExampleInformationProtectionPoliciesClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewInformationProtectionPoliciesClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("providers/Microsoft.Management/managementGroups/148059f7-faf3-49a6-ba35-85122112291e", nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/security/armsecurity/ingestionsettings_client.go b/sdk/resourcemanager/security/armsecurity/ingestionsettings_client.go index c3e0e2349fec..6a17f4ddcd7b 100644 --- a/sdk/resourcemanager/security/armsecurity/ingestionsettings_client.go +++ b/sdk/resourcemanager/security/armsecurity/ingestionsettings_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,48 +24,40 @@ import ( // IngestionSettingsClient contains the methods for the IngestionSettings group. // Don't use this type directly, use NewIngestionSettingsClient() instead. type IngestionSettingsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewIngestionSettingsClient creates a new instance of IngestionSettingsClient with the specified values. -// subscriptionID - Azure subscription ID -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure subscription ID +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewIngestionSettingsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*IngestionSettingsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".IngestionSettingsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &IngestionSettingsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Create - Create setting for ingesting security data and logs to correlate with resources associated with the subscription. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-01-15-preview -// ingestionSettingName - Name of the ingestion setting -// ingestionSetting - Ingestion setting object -// options - IngestionSettingsClientCreateOptions contains the optional parameters for the IngestionSettingsClient.Create -// method. +// - ingestionSettingName - Name of the ingestion setting +// - ingestionSetting - Ingestion setting object +// - options - IngestionSettingsClientCreateOptions contains the optional parameters for the IngestionSettingsClient.Create +// method. func (client *IngestionSettingsClient) Create(ctx context.Context, ingestionSettingName string, ingestionSetting IngestionSetting, options *IngestionSettingsClientCreateOptions) (IngestionSettingsClientCreateResponse, error) { req, err := client.createCreateRequest(ctx, ingestionSettingName, ingestionSetting, options) if err != nil { return IngestionSettingsClientCreateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return IngestionSettingsClientCreateResponse{}, err } @@ -88,7 +78,7 @@ func (client *IngestionSettingsClient) createCreateRequest(ctx context.Context, return nil, errors.New("parameter ingestionSettingName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{ingestionSettingName}", url.PathEscape(ingestionSettingName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -110,16 +100,17 @@ func (client *IngestionSettingsClient) createHandleResponse(resp *http.Response) // Delete - Deletes the ingestion settings for this subscription. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-01-15-preview -// ingestionSettingName - Name of the ingestion setting -// options - IngestionSettingsClientDeleteOptions contains the optional parameters for the IngestionSettingsClient.Delete -// method. +// - ingestionSettingName - Name of the ingestion setting +// - options - IngestionSettingsClientDeleteOptions contains the optional parameters for the IngestionSettingsClient.Delete +// method. func (client *IngestionSettingsClient) Delete(ctx context.Context, ingestionSettingName string, options *IngestionSettingsClientDeleteOptions) (IngestionSettingsClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, ingestionSettingName, options) if err != nil { return IngestionSettingsClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return IngestionSettingsClientDeleteResponse{}, err } @@ -140,7 +131,7 @@ func (client *IngestionSettingsClient) deleteCreateRequest(ctx context.Context, return nil, errors.New("parameter ingestionSettingName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{ingestionSettingName}", url.PathEscape(ingestionSettingName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -153,15 +144,16 @@ func (client *IngestionSettingsClient) deleteCreateRequest(ctx context.Context, // Get - Settings for ingesting security data and logs to correlate with resources associated with the subscription. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-01-15-preview -// ingestionSettingName - Name of the ingestion setting -// options - IngestionSettingsClientGetOptions contains the optional parameters for the IngestionSettingsClient.Get method. +// - ingestionSettingName - Name of the ingestion setting +// - options - IngestionSettingsClientGetOptions contains the optional parameters for the IngestionSettingsClient.Get method. func (client *IngestionSettingsClient) Get(ctx context.Context, ingestionSettingName string, options *IngestionSettingsClientGetOptions) (IngestionSettingsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, ingestionSettingName, options) if err != nil { return IngestionSettingsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return IngestionSettingsClientGetResponse{}, err } @@ -182,7 +174,7 @@ func (client *IngestionSettingsClient) getCreateRequest(ctx context.Context, ing return nil, errors.New("parameter ingestionSettingName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{ingestionSettingName}", url.PathEscape(ingestionSettingName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -203,8 +195,10 @@ func (client *IngestionSettingsClient) getHandleResponse(resp *http.Response) (I } // NewListPager - Settings for ingesting security data and logs to correlate with resources associated with the subscription. +// // Generated from API version 2021-01-15-preview -// options - IngestionSettingsClientListOptions contains the optional parameters for the IngestionSettingsClient.List method. +// - options - IngestionSettingsClientListOptions contains the optional parameters for the IngestionSettingsClient.NewListPager +// method. func (client *IngestionSettingsClient) NewListPager(options *IngestionSettingsClientListOptions) *runtime.Pager[IngestionSettingsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[IngestionSettingsClientListResponse]{ More: func(page IngestionSettingsClientListResponse) bool { @@ -221,7 +215,7 @@ func (client *IngestionSettingsClient) NewListPager(options *IngestionSettingsCl if err != nil { return IngestionSettingsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return IngestionSettingsClientListResponse{}, err } @@ -240,7 +234,7 @@ func (client *IngestionSettingsClient) listCreateRequest(ctx context.Context, op return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -262,16 +256,17 @@ func (client *IngestionSettingsClient) listHandleResponse(resp *http.Response) ( // ListConnectionStrings - Connection strings for ingesting security scan logs and data. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-01-15-preview -// ingestionSettingName - Name of the ingestion setting -// options - IngestionSettingsClientListConnectionStringsOptions contains the optional parameters for the IngestionSettingsClient.ListConnectionStrings -// method. +// - ingestionSettingName - Name of the ingestion setting +// - options - IngestionSettingsClientListConnectionStringsOptions contains the optional parameters for the IngestionSettingsClient.ListConnectionStrings +// method. func (client *IngestionSettingsClient) ListConnectionStrings(ctx context.Context, ingestionSettingName string, options *IngestionSettingsClientListConnectionStringsOptions) (IngestionSettingsClientListConnectionStringsResponse, error) { req, err := client.listConnectionStringsCreateRequest(ctx, ingestionSettingName, options) if err != nil { return IngestionSettingsClientListConnectionStringsResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return IngestionSettingsClientListConnectionStringsResponse{}, err } @@ -292,7 +287,7 @@ func (client *IngestionSettingsClient) listConnectionStringsCreateRequest(ctx co return nil, errors.New("parameter ingestionSettingName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{ingestionSettingName}", url.PathEscape(ingestionSettingName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -314,16 +309,17 @@ func (client *IngestionSettingsClient) listConnectionStringsHandleResponse(resp // ListTokens - Returns the token that is used for correlating ingested telemetry with the resources in the subscription. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-01-15-preview -// ingestionSettingName - Name of the ingestion setting -// options - IngestionSettingsClientListTokensOptions contains the optional parameters for the IngestionSettingsClient.ListTokens -// method. +// - ingestionSettingName - Name of the ingestion setting +// - options - IngestionSettingsClientListTokensOptions contains the optional parameters for the IngestionSettingsClient.ListTokens +// method. func (client *IngestionSettingsClient) ListTokens(ctx context.Context, ingestionSettingName string, options *IngestionSettingsClientListTokensOptions) (IngestionSettingsClientListTokensResponse, error) { req, err := client.listTokensCreateRequest(ctx, ingestionSettingName, options) if err != nil { return IngestionSettingsClientListTokensResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return IngestionSettingsClientListTokensResponse{}, err } @@ -344,7 +340,7 @@ func (client *IngestionSettingsClient) listTokensCreateRequest(ctx context.Conte return nil, errors.New("parameter ingestionSettingName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{ingestionSettingName}", url.PathEscape(ingestionSettingName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/security/armsecurity/ingestionsettings_client_example_test.go b/sdk/resourcemanager/security/armsecurity/ingestionsettings_client_example_test.go deleted file mode 100644 index fef619cca476..000000000000 --- a/sdk/resourcemanager/security/armsecurity/ingestionsettings_client_example_test.go +++ /dev/null @@ -1,134 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. - -package armsecurity_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2021-01-15-preview/examples/IngestionSettings/GetIngestionSettings_example.json -func ExampleIngestionSettingsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewIngestionSettingsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2021-01-15-preview/examples/IngestionSettings/GetIngestionSetting_example.json -func ExampleIngestionSettingsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewIngestionSettingsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "default", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2021-01-15-preview/examples/IngestionSettings/CreateIngestionSetting_example.json -func ExampleIngestionSettingsClient_Create() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewIngestionSettingsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Create(ctx, "default", armsecurity.IngestionSetting{}, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2021-01-15-preview/examples/IngestionSettings/DeleteIngestionSetting_example.json -func ExampleIngestionSettingsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewIngestionSettingsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, "default", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2021-01-15-preview/examples/IngestionSettings/ListTokensIngestionSetting_example.json -func ExampleIngestionSettingsClient_ListTokens() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewIngestionSettingsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.ListTokens(ctx, "default", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2021-01-15-preview/examples/IngestionSettings/ListConnectionStrings_example.json -func ExampleIngestionSettingsClient_ListConnectionStrings() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewIngestionSettingsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.ListConnectionStrings(ctx, "default", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/security/armsecurity/iotsecuritysolution_client.go b/sdk/resourcemanager/security/armsecurity/iotsecuritysolution_client.go index 40bfaaddc4de..0825a104a098 100644 --- a/sdk/resourcemanager/security/armsecurity/iotsecuritysolution_client.go +++ b/sdk/resourcemanager/security/armsecurity/iotsecuritysolution_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,49 +24,41 @@ import ( // IotSecuritySolutionClient contains the methods for the IotSecuritySolution group. // Don't use this type directly, use NewIotSecuritySolutionClient() instead. type IotSecuritySolutionClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewIotSecuritySolutionClient creates a new instance of IotSecuritySolutionClient with the specified values. -// subscriptionID - Azure subscription ID -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure subscription ID +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewIotSecuritySolutionClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*IotSecuritySolutionClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".IotSecuritySolutionClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &IotSecuritySolutionClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // CreateOrUpdate - Use this method to create or update yours IoT Security solution // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-08-01 -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// solutionName - The name of the IoT Security solution. -// iotSecuritySolutionData - The security solution data -// options - IotSecuritySolutionClientCreateOrUpdateOptions contains the optional parameters for the IotSecuritySolutionClient.CreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - solutionName - The name of the IoT Security solution. +// - iotSecuritySolutionData - The security solution data +// - options - IotSecuritySolutionClientCreateOrUpdateOptions contains the optional parameters for the IotSecuritySolutionClient.CreateOrUpdate +// method. func (client *IotSecuritySolutionClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, solutionName string, iotSecuritySolutionData IoTSecuritySolutionModel, options *IotSecuritySolutionClientCreateOrUpdateOptions) (IotSecuritySolutionClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, solutionName, iotSecuritySolutionData, options) if err != nil { return IotSecuritySolutionClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return IotSecuritySolutionClientCreateOrUpdateResponse{}, err } @@ -93,7 +83,7 @@ func (client *IotSecuritySolutionClient) createOrUpdateCreateRequest(ctx context return nil, errors.New("parameter solutionName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{solutionName}", url.PathEscape(solutionName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -115,17 +105,18 @@ func (client *IotSecuritySolutionClient) createOrUpdateHandleResponse(resp *http // Delete - Use this method to delete yours IoT Security solution // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-08-01 -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// solutionName - The name of the IoT Security solution. -// options - IotSecuritySolutionClientDeleteOptions contains the optional parameters for the IotSecuritySolutionClient.Delete -// method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - solutionName - The name of the IoT Security solution. +// - options - IotSecuritySolutionClientDeleteOptions contains the optional parameters for the IotSecuritySolutionClient.Delete +// method. func (client *IotSecuritySolutionClient) Delete(ctx context.Context, resourceGroupName string, solutionName string, options *IotSecuritySolutionClientDeleteOptions) (IotSecuritySolutionClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, solutionName, options) if err != nil { return IotSecuritySolutionClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return IotSecuritySolutionClientDeleteResponse{}, err } @@ -150,7 +141,7 @@ func (client *IotSecuritySolutionClient) deleteCreateRequest(ctx context.Context return nil, errors.New("parameter solutionName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{solutionName}", url.PathEscape(solutionName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -163,16 +154,17 @@ func (client *IotSecuritySolutionClient) deleteCreateRequest(ctx context.Context // Get - User this method to get details of a specific IoT Security solution based on solution name // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-08-01 -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// solutionName - The name of the IoT Security solution. -// options - IotSecuritySolutionClientGetOptions contains the optional parameters for the IotSecuritySolutionClient.Get method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - solutionName - The name of the IoT Security solution. +// - options - IotSecuritySolutionClientGetOptions contains the optional parameters for the IotSecuritySolutionClient.Get method. func (client *IotSecuritySolutionClient) Get(ctx context.Context, resourceGroupName string, solutionName string, options *IotSecuritySolutionClientGetOptions) (IotSecuritySolutionClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, solutionName, options) if err != nil { return IotSecuritySolutionClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return IotSecuritySolutionClientGetResponse{}, err } @@ -197,7 +189,7 @@ func (client *IotSecuritySolutionClient) getCreateRequest(ctx context.Context, r return nil, errors.New("parameter solutionName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{solutionName}", url.PathEscape(solutionName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -218,10 +210,11 @@ func (client *IotSecuritySolutionClient) getHandleResponse(resp *http.Response) } // NewListByResourceGroupPager - Use this method to get the list IoT Security solutions organized by resource group. +// // Generated from API version 2019-08-01 -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// options - IotSecuritySolutionClientListByResourceGroupOptions contains the optional parameters for the IotSecuritySolutionClient.ListByResourceGroup -// method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - options - IotSecuritySolutionClientListByResourceGroupOptions contains the optional parameters for the IotSecuritySolutionClient.NewListByResourceGroupPager +// method. func (client *IotSecuritySolutionClient) NewListByResourceGroupPager(resourceGroupName string, options *IotSecuritySolutionClientListByResourceGroupOptions) *runtime.Pager[IotSecuritySolutionClientListByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[IotSecuritySolutionClientListByResourceGroupResponse]{ More: func(page IotSecuritySolutionClientListByResourceGroupResponse) bool { @@ -238,7 +231,7 @@ func (client *IotSecuritySolutionClient) NewListByResourceGroupPager(resourceGro if err != nil { return IotSecuritySolutionClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return IotSecuritySolutionClientListByResourceGroupResponse{}, err } @@ -261,7 +254,7 @@ func (client *IotSecuritySolutionClient) listByResourceGroupCreateRequest(ctx co return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -285,9 +278,10 @@ func (client *IotSecuritySolutionClient) listByResourceGroupHandleResponse(resp } // NewListBySubscriptionPager - Use this method to get the list of IoT Security solutions by subscription. +// // Generated from API version 2019-08-01 -// options - IotSecuritySolutionClientListBySubscriptionOptions contains the optional parameters for the IotSecuritySolutionClient.ListBySubscription -// method. +// - options - IotSecuritySolutionClientListBySubscriptionOptions contains the optional parameters for the IotSecuritySolutionClient.NewListBySubscriptionPager +// method. func (client *IotSecuritySolutionClient) NewListBySubscriptionPager(options *IotSecuritySolutionClientListBySubscriptionOptions) *runtime.Pager[IotSecuritySolutionClientListBySubscriptionResponse] { return runtime.NewPager(runtime.PagingHandler[IotSecuritySolutionClientListBySubscriptionResponse]{ More: func(page IotSecuritySolutionClientListBySubscriptionResponse) bool { @@ -304,7 +298,7 @@ func (client *IotSecuritySolutionClient) NewListBySubscriptionPager(options *Iot if err != nil { return IotSecuritySolutionClientListBySubscriptionResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return IotSecuritySolutionClientListBySubscriptionResponse{}, err } @@ -323,7 +317,7 @@ func (client *IotSecuritySolutionClient) listBySubscriptionCreateRequest(ctx con return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -349,18 +343,19 @@ func (client *IotSecuritySolutionClient) listBySubscriptionHandleResponse(resp * // Update - Use this method to update existing IoT Security solution tags or user defined resources. To update other fields // use the CreateOrUpdate method. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-08-01 -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// solutionName - The name of the IoT Security solution. -// updateIotSecuritySolutionData - The security solution data -// options - IotSecuritySolutionClientUpdateOptions contains the optional parameters for the IotSecuritySolutionClient.Update -// method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - solutionName - The name of the IoT Security solution. +// - updateIotSecuritySolutionData - The security solution data +// - options - IotSecuritySolutionClientUpdateOptions contains the optional parameters for the IotSecuritySolutionClient.Update +// method. func (client *IotSecuritySolutionClient) Update(ctx context.Context, resourceGroupName string, solutionName string, updateIotSecuritySolutionData UpdateIotSecuritySolutionData, options *IotSecuritySolutionClientUpdateOptions) (IotSecuritySolutionClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, solutionName, updateIotSecuritySolutionData, options) if err != nil { return IotSecuritySolutionClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return IotSecuritySolutionClientUpdateResponse{}, err } @@ -385,7 +380,7 @@ func (client *IotSecuritySolutionClient) updateCreateRequest(ctx context.Context return nil, errors.New("parameter solutionName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{solutionName}", url.PathEscape(solutionName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/security/armsecurity/iotsecuritysolution_client_example_test.go b/sdk/resourcemanager/security/armsecurity/iotsecuritysolution_client_example_test.go deleted file mode 100644 index 92836e277000..000000000000 --- a/sdk/resourcemanager/security/armsecurity/iotsecuritysolution_client_example_test.go +++ /dev/null @@ -1,235 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. - -package armsecurity_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/IoTSecuritySolutions/GetIoTSecuritySolutionsListByIotHub.json -func ExampleIotSecuritySolutionClient_NewListBySubscriptionPager_listIoTSecuritySolutionsByIoTHub() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewIotSecuritySolutionClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListBySubscriptionPager(&armsecurity.IotSecuritySolutionClientListBySubscriptionOptions{Filter: to.Ptr("properties.iotHubs/any(i eq \"/subscriptions/075423e9-7d33-4166-8bdf-3920b04e3735/resourceGroups/myRg/providers/Microsoft.Devices/IotHubs/FirstIotHub\")")}) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/IoTSecuritySolutions/GetIoTSecuritySolutionsList.json -func ExampleIotSecuritySolutionClient_NewListBySubscriptionPager_listIoTSecuritySolutionsBySubscription() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewIotSecuritySolutionClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListBySubscriptionPager(&armsecurity.IotSecuritySolutionClientListBySubscriptionOptions{Filter: nil}) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/IoTSecuritySolutions/GetIoTSecuritySolutionsListByRg.json -func ExampleIotSecuritySolutionClient_NewListByResourceGroupPager_listIoTSecuritySolutionsByResourceGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewIotSecuritySolutionClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByResourceGroupPager("MyGroup", &armsecurity.IotSecuritySolutionClientListByResourceGroupOptions{Filter: nil}) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/IoTSecuritySolutions/GetIoTSecuritySolutionsListByIotHubAndRg.json -func ExampleIotSecuritySolutionClient_NewListByResourceGroupPager_listIoTSecuritySolutionsByResourceGroupAndIoTHub() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewIotSecuritySolutionClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByResourceGroupPager("MyRg", &armsecurity.IotSecuritySolutionClientListByResourceGroupOptions{Filter: to.Ptr("properties.iotHubs/any(i eq \"/subscriptions/075423e9-7d33-4166-8bdf-3920b04e3735/resourceGroups/myRg/providers/Microsoft.Devices/IotHubs/FirstIotHub\")")}) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/IoTSecuritySolutions/GetIoTSecuritySolution.json -func ExampleIotSecuritySolutionClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewIotSecuritySolutionClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "MyGroup", "default", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/IoTSecuritySolutions/CreateIoTSecuritySolution.json -func ExampleIotSecuritySolutionClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewIotSecuritySolutionClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdate(ctx, "MyGroup", "default", armsecurity.IoTSecuritySolutionModel{ - Tags: map[string]*string{}, - Location: to.Ptr("East Us"), - Properties: &armsecurity.IoTSecuritySolutionProperties{ - DisabledDataSources: []*armsecurity.DataSource{}, - DisplayName: to.Ptr("Solution Default"), - Export: []*armsecurity.ExportData{}, - IotHubs: []*string{ - to.Ptr("/subscriptions/075423e9-7d33-4166-8bdf-3920b04e3735/resourceGroups/myRg/providers/Microsoft.Devices/IotHubs/FirstIotHub")}, - RecommendationsConfiguration: []*armsecurity.RecommendationConfigurationProperties{ - { - RecommendationType: to.Ptr(armsecurity.RecommendationTypeIoTOpenPorts), - Status: to.Ptr(armsecurity.RecommendationConfigStatusDisabled), - }, - { - RecommendationType: to.Ptr(armsecurity.RecommendationTypeIoTSharedCredentials), - Status: to.Ptr(armsecurity.RecommendationConfigStatusDisabled), - }}, - Status: to.Ptr(armsecurity.SecuritySolutionStatusEnabled), - UnmaskedIPLoggingStatus: to.Ptr(armsecurity.UnmaskedIPLoggingStatusEnabled), - UserDefinedResources: &armsecurity.UserDefinedResourcesProperties{ - Query: to.Ptr("where type != \"microsoft.devices/iothubs\" | where name contains \"iot\""), - QuerySubscriptions: []*string{ - to.Ptr("075423e9-7d33-4166-8bdf-3920b04e3735")}, - }, - Workspace: to.Ptr("/subscriptions/c4930e90-cd72-4aa5-93e9-2d081d129569/resourceGroups/myRg/providers/Microsoft.OperationalInsights/workspaces/myWorkspace1"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/IoTSecuritySolutions/UpdateIoTSecuritySolution.json -func ExampleIotSecuritySolutionClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewIotSecuritySolutionClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Update(ctx, "myRg", "default", armsecurity.UpdateIotSecuritySolutionData{ - Tags: map[string]*string{ - "foo": to.Ptr("bar"), - }, - Properties: &armsecurity.UpdateIoTSecuritySolutionProperties{ - RecommendationsConfiguration: []*armsecurity.RecommendationConfigurationProperties{ - { - RecommendationType: to.Ptr(armsecurity.RecommendationTypeIoTOpenPorts), - Status: to.Ptr(armsecurity.RecommendationConfigStatusDisabled), - }, - { - RecommendationType: to.Ptr(armsecurity.RecommendationTypeIoTSharedCredentials), - Status: to.Ptr(armsecurity.RecommendationConfigStatusDisabled), - }}, - UserDefinedResources: &armsecurity.UserDefinedResourcesProperties{ - Query: to.Ptr("where type != \"microsoft.devices/iothubs\" | where name contains \"v2\""), - QuerySubscriptions: []*string{ - to.Ptr("075423e9-7d33-4166-8bdf-3920b04e3735")}, - }, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/IoTSecuritySolutions/DeleteIoTSecuritySolution.json -func ExampleIotSecuritySolutionClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewIotSecuritySolutionClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, "MyGroup", "default", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/security/armsecurity/iotsecuritysolutionanalytics_client.go b/sdk/resourcemanager/security/armsecurity/iotsecuritysolutionanalytics_client.go index 22dd8c0fe893..81628695e672 100644 --- a/sdk/resourcemanager/security/armsecurity/iotsecuritysolutionanalytics_client.go +++ b/sdk/resourcemanager/security/armsecurity/iotsecuritysolutionanalytics_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,48 +24,40 @@ import ( // IotSecuritySolutionAnalyticsClient contains the methods for the IotSecuritySolutionAnalytics group. // Don't use this type directly, use NewIotSecuritySolutionAnalyticsClient() instead. type IotSecuritySolutionAnalyticsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewIotSecuritySolutionAnalyticsClient creates a new instance of IotSecuritySolutionAnalyticsClient with the specified values. -// subscriptionID - Azure subscription ID -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure subscription ID +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewIotSecuritySolutionAnalyticsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*IotSecuritySolutionAnalyticsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".IotSecuritySolutionAnalyticsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &IotSecuritySolutionAnalyticsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Use this method to get IoT Security Analytics metrics. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-08-01 -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// solutionName - The name of the IoT Security solution. -// options - IotSecuritySolutionAnalyticsClientGetOptions contains the optional parameters for the IotSecuritySolutionAnalyticsClient.Get -// method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - solutionName - The name of the IoT Security solution. +// - options - IotSecuritySolutionAnalyticsClientGetOptions contains the optional parameters for the IotSecuritySolutionAnalyticsClient.Get +// method. func (client *IotSecuritySolutionAnalyticsClient) Get(ctx context.Context, resourceGroupName string, solutionName string, options *IotSecuritySolutionAnalyticsClientGetOptions) (IotSecuritySolutionAnalyticsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, solutionName, options) if err != nil { return IotSecuritySolutionAnalyticsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return IotSecuritySolutionAnalyticsClientGetResponse{}, err } @@ -92,7 +82,7 @@ func (client *IotSecuritySolutionAnalyticsClient) getCreateRequest(ctx context.C return nil, errors.New("parameter solutionName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{solutionName}", url.PathEscape(solutionName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -114,17 +104,18 @@ func (client *IotSecuritySolutionAnalyticsClient) getHandleResponse(resp *http.R // List - Use this method to get IoT security Analytics metrics in an array. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-08-01 -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// solutionName - The name of the IoT Security solution. -// options - IotSecuritySolutionAnalyticsClientListOptions contains the optional parameters for the IotSecuritySolutionAnalyticsClient.List -// method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - solutionName - The name of the IoT Security solution. +// - options - IotSecuritySolutionAnalyticsClientListOptions contains the optional parameters for the IotSecuritySolutionAnalyticsClient.List +// method. func (client *IotSecuritySolutionAnalyticsClient) List(ctx context.Context, resourceGroupName string, solutionName string, options *IotSecuritySolutionAnalyticsClientListOptions) (IotSecuritySolutionAnalyticsClientListResponse, error) { req, err := client.listCreateRequest(ctx, resourceGroupName, solutionName, options) if err != nil { return IotSecuritySolutionAnalyticsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return IotSecuritySolutionAnalyticsClientListResponse{}, err } @@ -149,7 +140,7 @@ func (client *IotSecuritySolutionAnalyticsClient) listCreateRequest(ctx context. return nil, errors.New("parameter solutionName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{solutionName}", url.PathEscape(solutionName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/security/armsecurity/iotsecuritysolutionanalytics_client_example_test.go b/sdk/resourcemanager/security/armsecurity/iotsecuritysolutionanalytics_client_example_test.go deleted file mode 100644 index 9fc80ba63653..000000000000 --- a/sdk/resourcemanager/security/armsecurity/iotsecuritysolutionanalytics_client_example_test.go +++ /dev/null @@ -1,55 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. - -package armsecurity_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/IoTSecuritySolutionsAnalytics/GetIoTSecuritySolutionsSecurityAnalyticsList.json -func ExampleIotSecuritySolutionAnalyticsClient_List() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewIotSecuritySolutionAnalyticsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.List(ctx, "MyGroup", "default", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/IoTSecuritySolutionsAnalytics/GetIoTSecuritySolutionsSecurityAnalytics.json -func ExampleIotSecuritySolutionAnalyticsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewIotSecuritySolutionAnalyticsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "MyGroup", "default", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/security/armsecurity/iotsecuritysolutionsanalyticsaggregatedalert_client.go b/sdk/resourcemanager/security/armsecurity/iotsecuritysolutionsanalyticsaggregatedalert_client.go index 3816afa853b3..1e8496b9278f 100644 --- a/sdk/resourcemanager/security/armsecurity/iotsecuritysolutionsanalyticsaggregatedalert_client.go +++ b/sdk/resourcemanager/security/armsecurity/iotsecuritysolutionsanalyticsaggregatedalert_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -27,49 +25,41 @@ import ( // IotSecuritySolutionsAnalyticsAggregatedAlertClient contains the methods for the IotSecuritySolutionsAnalyticsAggregatedAlert group. // Don't use this type directly, use NewIotSecuritySolutionsAnalyticsAggregatedAlertClient() instead. type IotSecuritySolutionsAnalyticsAggregatedAlertClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewIotSecuritySolutionsAnalyticsAggregatedAlertClient creates a new instance of IotSecuritySolutionsAnalyticsAggregatedAlertClient with the specified values. -// subscriptionID - Azure subscription ID -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure subscription ID +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewIotSecuritySolutionsAnalyticsAggregatedAlertClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*IotSecuritySolutionsAnalyticsAggregatedAlertClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".IotSecuritySolutionsAnalyticsAggregatedAlertClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &IotSecuritySolutionsAnalyticsAggregatedAlertClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Dismiss - Use this method to dismiss an aggregated IoT Security Solution Alert. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-08-01 -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// solutionName - The name of the IoT Security solution. -// aggregatedAlertName - Identifier of the aggregated alert. -// options - IotSecuritySolutionsAnalyticsAggregatedAlertClientDismissOptions contains the optional parameters for the IotSecuritySolutionsAnalyticsAggregatedAlertClient.Dismiss -// method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - solutionName - The name of the IoT Security solution. +// - aggregatedAlertName - Identifier of the aggregated alert. +// - options - IotSecuritySolutionsAnalyticsAggregatedAlertClientDismissOptions contains the optional parameters for the IotSecuritySolutionsAnalyticsAggregatedAlertClient.Dismiss +// method. func (client *IotSecuritySolutionsAnalyticsAggregatedAlertClient) Dismiss(ctx context.Context, resourceGroupName string, solutionName string, aggregatedAlertName string, options *IotSecuritySolutionsAnalyticsAggregatedAlertClientDismissOptions) (IotSecuritySolutionsAnalyticsAggregatedAlertClientDismissResponse, error) { req, err := client.dismissCreateRequest(ctx, resourceGroupName, solutionName, aggregatedAlertName, options) if err != nil { return IotSecuritySolutionsAnalyticsAggregatedAlertClientDismissResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return IotSecuritySolutionsAnalyticsAggregatedAlertClientDismissResponse{}, err } @@ -98,7 +88,7 @@ func (client *IotSecuritySolutionsAnalyticsAggregatedAlertClient) dismissCreateR return nil, errors.New("parameter aggregatedAlertName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{aggregatedAlertName}", url.PathEscape(aggregatedAlertName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -112,18 +102,19 @@ func (client *IotSecuritySolutionsAnalyticsAggregatedAlertClient) dismissCreateR // Get - Use this method to get a single the aggregated alert of yours IoT Security solution. This aggregation is performed // by alert name. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-08-01 -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// solutionName - The name of the IoT Security solution. -// aggregatedAlertName - Identifier of the aggregated alert. -// options - IotSecuritySolutionsAnalyticsAggregatedAlertClientGetOptions contains the optional parameters for the IotSecuritySolutionsAnalyticsAggregatedAlertClient.Get -// method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - solutionName - The name of the IoT Security solution. +// - aggregatedAlertName - Identifier of the aggregated alert. +// - options - IotSecuritySolutionsAnalyticsAggregatedAlertClientGetOptions contains the optional parameters for the IotSecuritySolutionsAnalyticsAggregatedAlertClient.Get +// method. func (client *IotSecuritySolutionsAnalyticsAggregatedAlertClient) Get(ctx context.Context, resourceGroupName string, solutionName string, aggregatedAlertName string, options *IotSecuritySolutionsAnalyticsAggregatedAlertClientGetOptions) (IotSecuritySolutionsAnalyticsAggregatedAlertClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, solutionName, aggregatedAlertName, options) if err != nil { return IotSecuritySolutionsAnalyticsAggregatedAlertClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return IotSecuritySolutionsAnalyticsAggregatedAlertClientGetResponse{}, err } @@ -152,7 +143,7 @@ func (client *IotSecuritySolutionsAnalyticsAggregatedAlertClient) getCreateReque return nil, errors.New("parameter aggregatedAlertName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{aggregatedAlertName}", url.PathEscape(aggregatedAlertName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -173,11 +164,12 @@ func (client *IotSecuritySolutionsAnalyticsAggregatedAlertClient) getHandleRespo } // NewListPager - Use this method to get the aggregated alert list of yours IoT Security solution. +// // Generated from API version 2019-08-01 -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// solutionName - The name of the IoT Security solution. -// options - IotSecuritySolutionsAnalyticsAggregatedAlertClientListOptions contains the optional parameters for the IotSecuritySolutionsAnalyticsAggregatedAlertClient.List -// method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - solutionName - The name of the IoT Security solution. +// - options - IotSecuritySolutionsAnalyticsAggregatedAlertClientListOptions contains the optional parameters for the IotSecuritySolutionsAnalyticsAggregatedAlertClient.NewListPager +// method. func (client *IotSecuritySolutionsAnalyticsAggregatedAlertClient) NewListPager(resourceGroupName string, solutionName string, options *IotSecuritySolutionsAnalyticsAggregatedAlertClientListOptions) *runtime.Pager[IotSecuritySolutionsAnalyticsAggregatedAlertClientListResponse] { return runtime.NewPager(runtime.PagingHandler[IotSecuritySolutionsAnalyticsAggregatedAlertClientListResponse]{ More: func(page IotSecuritySolutionsAnalyticsAggregatedAlertClientListResponse) bool { @@ -194,7 +186,7 @@ func (client *IotSecuritySolutionsAnalyticsAggregatedAlertClient) NewListPager(r if err != nil { return IotSecuritySolutionsAnalyticsAggregatedAlertClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return IotSecuritySolutionsAnalyticsAggregatedAlertClientListResponse{}, err } @@ -221,7 +213,7 @@ func (client *IotSecuritySolutionsAnalyticsAggregatedAlertClient) listCreateRequ return nil, errors.New("parameter solutionName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{solutionName}", url.PathEscape(solutionName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/security/armsecurity/iotsecuritysolutionsanalyticsaggregatedalert_client_example_test.go b/sdk/resourcemanager/security/armsecurity/iotsecuritysolutionsanalyticsaggregatedalert_client_example_test.go deleted file mode 100644 index 1e56d218641b..000000000000 --- a/sdk/resourcemanager/security/armsecurity/iotsecuritysolutionsanalyticsaggregatedalert_client_example_test.go +++ /dev/null @@ -1,77 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. - -package armsecurity_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/IoTSecuritySolutionsAnalytics/GetIoTSecuritySolutionsSecurityAggregatedAlertList.json -func ExampleIotSecuritySolutionsAnalyticsAggregatedAlertClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewIotSecuritySolutionsAnalyticsAggregatedAlertClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("MyGroup", "default", &armsecurity.IotSecuritySolutionsAnalyticsAggregatedAlertClientListOptions{Top: nil}) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/IoTSecuritySolutionsAnalytics/GetIoTSecuritySolutionsSecurityAggregatedAlert.json -func ExampleIotSecuritySolutionsAnalyticsAggregatedAlertClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewIotSecuritySolutionsAnalyticsAggregatedAlertClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "MyGroup", "default", "IoT_Bruteforce_Fail/2019-02-02", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/IoTSecuritySolutionsAnalytics/PostIoTSecuritySolutionsSecurityAggregatedAlertDismiss.json -func ExampleIotSecuritySolutionsAnalyticsAggregatedAlertClient_Dismiss() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewIotSecuritySolutionsAnalyticsAggregatedAlertClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Dismiss(ctx, "IoTEdgeResources", "default", "IoT_Bruteforce_Fail/2019-02-02/dismiss", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/security/armsecurity/iotsecuritysolutionsanalyticsrecommendation_client.go b/sdk/resourcemanager/security/armsecurity/iotsecuritysolutionsanalyticsrecommendation_client.go index 5be04969ed8e..ee38bb28470e 100644 --- a/sdk/resourcemanager/security/armsecurity/iotsecuritysolutionsanalyticsrecommendation_client.go +++ b/sdk/resourcemanager/security/armsecurity/iotsecuritysolutionsanalyticsrecommendation_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -27,31 +25,22 @@ import ( // IotSecuritySolutionsAnalyticsRecommendationClient contains the methods for the IotSecuritySolutionsAnalyticsRecommendation group. // Don't use this type directly, use NewIotSecuritySolutionsAnalyticsRecommendationClient() instead. type IotSecuritySolutionsAnalyticsRecommendationClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewIotSecuritySolutionsAnalyticsRecommendationClient creates a new instance of IotSecuritySolutionsAnalyticsRecommendationClient with the specified values. -// subscriptionID - Azure subscription ID -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure subscription ID +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewIotSecuritySolutionsAnalyticsRecommendationClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*IotSecuritySolutionsAnalyticsRecommendationClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".IotSecuritySolutionsAnalyticsRecommendationClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &IotSecuritySolutionsAnalyticsRecommendationClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -59,18 +48,19 @@ func NewIotSecuritySolutionsAnalyticsRecommendationClient(subscriptionID string, // Get - Use this method to get the aggregated security analytics recommendation of yours IoT Security solution. This aggregation // is performed by recommendation name. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-08-01 -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// solutionName - The name of the IoT Security solution. -// aggregatedRecommendationName - Name of the recommendation aggregated for this query. -// options - IotSecuritySolutionsAnalyticsRecommendationClientGetOptions contains the optional parameters for the IotSecuritySolutionsAnalyticsRecommendationClient.Get -// method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - solutionName - The name of the IoT Security solution. +// - aggregatedRecommendationName - Name of the recommendation aggregated for this query. +// - options - IotSecuritySolutionsAnalyticsRecommendationClientGetOptions contains the optional parameters for the IotSecuritySolutionsAnalyticsRecommendationClient.Get +// method. func (client *IotSecuritySolutionsAnalyticsRecommendationClient) Get(ctx context.Context, resourceGroupName string, solutionName string, aggregatedRecommendationName string, options *IotSecuritySolutionsAnalyticsRecommendationClientGetOptions) (IotSecuritySolutionsAnalyticsRecommendationClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, solutionName, aggregatedRecommendationName, options) if err != nil { return IotSecuritySolutionsAnalyticsRecommendationClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return IotSecuritySolutionsAnalyticsRecommendationClientGetResponse{}, err } @@ -99,7 +89,7 @@ func (client *IotSecuritySolutionsAnalyticsRecommendationClient) getCreateReques return nil, errors.New("parameter aggregatedRecommendationName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{aggregatedRecommendationName}", url.PathEscape(aggregatedRecommendationName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -120,11 +110,12 @@ func (client *IotSecuritySolutionsAnalyticsRecommendationClient) getHandleRespon } // NewListPager - Use this method to get the list of aggregated security analytics recommendations of yours IoT Security solution. +// // Generated from API version 2019-08-01 -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// solutionName - The name of the IoT Security solution. -// options - IotSecuritySolutionsAnalyticsRecommendationClientListOptions contains the optional parameters for the IotSecuritySolutionsAnalyticsRecommendationClient.List -// method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - solutionName - The name of the IoT Security solution. +// - options - IotSecuritySolutionsAnalyticsRecommendationClientListOptions contains the optional parameters for the IotSecuritySolutionsAnalyticsRecommendationClient.NewListPager +// method. func (client *IotSecuritySolutionsAnalyticsRecommendationClient) NewListPager(resourceGroupName string, solutionName string, options *IotSecuritySolutionsAnalyticsRecommendationClientListOptions) *runtime.Pager[IotSecuritySolutionsAnalyticsRecommendationClientListResponse] { return runtime.NewPager(runtime.PagingHandler[IotSecuritySolutionsAnalyticsRecommendationClientListResponse]{ More: func(page IotSecuritySolutionsAnalyticsRecommendationClientListResponse) bool { @@ -141,7 +132,7 @@ func (client *IotSecuritySolutionsAnalyticsRecommendationClient) NewListPager(re if err != nil { return IotSecuritySolutionsAnalyticsRecommendationClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return IotSecuritySolutionsAnalyticsRecommendationClientListResponse{}, err } @@ -168,7 +159,7 @@ func (client *IotSecuritySolutionsAnalyticsRecommendationClient) listCreateReque return nil, errors.New("parameter solutionName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{solutionName}", url.PathEscape(solutionName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/security/armsecurity/iotsecuritysolutionsanalyticsrecommendation_client_example_test.go b/sdk/resourcemanager/security/armsecurity/iotsecuritysolutionsanalyticsrecommendation_client_example_test.go deleted file mode 100644 index 92f697e736ff..000000000000 --- a/sdk/resourcemanager/security/armsecurity/iotsecuritysolutionsanalyticsrecommendation_client_example_test.go +++ /dev/null @@ -1,60 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. - -package armsecurity_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/IoTSecuritySolutionsAnalytics/GetIoTSecuritySolutionsSecurityRecommendation.json -func ExampleIotSecuritySolutionsAnalyticsRecommendationClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewIotSecuritySolutionsAnalyticsRecommendationClient("075423e9-7d33-4166-8bdf-3920b04e3735", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "IoTEdgeResources", "default", "OpenPortsOnDevice", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/IoTSecuritySolutionsAnalytics/GetIoTSecuritySolutionsSecurityRecommendationList.json -func ExampleIotSecuritySolutionsAnalyticsRecommendationClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewIotSecuritySolutionsAnalyticsRecommendationClient("075423e9-7d33-4166-8bdf-3920b04e3735", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("IoTEdgeResources", "default", &armsecurity.IotSecuritySolutionsAnalyticsRecommendationClientListOptions{Top: nil}) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/security/armsecurity/jitnetworkaccesspolicies_client.go b/sdk/resourcemanager/security/armsecurity/jitnetworkaccesspolicies_client.go index a123d3a7f6bc..5576ad82089d 100644 --- a/sdk/resourcemanager/security/armsecurity/jitnetworkaccesspolicies_client.go +++ b/sdk/resourcemanager/security/armsecurity/jitnetworkaccesspolicies_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,49 +24,41 @@ import ( // JitNetworkAccessPoliciesClient contains the methods for the JitNetworkAccessPolicies group. // Don't use this type directly, use NewJitNetworkAccessPoliciesClient() instead. type JitNetworkAccessPoliciesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewJitNetworkAccessPoliciesClient creates a new instance of JitNetworkAccessPoliciesClient with the specified values. -// subscriptionID - Azure subscription ID -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure subscription ID +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewJitNetworkAccessPoliciesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*JitNetworkAccessPoliciesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".JitNetworkAccessPoliciesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &JitNetworkAccessPoliciesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // CreateOrUpdate - Create a policy for protecting resources using Just-in-Time access control // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-01-01 -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations -// jitNetworkAccessPolicyName - Name of a Just-in-Time access configuration policy. -// options - JitNetworkAccessPoliciesClientCreateOrUpdateOptions contains the optional parameters for the JitNetworkAccessPoliciesClient.CreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations +// - jitNetworkAccessPolicyName - Name of a Just-in-Time access configuration policy. +// - options - JitNetworkAccessPoliciesClientCreateOrUpdateOptions contains the optional parameters for the JitNetworkAccessPoliciesClient.CreateOrUpdate +// method. func (client *JitNetworkAccessPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, ascLocation string, jitNetworkAccessPolicyName string, body JitNetworkAccessPolicy, options *JitNetworkAccessPoliciesClientCreateOrUpdateOptions) (JitNetworkAccessPoliciesClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, ascLocation, jitNetworkAccessPolicyName, body, options) if err != nil { return JitNetworkAccessPoliciesClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return JitNetworkAccessPoliciesClientCreateOrUpdateResponse{}, err } @@ -97,7 +87,7 @@ func (client *JitNetworkAccessPoliciesClient) createOrUpdateCreateRequest(ctx co return nil, errors.New("parameter jitNetworkAccessPolicyName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{jitNetworkAccessPolicyName}", url.PathEscape(jitNetworkAccessPolicyName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -119,18 +109,19 @@ func (client *JitNetworkAccessPoliciesClient) createOrUpdateHandleResponse(resp // Delete - Delete a Just-in-Time access control policy. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-01-01 -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations -// jitNetworkAccessPolicyName - Name of a Just-in-Time access configuration policy. -// options - JitNetworkAccessPoliciesClientDeleteOptions contains the optional parameters for the JitNetworkAccessPoliciesClient.Delete -// method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations +// - jitNetworkAccessPolicyName - Name of a Just-in-Time access configuration policy. +// - options - JitNetworkAccessPoliciesClientDeleteOptions contains the optional parameters for the JitNetworkAccessPoliciesClient.Delete +// method. func (client *JitNetworkAccessPoliciesClient) Delete(ctx context.Context, resourceGroupName string, ascLocation string, jitNetworkAccessPolicyName string, options *JitNetworkAccessPoliciesClientDeleteOptions) (JitNetworkAccessPoliciesClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, ascLocation, jitNetworkAccessPolicyName, options) if err != nil { return JitNetworkAccessPoliciesClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return JitNetworkAccessPoliciesClientDeleteResponse{}, err } @@ -159,7 +150,7 @@ func (client *JitNetworkAccessPoliciesClient) deleteCreateRequest(ctx context.Co return nil, errors.New("parameter jitNetworkAccessPolicyName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{jitNetworkAccessPolicyName}", url.PathEscape(jitNetworkAccessPolicyName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -172,18 +163,19 @@ func (client *JitNetworkAccessPoliciesClient) deleteCreateRequest(ctx context.Co // Get - Policies for protecting resources using Just-in-Time access control for the subscription, location // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-01-01 -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations -// jitNetworkAccessPolicyName - Name of a Just-in-Time access configuration policy. -// options - JitNetworkAccessPoliciesClientGetOptions contains the optional parameters for the JitNetworkAccessPoliciesClient.Get -// method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations +// - jitNetworkAccessPolicyName - Name of a Just-in-Time access configuration policy. +// - options - JitNetworkAccessPoliciesClientGetOptions contains the optional parameters for the JitNetworkAccessPoliciesClient.Get +// method. func (client *JitNetworkAccessPoliciesClient) Get(ctx context.Context, resourceGroupName string, ascLocation string, jitNetworkAccessPolicyName string, options *JitNetworkAccessPoliciesClientGetOptions) (JitNetworkAccessPoliciesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, ascLocation, jitNetworkAccessPolicyName, options) if err != nil { return JitNetworkAccessPoliciesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return JitNetworkAccessPoliciesClientGetResponse{}, err } @@ -212,7 +204,7 @@ func (client *JitNetworkAccessPoliciesClient) getCreateRequest(ctx context.Conte return nil, errors.New("parameter jitNetworkAccessPolicyName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{jitNetworkAccessPolicyName}", url.PathEscape(jitNetworkAccessPolicyName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -234,18 +226,19 @@ func (client *JitNetworkAccessPoliciesClient) getHandleResponse(resp *http.Respo // Initiate - Initiate a JIT access from a specific Just-in-Time policy configuration. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-01-01 -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations -// jitNetworkAccessPolicyName - Name of a Just-in-Time access configuration policy. -// options - JitNetworkAccessPoliciesClientInitiateOptions contains the optional parameters for the JitNetworkAccessPoliciesClient.Initiate -// method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations +// - jitNetworkAccessPolicyName - Name of a Just-in-Time access configuration policy. +// - options - JitNetworkAccessPoliciesClientInitiateOptions contains the optional parameters for the JitNetworkAccessPoliciesClient.Initiate +// method. func (client *JitNetworkAccessPoliciesClient) Initiate(ctx context.Context, resourceGroupName string, ascLocation string, jitNetworkAccessPolicyName string, body JitNetworkAccessPolicyInitiateRequest, options *JitNetworkAccessPoliciesClientInitiateOptions) (JitNetworkAccessPoliciesClientInitiateResponse, error) { req, err := client.initiateCreateRequest(ctx, resourceGroupName, ascLocation, jitNetworkAccessPolicyName, body, options) if err != nil { return JitNetworkAccessPoliciesClientInitiateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return JitNetworkAccessPoliciesClientInitiateResponse{}, err } @@ -275,7 +268,7 @@ func (client *JitNetworkAccessPoliciesClient) initiateCreateRequest(ctx context. } urlPath = strings.ReplaceAll(urlPath, "{jitNetworkAccessPolicyName}", url.PathEscape(jitNetworkAccessPolicyName)) urlPath = strings.ReplaceAll(urlPath, "{jitNetworkAccessPolicyInitiateType}", url.PathEscape("initiate")) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -296,9 +289,10 @@ func (client *JitNetworkAccessPoliciesClient) initiateHandleResponse(resp *http. } // NewListPager - Policies for protecting resources using Just-in-Time access control. +// // Generated from API version 2020-01-01 -// options - JitNetworkAccessPoliciesClientListOptions contains the optional parameters for the JitNetworkAccessPoliciesClient.List -// method. +// - options - JitNetworkAccessPoliciesClientListOptions contains the optional parameters for the JitNetworkAccessPoliciesClient.NewListPager +// method. func (client *JitNetworkAccessPoliciesClient) NewListPager(options *JitNetworkAccessPoliciesClientListOptions) *runtime.Pager[JitNetworkAccessPoliciesClientListResponse] { return runtime.NewPager(runtime.PagingHandler[JitNetworkAccessPoliciesClientListResponse]{ More: func(page JitNetworkAccessPoliciesClientListResponse) bool { @@ -315,7 +309,7 @@ func (client *JitNetworkAccessPoliciesClient) NewListPager(options *JitNetworkAc if err != nil { return JitNetworkAccessPoliciesClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return JitNetworkAccessPoliciesClientListResponse{}, err } @@ -334,7 +328,7 @@ func (client *JitNetworkAccessPoliciesClient) listCreateRequest(ctx context.Cont return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -355,10 +349,11 @@ func (client *JitNetworkAccessPoliciesClient) listHandleResponse(resp *http.Resp } // NewListByRegionPager - Policies for protecting resources using Just-in-Time access control for the subscription, location +// // Generated from API version 2020-01-01 -// ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations -// options - JitNetworkAccessPoliciesClientListByRegionOptions contains the optional parameters for the JitNetworkAccessPoliciesClient.ListByRegion -// method. +// - ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations +// - options - JitNetworkAccessPoliciesClientListByRegionOptions contains the optional parameters for the JitNetworkAccessPoliciesClient.NewListByRegionPager +// method. func (client *JitNetworkAccessPoliciesClient) NewListByRegionPager(ascLocation string, options *JitNetworkAccessPoliciesClientListByRegionOptions) *runtime.Pager[JitNetworkAccessPoliciesClientListByRegionResponse] { return runtime.NewPager(runtime.PagingHandler[JitNetworkAccessPoliciesClientListByRegionResponse]{ More: func(page JitNetworkAccessPoliciesClientListByRegionResponse) bool { @@ -375,7 +370,7 @@ func (client *JitNetworkAccessPoliciesClient) NewListByRegionPager(ascLocation s if err != nil { return JitNetworkAccessPoliciesClientListByRegionResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return JitNetworkAccessPoliciesClientListByRegionResponse{}, err } @@ -398,7 +393,7 @@ func (client *JitNetworkAccessPoliciesClient) listByRegionCreateRequest(ctx cont return nil, errors.New("parameter ascLocation cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{ascLocation}", url.PathEscape(ascLocation)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -420,10 +415,11 @@ func (client *JitNetworkAccessPoliciesClient) listByRegionHandleResponse(resp *h // NewListByResourceGroupPager - Policies for protecting resources using Just-in-Time access control for the subscription, // location +// // Generated from API version 2020-01-01 -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// options - JitNetworkAccessPoliciesClientListByResourceGroupOptions contains the optional parameters for the JitNetworkAccessPoliciesClient.ListByResourceGroup -// method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - options - JitNetworkAccessPoliciesClientListByResourceGroupOptions contains the optional parameters for the JitNetworkAccessPoliciesClient.NewListByResourceGroupPager +// method. func (client *JitNetworkAccessPoliciesClient) NewListByResourceGroupPager(resourceGroupName string, options *JitNetworkAccessPoliciesClientListByResourceGroupOptions) *runtime.Pager[JitNetworkAccessPoliciesClientListByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[JitNetworkAccessPoliciesClientListByResourceGroupResponse]{ More: func(page JitNetworkAccessPoliciesClientListByResourceGroupResponse) bool { @@ -440,7 +436,7 @@ func (client *JitNetworkAccessPoliciesClient) NewListByResourceGroupPager(resour if err != nil { return JitNetworkAccessPoliciesClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return JitNetworkAccessPoliciesClientListByResourceGroupResponse{}, err } @@ -463,7 +459,7 @@ func (client *JitNetworkAccessPoliciesClient) listByResourceGroupCreateRequest(c return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -485,11 +481,12 @@ func (client *JitNetworkAccessPoliciesClient) listByResourceGroupHandleResponse( // NewListByResourceGroupAndRegionPager - Policies for protecting resources using Just-in-Time access control for the subscription, // location +// // Generated from API version 2020-01-01 -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations -// options - JitNetworkAccessPoliciesClientListByResourceGroupAndRegionOptions contains the optional parameters for the JitNetworkAccessPoliciesClient.ListByResourceGroupAndRegion -// method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations +// - options - JitNetworkAccessPoliciesClientListByResourceGroupAndRegionOptions contains the optional parameters for the JitNetworkAccessPoliciesClient.NewListByResourceGroupAndRegionPager +// method. func (client *JitNetworkAccessPoliciesClient) NewListByResourceGroupAndRegionPager(resourceGroupName string, ascLocation string, options *JitNetworkAccessPoliciesClientListByResourceGroupAndRegionOptions) *runtime.Pager[JitNetworkAccessPoliciesClientListByResourceGroupAndRegionResponse] { return runtime.NewPager(runtime.PagingHandler[JitNetworkAccessPoliciesClientListByResourceGroupAndRegionResponse]{ More: func(page JitNetworkAccessPoliciesClientListByResourceGroupAndRegionResponse) bool { @@ -506,7 +503,7 @@ func (client *JitNetworkAccessPoliciesClient) NewListByResourceGroupAndRegionPag if err != nil { return JitNetworkAccessPoliciesClientListByResourceGroupAndRegionResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return JitNetworkAccessPoliciesClientListByResourceGroupAndRegionResponse{}, err } @@ -533,7 +530,7 @@ func (client *JitNetworkAccessPoliciesClient) listByResourceGroupAndRegionCreate return nil, errors.New("parameter ascLocation cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{ascLocation}", url.PathEscape(ascLocation)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/security/armsecurity/jitnetworkaccesspolicies_client_example_test.go b/sdk/resourcemanager/security/armsecurity/jitnetworkaccesspolicies_client_example_test.go deleted file mode 100644 index 29949c27585c..000000000000 --- a/sdk/resourcemanager/security/armsecurity/jitnetworkaccesspolicies_client_example_test.go +++ /dev/null @@ -1,242 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. - -package armsecurity_test - -import ( - "context" - "log" - - "time" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/JitNetworkAccessPolicies/GetJitNetworkAccessPoliciesSubscription_example.json -func ExampleJitNetworkAccessPoliciesClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewJitNetworkAccessPoliciesClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/JitNetworkAccessPolicies/GetJitNetworkAccessPoliciesSubscriptionLocation_example.json -func ExampleJitNetworkAccessPoliciesClient_NewListByRegionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewJitNetworkAccessPoliciesClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByRegionPager("westeurope", nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/JitNetworkAccessPolicies/GetJitNetworkAccessPoliciesResourceGroup_example.json -func ExampleJitNetworkAccessPoliciesClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewJitNetworkAccessPoliciesClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByResourceGroupPager("myRg1", nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/JitNetworkAccessPolicies/GetJitNetworkAccessPoliciesResourceGroupLocation_example.json -func ExampleJitNetworkAccessPoliciesClient_NewListByResourceGroupAndRegionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewJitNetworkAccessPoliciesClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByResourceGroupAndRegionPager("myRg1", "westeurope", nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/JitNetworkAccessPolicies/GetJitNetworkAccessPolicy_example.json -func ExampleJitNetworkAccessPoliciesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewJitNetworkAccessPoliciesClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "myRg1", "westeurope", "default", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/JitNetworkAccessPolicies/CreateJitNetworkAccessPolicy_example.json -func ExampleJitNetworkAccessPoliciesClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewJitNetworkAccessPoliciesClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdate(ctx, "myRg1", "westeurope", "default", armsecurity.JitNetworkAccessPolicy{ - Kind: to.Ptr("Basic"), - Location: to.Ptr("westeurope"), - Name: to.Ptr("default"), - Type: to.Ptr("Microsoft.Security/locations/jitNetworkAccessPolicies"), - ID: to.Ptr("/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/myRg1/providers/Microsoft.Security/locations/westeurope/jitNetworkAccessPolicies/default"), - Properties: &armsecurity.JitNetworkAccessPolicyProperties{ - ProvisioningState: to.Ptr("Succeeded"), - Requests: []*armsecurity.JitNetworkAccessRequest{ - { - Requestor: to.Ptr("barbara@contoso.com"), - StartTimeUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-17T08:06:45.5691611Z"); return t }()), - VirtualMachines: []*armsecurity.JitNetworkAccessRequestVirtualMachine{ - { - ID: to.Ptr("/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/myRg1/providers/Microsoft.Compute/virtualMachines/vm1"), - Ports: []*armsecurity.JitNetworkAccessRequestPort{ - { - AllowedSourceAddressPrefix: to.Ptr("192.127.0.2"), - EndTimeUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-17T09:06:45.5691611Z"); return t }()), - Number: to.Ptr[int32](3389), - Status: to.Ptr(armsecurity.StatusInitiated), - StatusReason: to.Ptr(armsecurity.StatusReasonUserRequested), - }}, - }}, - }}, - VirtualMachines: []*armsecurity.JitNetworkAccessPolicyVirtualMachine{ - { - ID: to.Ptr("/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/myRg1/providers/Microsoft.Compute/virtualMachines/vm1"), - Ports: []*armsecurity.JitNetworkAccessPortRule{ - { - AllowedSourceAddressPrefix: to.Ptr("*"), - MaxRequestAccessDuration: to.Ptr("PT3H"), - Number: to.Ptr[int32](22), - Protocol: to.Ptr(armsecurity.ProtocolAll), - }, - { - AllowedSourceAddressPrefix: to.Ptr("*"), - MaxRequestAccessDuration: to.Ptr("PT3H"), - Number: to.Ptr[int32](3389), - Protocol: to.Ptr(armsecurity.ProtocolAll), - }}, - }}, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/JitNetworkAccessPolicies/DeleteJitNetworkAccessPolicy_example.json -func ExampleJitNetworkAccessPoliciesClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewJitNetworkAccessPoliciesClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, "myRg1", "westeurope", "default", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/JitNetworkAccessPolicies/InitiateJitNetworkAccessPolicy_example.json -func ExampleJitNetworkAccessPoliciesClient_Initiate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewJitNetworkAccessPoliciesClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Initiate(ctx, "myRg1", "westeurope", "default", armsecurity.JitNetworkAccessPolicyInitiateRequest{ - Justification: to.Ptr("testing a new version of the product"), - VirtualMachines: []*armsecurity.JitNetworkAccessPolicyInitiateVirtualMachine{ - { - ID: to.Ptr("/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/myRg1/providers/Microsoft.Compute/virtualMachines/vm1"), - Ports: []*armsecurity.JitNetworkAccessPolicyInitiatePort{ - { - AllowedSourceAddressPrefix: to.Ptr("192.127.0.2"), - Number: to.Ptr[int32](3389), - }}, - }}, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/security/armsecurity/locations_client.go b/sdk/resourcemanager/security/armsecurity/locations_client.go index 0dadb6cab586..44e6850e0d23 100644 --- a/sdk/resourcemanager/security/armsecurity/locations_client.go +++ b/sdk/resourcemanager/security/armsecurity/locations_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,46 +24,38 @@ import ( // LocationsClient contains the methods for the Locations group. // Don't use this type directly, use NewLocationsClient() instead. type LocationsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewLocationsClient creates a new instance of LocationsClient with the specified values. -// subscriptionID - Azure subscription ID -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure subscription ID +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewLocationsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*LocationsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".LocationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &LocationsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Details of a specific location // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2015-06-01-preview -// ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations -// options - LocationsClientGetOptions contains the optional parameters for the LocationsClient.Get method. +// - ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations +// - options - LocationsClientGetOptions contains the optional parameters for the LocationsClient.Get method. func (client *LocationsClient) Get(ctx context.Context, ascLocation string, options *LocationsClientGetOptions) (LocationsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, ascLocation, options) if err != nil { return LocationsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return LocationsClientGetResponse{}, err } @@ -86,7 +76,7 @@ func (client *LocationsClient) getCreateRequest(ctx context.Context, ascLocation return nil, errors.New("parameter ascLocation cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{ascLocation}", url.PathEscape(ascLocation)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -109,8 +99,9 @@ func (client *LocationsClient) getHandleResponse(resp *http.Response) (Locations // NewListPager - The location of the responsible ASC of the specific subscription (home region). For each subscription there // is only one responsible location. The location in the response should be used to read or // write other resources in ASC according to their ID. +// // Generated from API version 2015-06-01-preview -// options - LocationsClientListOptions contains the optional parameters for the LocationsClient.List method. +// - options - LocationsClientListOptions contains the optional parameters for the LocationsClient.NewListPager method. func (client *LocationsClient) NewListPager(options *LocationsClientListOptions) *runtime.Pager[LocationsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[LocationsClientListResponse]{ More: func(page LocationsClientListResponse) bool { @@ -127,7 +118,7 @@ func (client *LocationsClient) NewListPager(options *LocationsClientListOptions) if err != nil { return LocationsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return LocationsClientListResponse{}, err } @@ -146,7 +137,7 @@ func (client *LocationsClient) listCreateRequest(ctx context.Context, options *L return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/security/armsecurity/locations_client_example_test.go b/sdk/resourcemanager/security/armsecurity/locations_client_example_test.go deleted file mode 100644 index b5f32795ffc7..000000000000 --- a/sdk/resourcemanager/security/armsecurity/locations_client_example_test.go +++ /dev/null @@ -1,60 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. - -package armsecurity_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2015-06-01-preview/examples/Locations/GetLocations_example.json -func ExampleLocationsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewLocationsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2015-06-01-preview/examples/Locations/GetLocation_example.json -func ExampleLocationsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewLocationsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "centralus", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/security/armsecurity/mdeonboardings_client.go b/sdk/resourcemanager/security/armsecurity/mdeonboardings_client.go index 97c056136dd7..365b64fda132 100644 --- a/sdk/resourcemanager/security/armsecurity/mdeonboardings_client.go +++ b/sdk/resourcemanager/security/armsecurity/mdeonboardings_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,45 +24,37 @@ import ( // MdeOnboardingsClient contains the methods for the MdeOnboardings group. // Don't use this type directly, use NewMdeOnboardingsClient() instead. type MdeOnboardingsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewMdeOnboardingsClient creates a new instance of MdeOnboardingsClient with the specified values. -// subscriptionID - Azure subscription ID -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure subscription ID +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewMdeOnboardingsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*MdeOnboardingsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".MdeOnboardingsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &MdeOnboardingsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - The default configuration or data needed to onboard the machine to MDE // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-10-01-preview -// options - MdeOnboardingsClientGetOptions contains the optional parameters for the MdeOnboardingsClient.Get method. +// - options - MdeOnboardingsClientGetOptions contains the optional parameters for the MdeOnboardingsClient.Get method. func (client *MdeOnboardingsClient) Get(ctx context.Context, options *MdeOnboardingsClientGetOptions) (MdeOnboardingsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, options) if err != nil { return MdeOnboardingsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return MdeOnboardingsClientGetResponse{}, err } @@ -81,7 +71,7 @@ func (client *MdeOnboardingsClient) getCreateRequest(ctx context.Context, option return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -103,14 +93,15 @@ func (client *MdeOnboardingsClient) getHandleResponse(resp *http.Response) (MdeO // List - The configuration or data needed to onboard the machine to MDE // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-10-01-preview -// options - MdeOnboardingsClientListOptions contains the optional parameters for the MdeOnboardingsClient.List method. +// - options - MdeOnboardingsClientListOptions contains the optional parameters for the MdeOnboardingsClient.List method. func (client *MdeOnboardingsClient) List(ctx context.Context, options *MdeOnboardingsClientListOptions) (MdeOnboardingsClientListResponse, error) { req, err := client.listCreateRequest(ctx, options) if err != nil { return MdeOnboardingsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return MdeOnboardingsClientListResponse{}, err } @@ -127,7 +118,7 @@ func (client *MdeOnboardingsClient) listCreateRequest(ctx context.Context, optio return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/security/armsecurity/mdeonboardings_client_example_test.go b/sdk/resourcemanager/security/armsecurity/mdeonboardings_client_example_test.go deleted file mode 100644 index 027cd0fdb7ae..000000000000 --- a/sdk/resourcemanager/security/armsecurity/mdeonboardings_client_example_test.go +++ /dev/null @@ -1,55 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. - -package armsecurity_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2021-10-01-preview/examples/MdeOnboardings/ListMdeOnboardings_example.json -func ExampleMdeOnboardingsClient_List() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewMdeOnboardingsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.List(ctx, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2021-10-01-preview/examples/MdeOnboardings/GetMdeOnboardings_example.json -func ExampleMdeOnboardingsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewMdeOnboardingsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/security/armsecurity/models.go b/sdk/resourcemanager/security/armsecurity/models.go index a1f8693ad4e3..2dafcd7daffd 100644 --- a/sdk/resourcemanager/security/armsecurity/models.go +++ b/sdk/resourcemanager/security/armsecurity/models.go @@ -41,7 +41,7 @@ type AADExternalSecuritySolution struct { // AADSolutionProperties - The external security solution properties for AAD solutions type AADSolutionProperties struct { // OPTIONAL; Contains additional key/value pairs not defined in the schema. - AdditionalProperties map[string]interface{} + AdditionalProperties map[string]any // The connectivity state of the external AAD solution ConnectivityState *AADConnectivityState `json:"connectivityState,omitempty"` @@ -52,6 +52,61 @@ type AADSolutionProperties struct { Workspace *ConnectedWorkspace `json:"workspace,omitempty"` } +// APICollectionClientGetOptions contains the optional parameters for the APICollectionClient.Get method. +type APICollectionClientGetOptions struct { + // placeholder for future optional parameters +} + +// APICollectionClientListOptions contains the optional parameters for the APICollectionClient.NewListPager method. +type APICollectionClientListOptions struct { + // placeholder for future optional parameters +} + +// APICollectionOffboardingClientDeleteOptions contains the optional parameters for the APICollectionOffboardingClient.Delete +// method. +type APICollectionOffboardingClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// APICollectionOnboardingClientCreateOptions contains the optional parameters for the APICollectionOnboardingClient.Create +// method. +type APICollectionOnboardingClientCreateOptions struct { + // placeholder for future optional parameters +} + +// APICollectionProperties - Describes the properties of an API collection. +type APICollectionProperties struct { + // Additional data regarding the API collection. + AdditionalData map[string]*string `json:"additionalData,omitempty"` + + // The display name of the Azure API Management API. + DisplayName *string `json:"displayName,omitempty"` +} + +// APICollectionResponse - An API collection as represented by Defender for APIs. +type APICollectionResponse struct { + // Describes the properties of an API collection. + Properties *APICollectionProperties `json:"properties,omitempty"` + + // READ-ONLY; Resource Id + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; Resource name + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Resource type + Type *string `json:"type,omitempty" azure:"ro"` +} + +// APICollectionResponseList - Page of a list of API collections as represented by Defender for APIs. +type APICollectionResponseList struct { + // READ-ONLY; The URI to fetch the next page. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; API collections in this page. + Value []*APICollectionResponse `json:"value,omitempty" azure:"ro"` +} + // AccountConnectorsClientCreateOrUpdateOptions contains the optional parameters for the AccountConnectorsClient.CreateOrUpdate // method. type AccountConnectorsClientCreateOrUpdateOptions struct { @@ -68,7 +123,7 @@ type AccountConnectorsClientGetOptions struct { // placeholder for future optional parameters } -// AccountConnectorsClientListOptions contains the optional parameters for the AccountConnectorsClient.List method. +// AccountConnectorsClientListOptions contains the optional parameters for the AccountConnectorsClient.NewListPager method. type AccountConnectorsClientListOptions struct { // placeholder for future optional parameters } @@ -264,7 +319,7 @@ type AdaptiveNetworkHardeningsClientGetOptions struct { // placeholder for future optional parameters } -// AdaptiveNetworkHardeningsClientListByExtendedResourceOptions contains the optional parameters for the AdaptiveNetworkHardeningsClient.ListByExtendedResource +// AdaptiveNetworkHardeningsClientListByExtendedResourceOptions contains the optional parameters for the AdaptiveNetworkHardeningsClient.NewListByExtendedResourcePager // method. type AdaptiveNetworkHardeningsClientListByExtendedResourceOptions struct { // placeholder for future optional parameters @@ -359,7 +414,7 @@ type Alert struct { // AlertEntity - Changing set of properties depending on the entity type. type AlertEntity struct { // OPTIONAL; Contains additional key/value pairs not defined in the schema. - AdditionalProperties map[string]interface{} + AdditionalProperties map[string]any // READ-ONLY; Type of entity Type *string `json:"type,omitempty" azure:"ro"` @@ -423,8 +478,9 @@ type AlertProperties struct { // READ-ONLY; The name of Azure Security Center pricing tier which powering this alert. Learn more: https://docs.microsoft.com/en-us/azure/security-center/security-center-pricing ProductComponentName *string `json:"productComponentName,omitempty" azure:"ro"` - // READ-ONLY; The name of the product which published this alert (Azure Security Center, Azure ATP, Microsoft Defender ATP, - // O365 ATP, MCAS, and so on). + // READ-ONLY; The name of the product which published this alert (Microsoft Sentinel, Microsoft Defender for Identity, Microsoft + // Defender for Endpoint, Microsoft Defender for Office, Microsoft Defender for Cloud + // Apps, and so on). ProductName *string `json:"productName,omitempty" azure:"ro"` // READ-ONLY; Manual action items to take to remediate the alert. @@ -465,7 +521,7 @@ type AlertProperties struct { // AlertPropertiesSupportingEvidence - Changing set of properties depending on the supportingEvidence type. type AlertPropertiesSupportingEvidence struct { // OPTIONAL; Contains additional key/value pairs not defined in the schema. - AdditionalProperties map[string]interface{} + AdditionalProperties map[string]any // READ-ONLY; Type of the supportingEvidence Type *string `json:"type,omitempty" azure:"ro"` @@ -477,7 +533,7 @@ type AlertSimulatorBundlesRequestProperties struct { Kind *Kind `json:"kind,omitempty"` // OPTIONAL; Contains additional key/value pairs not defined in the schema. - AdditionalProperties map[string]interface{} + AdditionalProperties map[string]any // Bundles list. Bundles []*BundleType `json:"bundles,omitempty"` @@ -512,7 +568,7 @@ type AlertSimulatorRequestProperties struct { Kind *Kind `json:"kind,omitempty"` // OPTIONAL; Contains additional key/value pairs not defined in the schema. - AdditionalProperties map[string]interface{} + AdditionalProperties map[string]any } // GetAlertSimulatorRequestProperties implements the AlertSimulatorRequestPropertiesClassification interface for type AlertSimulatorRequestProperties. @@ -570,23 +626,24 @@ type AlertsClientGetSubscriptionLevelOptions struct { // placeholder for future optional parameters } -// AlertsClientListByResourceGroupOptions contains the optional parameters for the AlertsClient.ListByResourceGroup method. +// AlertsClientListByResourceGroupOptions contains the optional parameters for the AlertsClient.NewListByResourceGroupPager +// method. type AlertsClientListByResourceGroupOptions struct { // placeholder for future optional parameters } -// AlertsClientListOptions contains the optional parameters for the AlertsClient.List method. +// AlertsClientListOptions contains the optional parameters for the AlertsClient.NewListPager method. type AlertsClientListOptions struct { // placeholder for future optional parameters } -// AlertsClientListResourceGroupLevelByRegionOptions contains the optional parameters for the AlertsClient.ListResourceGroupLevelByRegion +// AlertsClientListResourceGroupLevelByRegionOptions contains the optional parameters for the AlertsClient.NewListResourceGroupLevelByRegionPager // method. type AlertsClientListResourceGroupLevelByRegionOptions struct { // placeholder for future optional parameters } -// AlertsClientListSubscriptionLevelByRegionOptions contains the optional parameters for the AlertsClient.ListSubscriptionLevelByRegion +// AlertsClientListSubscriptionLevelByRegionOptions contains the optional parameters for the AlertsClient.NewListSubscriptionLevelByRegionPager // method. type AlertsClientListSubscriptionLevelByRegionOptions struct { // placeholder for future optional parameters @@ -691,7 +748,8 @@ type AlertsSuppressionRulesClientGetOptions struct { // placeholder for future optional parameters } -// AlertsSuppressionRulesClientListOptions contains the optional parameters for the AlertsSuppressionRulesClient.List method. +// AlertsSuppressionRulesClientListOptions contains the optional parameters for the AlertsSuppressionRulesClient.NewListPager +// method. type AlertsSuppressionRulesClientListOptions struct { // Type of the alert to get rules for AlertType *string @@ -717,13 +775,13 @@ type AllowedConnectionsClientGetOptions struct { // placeholder for future optional parameters } -// AllowedConnectionsClientListByHomeRegionOptions contains the optional parameters for the AllowedConnectionsClient.ListByHomeRegion +// AllowedConnectionsClientListByHomeRegionOptions contains the optional parameters for the AllowedConnectionsClient.NewListByHomeRegionPager // method. type AllowedConnectionsClientListByHomeRegionOptions struct { // placeholder for future optional parameters } -// AllowedConnectionsClientListOptions contains the optional parameters for the AllowedConnectionsClient.List method. +// AllowedConnectionsClientListOptions contains the optional parameters for the AllowedConnectionsClient.NewListPager method. type AllowedConnectionsClientListOptions struct { // placeholder for future optional parameters } @@ -1042,7 +1100,7 @@ type ApplicationCondition struct { // ApplicationProperties - Describes properties of an application type ApplicationProperties struct { // REQUIRED; The application conditionSets - see examples - ConditionSets []interface{} `json:"conditionSets,omitempty"` + ConditionSets []any `json:"conditionSets,omitempty"` // REQUIRED; The application source, what it affects, e.g. Assessments SourceResourceType *ApplicationSourceResourceType `json:"sourceResourceType,omitempty"` @@ -1054,7 +1112,7 @@ type ApplicationProperties struct { DisplayName *string `json:"displayName,omitempty"` } -// ApplicationsClientListOptions contains the optional parameters for the ApplicationsClient.List method. +// ApplicationsClientListOptions contains the optional parameters for the ApplicationsClient.NewListPager method. type ApplicationsClientListOptions struct { // placeholder for future optional parameters } @@ -1071,7 +1129,7 @@ type ApplicationsList struct { // AscLocation - The ASC location of the subscription is in the "name" field type AscLocation struct { // An empty set of properties - Properties interface{} `json:"properties,omitempty"` + Properties any `json:"properties,omitempty"` // READ-ONLY; Resource Id ID *string `json:"id,omitempty" azure:"ro"` @@ -1394,7 +1452,7 @@ type AssessmentsClientGetOptions struct { Expand *ExpandEnum } -// AssessmentsClientListOptions contains the optional parameters for the AssessmentsClient.List method. +// AssessmentsClientListOptions contains the optional parameters for the AssessmentsClient.NewListPager method. type AssessmentsClientListOptions struct { // placeholder for future optional parameters } @@ -1422,13 +1480,13 @@ type AssessmentsMetadataClientGetOptions struct { // placeholder for future optional parameters } -// AssessmentsMetadataClientListBySubscriptionOptions contains the optional parameters for the AssessmentsMetadataClient.ListBySubscription +// AssessmentsMetadataClientListBySubscriptionOptions contains the optional parameters for the AssessmentsMetadataClient.NewListBySubscriptionPager // method. type AssessmentsMetadataClientListBySubscriptionOptions struct { // placeholder for future optional parameters } -// AssessmentsMetadataClientListOptions contains the optional parameters for the AssessmentsMetadataClient.List method. +// AssessmentsMetadataClientListOptions contains the optional parameters for the AssessmentsMetadataClient.NewListPager method. type AssessmentsMetadataClientListOptions struct { // placeholder for future optional parameters } @@ -1457,7 +1515,7 @@ type AtaExternalSecuritySolution struct { // AtaSolutionProperties - The external security solution properties for ATA solutions type AtaSolutionProperties struct { // OPTIONAL; Contains additional key/value pairs not defined in the schema. - AdditionalProperties map[string]interface{} + AdditionalProperties map[string]any DeviceType *string `json:"deviceType,omitempty"` DeviceVendor *string `json:"deviceVendor,omitempty"` LastEventReceived *string `json:"lastEventReceived,omitempty"` @@ -1535,7 +1593,7 @@ type AutoProvisioningSettingsClientGetOptions struct { // placeholder for future optional parameters } -// AutoProvisioningSettingsClientListOptions contains the optional parameters for the AutoProvisioningSettingsClient.List +// AutoProvisioningSettingsClientListOptions contains the optional parameters for the AutoProvisioningSettingsClient.NewListPager // method. type AutoProvisioningSettingsClientListOptions struct { // placeholder for future optional parameters @@ -1750,13 +1808,13 @@ type AutomationsClientGetOptions struct { // placeholder for future optional parameters } -// AutomationsClientListByResourceGroupOptions contains the optional parameters for the AutomationsClient.ListByResourceGroup +// AutomationsClientListByResourceGroupOptions contains the optional parameters for the AutomationsClient.NewListByResourceGroupPager // method. type AutomationsClientListByResourceGroupOptions struct { // placeholder for future optional parameters } -// AutomationsClientListOptions contains the optional parameters for the AutomationsClient.List method. +// AutomationsClientListOptions contains the optional parameters for the AutomationsClient.NewListPager method. type AutomationsClientListOptions struct { // placeholder for future optional parameters } @@ -1832,13 +1890,19 @@ func (a *AwsCredsAuthenticationDetailsProperties) GetAuthenticationDetailsProper } } -// AwsEnvironmentData - The aws connector environment data +// AwsEnvironmentData - The AWS connector environment data type AwsEnvironmentData struct { // REQUIRED; The type of the environment data. EnvironmentType *EnvironmentType `json:"environmentType,omitempty"` // The AWS account's organizational data OrganizationalData AwsOrganizationalDataClassification `json:"organizationalData,omitempty"` + + // list of regions to scan + Regions []*string `json:"regions,omitempty"` + + // READ-ONLY; The AWS account name + AccountName *string `json:"accountName,omitempty" azure:"ro"` } // GetEnvironmentData implements the EnvironmentDataClassification interface for type AwsEnvironmentData. @@ -1857,7 +1921,7 @@ type AwsOrganizationalDataClassification interface { GetAwsOrganizationalData() *AwsOrganizationalData } -// AwsOrganizationalData - The awsOrganization data +// AwsOrganizationalData - The AWS organization data type AwsOrganizationalData struct { // REQUIRED; The multi cloud account's membership type in the organization OrganizationMembershipType *OrganizationMembershipType `json:"organizationMembershipType,omitempty"` @@ -1866,7 +1930,7 @@ type AwsOrganizationalData struct { // GetAwsOrganizationalData implements the AwsOrganizationalDataClassification interface for type AwsOrganizationalData. func (a *AwsOrganizationalData) GetAwsOrganizationalData() *AwsOrganizationalData { return a } -// AwsOrganizationalDataMaster - The awsOrganization data for the master account +// AwsOrganizationalDataMaster - The AWS organization data for the master account type AwsOrganizationalDataMaster struct { // REQUIRED; The multi cloud account's membership type in the organization OrganizationMembershipType *OrganizationMembershipType `json:"organizationMembershipType,omitempty"` @@ -1885,7 +1949,7 @@ func (a *AwsOrganizationalDataMaster) GetAwsOrganizationalData() *AwsOrganizatio } } -// AwsOrganizationalDataMember - The awsOrganization data for the member account +// AwsOrganizationalDataMember - The AWS organization data for the member account type AwsOrganizationalDataMember struct { // REQUIRED; The multi cloud account's membership type in the organization OrganizationMembershipType *OrganizationMembershipType `json:"organizationMembershipType,omitempty"` @@ -2030,7 +2094,7 @@ type CefExternalSecuritySolution struct { // CefSolutionProperties - The external security solution properties for CEF solutions type CefSolutionProperties struct { // OPTIONAL; Contains additional key/value pairs not defined in the schema. - AdditionalProperties map[string]interface{} + AdditionalProperties map[string]any Agent *string `json:"agent,omitempty"` DeviceType *string `json:"deviceType,omitempty"` DeviceVendor *string `json:"deviceVendor,omitempty"` @@ -2044,10 +2108,10 @@ type CefSolutionProperties struct { // CloudOfferingClassification provides polymorphic access to related types. // Call the interface's GetCloudOffering() method to access the common type. // Use a type switch to determine the concrete type. The possible types are: -// - *CloudOffering, *CspmMonitorAwsOffering, *CspmMonitorAzureDevOpsOffering, *CspmMonitorGcpOffering, *CspmMonitorGithubOffering, -// - *DefenderCspmAwsOffering, *DefenderCspmGcpOffering, *DefenderFoDatabasesAwsOffering, *DefenderForContainersAwsOffering, -// - *DefenderForContainersGcpOffering, *DefenderForDatabasesGcpOffering, *DefenderForDevOpsAzureDevOpsOffering, *DefenderForDevOpsGithubOffering, -// - *DefenderForServersAwsOffering, *DefenderForServersGcpOffering, *InformationProtectionAwsOffering +// - *CloudOffering, *CspmMonitorAwsOffering, *CspmMonitorAzureDevOpsOffering, *CspmMonitorGcpOffering, *CspmMonitorGitLabOffering, +// - *CspmMonitorGithubOffering, *DefenderCspmAwsOffering, *DefenderCspmGcpOffering, *DefenderFoDatabasesAwsOffering, *DefenderForContainersAwsOffering, +// - *DefenderForContainersGcpOffering, *DefenderForDatabasesGcpOffering, *DefenderForDevOpsAzureDevOpsOffering, *DefenderForDevOpsGitLabOffering, +// - *DefenderForDevOpsGithubOffering, *DefenderForServersAwsOffering, *DefenderForServersGcpOffering, *InformationProtectionAwsOffering type CloudOfferingClassification interface { // GetCloudOffering returns the CloudOffering content of the underlying type. GetCloudOffering() *CloudOffering @@ -2139,7 +2203,7 @@ type ComplianceResultsClientGetOptions struct { // placeholder for future optional parameters } -// ComplianceResultsClientListOptions contains the optional parameters for the ComplianceResultsClient.List method. +// ComplianceResultsClientListOptions contains the optional parameters for the ComplianceResultsClient.NewListPager method. type ComplianceResultsClientListOptions struct { // placeholder for future optional parameters } @@ -2158,7 +2222,7 @@ type CompliancesClientGetOptions struct { // placeholder for future optional parameters } -// CompliancesClientListOptions contains the optional parameters for the CompliancesClient.List method. +// CompliancesClientListOptions contains the optional parameters for the CompliancesClient.NewListPager method. type CompliancesClientListOptions struct { // placeholder for future optional parameters } @@ -2367,40 +2431,12 @@ type ConnectorApplicationClientGetOptions struct { // placeholder for future optional parameters } -// ConnectorApplicationsClientListOptions contains the optional parameters for the ConnectorApplicationsClient.List method. -type ConnectorApplicationsClientListOptions struct { - // placeholder for future optional parameters -} - -// ConnectorGovernanceRuleClientListOptions contains the optional parameters for the ConnectorGovernanceRuleClient.List method. -type ConnectorGovernanceRuleClientListOptions struct { - // placeholder for future optional parameters -} - -// ConnectorGovernanceRulesClientCreateOrUpdateOptions contains the optional parameters for the ConnectorGovernanceRulesClient.CreateOrUpdate -// method. -type ConnectorGovernanceRulesClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters -} - -// ConnectorGovernanceRulesClientDeleteOptions contains the optional parameters for the ConnectorGovernanceRulesClient.Delete +// ConnectorApplicationsClientListOptions contains the optional parameters for the ConnectorApplicationsClient.NewListPager // method. -type ConnectorGovernanceRulesClientDeleteOptions struct { - // placeholder for future optional parameters -} - -// ConnectorGovernanceRulesClientGetOptions contains the optional parameters for the ConnectorGovernanceRulesClient.Get method. -type ConnectorGovernanceRulesClientGetOptions struct { +type ConnectorApplicationsClientListOptions struct { // placeholder for future optional parameters } -// ConnectorGovernanceRulesExecuteStatusClientBeginGetOptions contains the optional parameters for the ConnectorGovernanceRulesExecuteStatusClient.BeginGet -// method. -type ConnectorGovernanceRulesExecuteStatusClientBeginGetOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - // ConnectorProperties - A set of properties that defines the security connector configuration. type ConnectorProperties struct { // The security connector environment data. @@ -2468,13 +2504,13 @@ type ConnectorsClientGetOptions struct { // placeholder for future optional parameters } -// ConnectorsClientListByResourceGroupOptions contains the optional parameters for the ConnectorsClient.ListByResourceGroup +// ConnectorsClientListByResourceGroupOptions contains the optional parameters for the ConnectorsClient.NewListByResourceGroupPager // method. type ConnectorsClientListByResourceGroupOptions struct { // placeholder for future optional parameters } -// ConnectorsClientListOptions contains the optional parameters for the ConnectorsClient.List method. +// ConnectorsClientListOptions contains the optional parameters for the ConnectorsClient.NewListPager method. type ConnectorsClientListOptions struct { // placeholder for future optional parameters } @@ -2569,7 +2605,7 @@ type ContactsClientGetOptions struct { // placeholder for future optional parameters } -// ContactsClientListOptions contains the optional parameters for the ContactsClient.List method. +// ContactsClientListOptions contains the optional parameters for the ContactsClient.NewListPager method. type ContactsClientListOptions struct { // placeholder for future optional parameters } @@ -2683,6 +2719,23 @@ type CspmMonitorGcpOfferingNativeCloudConnection struct { WorkloadIdentityProviderID *string `json:"workloadIdentityProviderId,omitempty"` } +// CspmMonitorGitLabOffering - The CSPM (Cloud security posture management) monitoring for gitlab offering +type CspmMonitorGitLabOffering struct { + // REQUIRED; The type of the security offering. + OfferingType *OfferingType `json:"offeringType,omitempty"` + + // READ-ONLY; The offering description. + Description *string `json:"description,omitempty" azure:"ro"` +} + +// GetCloudOffering implements the CloudOfferingClassification interface for type CspmMonitorGitLabOffering. +func (c *CspmMonitorGitLabOffering) GetCloudOffering() *CloudOffering { + return &CloudOffering{ + OfferingType: c.OfferingType, + Description: c.Description, + } +} + // CspmMonitorGithubOffering - The CSPM monitoring for github offering type CspmMonitorGithubOffering struct { // REQUIRED; The type of the security offering. @@ -2829,13 +2882,13 @@ type CustomAssessmentAutomationsClientGetOptions struct { // placeholder for future optional parameters } -// CustomAssessmentAutomationsClientListByResourceGroupOptions contains the optional parameters for the CustomAssessmentAutomationsClient.ListByResourceGroup +// CustomAssessmentAutomationsClientListByResourceGroupOptions contains the optional parameters for the CustomAssessmentAutomationsClient.NewListByResourceGroupPager // method. type CustomAssessmentAutomationsClientListByResourceGroupOptions struct { // placeholder for future optional parameters } -// CustomAssessmentAutomationsClientListBySubscriptionOptions contains the optional parameters for the CustomAssessmentAutomationsClient.ListBySubscription +// CustomAssessmentAutomationsClientListBySubscriptionOptions contains the optional parameters for the CustomAssessmentAutomationsClient.NewListBySubscriptionPager // method. type CustomAssessmentAutomationsClientListBySubscriptionOptions struct { // placeholder for future optional parameters @@ -2907,13 +2960,13 @@ type CustomEntityStoreAssignmentsClientGetOptions struct { // placeholder for future optional parameters } -// CustomEntityStoreAssignmentsClientListByResourceGroupOptions contains the optional parameters for the CustomEntityStoreAssignmentsClient.ListByResourceGroup +// CustomEntityStoreAssignmentsClientListByResourceGroupOptions contains the optional parameters for the CustomEntityStoreAssignmentsClient.NewListByResourceGroupPager // method. type CustomEntityStoreAssignmentsClientListByResourceGroupOptions struct { // placeholder for future optional parameters } -// CustomEntityStoreAssignmentsClientListBySubscriptionOptions contains the optional parameters for the CustomEntityStoreAssignmentsClient.ListBySubscription +// CustomEntityStoreAssignmentsClientListBySubscriptionOptions contains the optional parameters for the CustomEntityStoreAssignmentsClient.NewListBySubscriptionPager // method. type CustomEntityStoreAssignmentsClientListBySubscriptionOptions struct { // placeholder for future optional parameters @@ -2962,11 +3015,17 @@ func (d *DataExportSettings) GetSetting() *Setting { } } -// DefenderCspmAwsOffering - The CSPM P1 for Aws offering +// DefenderCspmAwsOffering - The CSPM P1 for AWS offering type DefenderCspmAwsOffering struct { // REQUIRED; The type of the security offering. OfferingType *OfferingType `json:"offeringType,omitempty"` + // The Microsoft Defender Data Sensitivity discovery configuration + DataSensitivityDiscovery *DefenderCspmAwsOfferingDataSensitivityDiscovery `json:"dataSensitivityDiscovery,omitempty"` + + // The databases DSPM configuration + DatabasesDspm *DefenderCspmAwsOfferingDatabasesDspm `json:"databasesDspm,omitempty"` + // The Microsoft Defender for Server VM scanning configuration VMScanners *DefenderCspmAwsOfferingVMScanners `json:"vmScanners,omitempty"` @@ -2982,6 +3041,24 @@ func (d *DefenderCspmAwsOffering) GetCloudOffering() *CloudOffering { } } +// DefenderCspmAwsOfferingDataSensitivityDiscovery - The Microsoft Defender Data Sensitivity discovery configuration +type DefenderCspmAwsOfferingDataSensitivityDiscovery struct { + // The cloud role ARN in AWS for this feature + CloudRoleArn *string `json:"cloudRoleArn,omitempty"` + + // Is Microsoft Defender Data Sensitivity discovery enabled + Enabled *bool `json:"enabled,omitempty"` +} + +// DefenderCspmAwsOfferingDatabasesDspm - The databases DSPM configuration +type DefenderCspmAwsOfferingDatabasesDspm struct { + // The cloud role ARN in AWS for this feature + CloudRoleArn *string `json:"cloudRoleArn,omitempty"` + + // Is databases DSPM protection enabled + Enabled *bool `json:"enabled,omitempty"` +} + // DefenderCspmAwsOfferingVMScanners - The Microsoft Defender for Server VM scanning configuration type DefenderCspmAwsOfferingVMScanners struct { // configuration for Microsoft Defender for Server VM scanning @@ -2999,7 +3076,7 @@ type DefenderCspmAwsOfferingVMScannersConfiguration struct { // VM tags that indicates that VM should not be scanned ExclusionTags map[string]*string `json:"exclusionTags,omitempty"` - // The scanning mode for the vm scan. + // The scanning mode for the VM scan. ScanningMode *ScanningMode `json:"scanningMode,omitempty"` } @@ -3028,6 +3105,9 @@ type DefenderFoDatabasesAwsOffering struct { // The ARC autoprovisioning configuration ArcAutoProvisioning *DefenderFoDatabasesAwsOfferingArcAutoProvisioning `json:"arcAutoProvisioning,omitempty"` + // The databases data security posture management (DSPM) configuration + DatabasesDspm *DefenderFoDatabasesAwsOfferingDatabasesDspm `json:"databasesDspm,omitempty"` + // The RDS configuration Rds *DefenderFoDatabasesAwsOfferingRds `json:"rds,omitempty"` @@ -3048,10 +3128,31 @@ type DefenderFoDatabasesAwsOfferingArcAutoProvisioning struct { // The cloud role ARN in AWS for this feature CloudRoleArn *string `json:"cloudRoleArn,omitempty"` + // Configuration for servers Arc auto provisioning + Configuration *DefenderFoDatabasesAwsOfferingArcAutoProvisioningConfiguration `json:"configuration,omitempty"` + // Is arc auto provisioning enabled Enabled *bool `json:"enabled,omitempty"` } +// DefenderFoDatabasesAwsOfferingArcAutoProvisioningConfiguration - Configuration for servers Arc auto provisioning +type DefenderFoDatabasesAwsOfferingArcAutoProvisioningConfiguration struct { + // Optional Arc private link scope resource id to link the Arc agent + PrivateLinkScope *string `json:"privateLinkScope,omitempty"` + + // Optional http proxy endpoint to use for the Arc agent + Proxy *string `json:"proxy,omitempty"` +} + +// DefenderFoDatabasesAwsOfferingDatabasesDspm - The databases data security posture management (DSPM) configuration +type DefenderFoDatabasesAwsOfferingDatabasesDspm struct { + // The cloud role ARN in AWS for this feature + CloudRoleArn *string `json:"cloudRoleArn,omitempty"` + + // Is databases data security posture management (DSPM) protection enabled + Enabled *bool `json:"enabled,omitempty"` +} + // DefenderFoDatabasesAwsOfferingRds - The RDS configuration type DefenderFoDatabasesAwsOfferingRds struct { // The cloud role ARN in AWS for this feature @@ -3219,10 +3320,22 @@ func (d *DefenderForDatabasesGcpOffering) GetCloudOffering() *CloudOffering { // DefenderForDatabasesGcpOfferingArcAutoProvisioning - The ARC autoprovisioning configuration type DefenderForDatabasesGcpOfferingArcAutoProvisioning struct { + // Configuration for servers Arc auto provisioning + Configuration *DefenderForDatabasesGcpOfferingArcAutoProvisioningConfiguration `json:"configuration,omitempty"` + // Is arc auto provisioning enabled Enabled *bool `json:"enabled,omitempty"` } +// DefenderForDatabasesGcpOfferingArcAutoProvisioningConfiguration - Configuration for servers Arc auto provisioning +type DefenderForDatabasesGcpOfferingArcAutoProvisioningConfiguration struct { + // Optional Arc private link scope resource id to link the Arc agent + PrivateLinkScope *string `json:"privateLinkScope,omitempty"` + + // Optional http proxy endpoint to use for the Arc agent + Proxy *string `json:"proxy,omitempty"` +} + // DefenderForDatabasesGcpOfferingDefenderForDatabasesArcAutoProvisioning - The native cloud connection configuration type DefenderForDatabasesGcpOfferingDefenderForDatabasesArcAutoProvisioning struct { // The service account email address in GCP for this offering @@ -3249,6 +3362,23 @@ func (d *DefenderForDevOpsAzureDevOpsOffering) GetCloudOffering() *CloudOffering } } +// DefenderForDevOpsGitLabOffering - The Defender for DevOps for Gitlab offering +type DefenderForDevOpsGitLabOffering struct { + // REQUIRED; The type of the security offering. + OfferingType *OfferingType `json:"offeringType,omitempty"` + + // READ-ONLY; The offering description. + Description *string `json:"description,omitempty" azure:"ro"` +} + +// GetCloudOffering implements the CloudOfferingClassification interface for type DefenderForDevOpsGitLabOffering. +func (d *DefenderForDevOpsGitLabOffering) GetCloudOffering() *CloudOffering { + return &CloudOffering{ + OfferingType: d.OfferingType, + Description: d.Description, + } +} + // DefenderForDevOpsGithubOffering - The Defender for DevOps for Github offering type DefenderForDevOpsGithubOffering struct { // REQUIRED; The type of the security offering. @@ -3306,10 +3436,22 @@ type DefenderForServersAwsOfferingArcAutoProvisioning struct { // The cloud role ARN in AWS for this feature CloudRoleArn *string `json:"cloudRoleArn,omitempty"` + // Configuration for servers Arc auto provisioning + Configuration *DefenderForServersAwsOfferingArcAutoProvisioningConfiguration `json:"configuration,omitempty"` + // Is arc auto provisioning enabled Enabled *bool `json:"enabled,omitempty"` } +// DefenderForServersAwsOfferingArcAutoProvisioningConfiguration - Configuration for servers Arc auto provisioning +type DefenderForServersAwsOfferingArcAutoProvisioningConfiguration struct { + // Optional Arc private link scope resource id to link the Arc agent + PrivateLinkScope *string `json:"privateLinkScope,omitempty"` + + // Optional HTTP proxy endpoint to use for the Arc agent + Proxy *string `json:"proxy,omitempty"` +} + // DefenderForServersAwsOfferingDefenderForServers - The Defender for servers connection configuration type DefenderForServersAwsOfferingDefenderForServers struct { // The cloud role ARN in AWS for this feature @@ -3319,7 +3461,7 @@ type DefenderForServersAwsOfferingDefenderForServers struct { // DefenderForServersAwsOfferingMdeAutoProvisioning - The Microsoft Defender for Endpoint autoprovisioning configuration type DefenderForServersAwsOfferingMdeAutoProvisioning struct { // configuration for Microsoft Defender for Endpoint autoprovisioning - Configuration interface{} `json:"configuration,omitempty"` + Configuration any `json:"configuration,omitempty"` // Is Microsoft Defender for Endpoint auto provisioning enabled Enabled *bool `json:"enabled,omitempty"` @@ -3348,7 +3490,7 @@ type DefenderForServersAwsOfferingVMScannersConfiguration struct { // VM tags that indicates that VM should not be scanned ExclusionTags map[string]*string `json:"exclusionTags,omitempty"` - // The scanning mode for the vm scan. + // The scanning mode for the VM scan. ScanningMode *ScanningMode `json:"scanningMode,omitempty"` } @@ -3384,6 +3526,9 @@ type DefenderForServersGcpOffering struct { // configuration for the servers offering subPlan SubPlan *DefenderForServersGcpOfferingSubPlan `json:"subPlan,omitempty"` + // The Microsoft Defender for Server VM scanning configuration + VMScanners *DefenderForServersGcpOfferingVMScanners `json:"vmScanners,omitempty"` + // The Vulnerability Assessment autoprovisioning configuration VaAutoProvisioning *DefenderForServersGcpOfferingVaAutoProvisioning `json:"vaAutoProvisioning,omitempty"` @@ -3401,10 +3546,22 @@ func (d *DefenderForServersGcpOffering) GetCloudOffering() *CloudOffering { // DefenderForServersGcpOfferingArcAutoProvisioning - The ARC autoprovisioning configuration type DefenderForServersGcpOfferingArcAutoProvisioning struct { + // Configuration for servers Arc auto provisioning + Configuration *DefenderForServersGcpOfferingArcAutoProvisioningConfiguration `json:"configuration,omitempty"` + // Is arc auto provisioning enabled Enabled *bool `json:"enabled,omitempty"` } +// DefenderForServersGcpOfferingArcAutoProvisioningConfiguration - Configuration for servers Arc auto provisioning +type DefenderForServersGcpOfferingArcAutoProvisioningConfiguration struct { + // Optional Arc private link scope resource id to link the Arc agent + PrivateLinkScope *string `json:"privateLinkScope,omitempty"` + + // Optional HTTP proxy endpoint to use for the Arc agent + Proxy *string `json:"proxy,omitempty"` +} + // DefenderForServersGcpOfferingDefenderForServers - The Defender for servers connection configuration type DefenderForServersGcpOfferingDefenderForServers struct { // The service account email address in GCP for this feature @@ -3417,7 +3574,7 @@ type DefenderForServersGcpOfferingDefenderForServers struct { // DefenderForServersGcpOfferingMdeAutoProvisioning - The Microsoft Defender for Endpoint autoprovisioning configuration type DefenderForServersGcpOfferingMdeAutoProvisioning struct { // configuration for Microsoft Defender for Endpoint autoprovisioning - Configuration interface{} `json:"configuration,omitempty"` + Configuration any `json:"configuration,omitempty"` // Is Microsoft Defender for Endpoint auto provisioning enabled Enabled *bool `json:"enabled,omitempty"` @@ -3429,6 +3586,24 @@ type DefenderForServersGcpOfferingSubPlan struct { Type *SubPlan `json:"type,omitempty"` } +// DefenderForServersGcpOfferingVMScanners - The Microsoft Defender for Server VM scanning configuration +type DefenderForServersGcpOfferingVMScanners struct { + // configuration for Microsoft Defender for Server VM scanning + Configuration *DefenderForServersGcpOfferingVMScannersConfiguration `json:"configuration,omitempty"` + + // Is Microsoft Defender for Server VM scanning enabled + Enabled *bool `json:"enabled,omitempty"` +} + +// DefenderForServersGcpOfferingVMScannersConfiguration - configuration for Microsoft Defender for Server VM scanning +type DefenderForServersGcpOfferingVMScannersConfiguration struct { + // VM tags that indicate that VM should not be scanned + ExclusionTags map[string]*string `json:"exclusionTags,omitempty"` + + // The scanning mode for the VM scan. + ScanningMode *ScanningMode `json:"scanningMode,omitempty"` +} + // DefenderForServersGcpOfferingVaAutoProvisioning - The Vulnerability Assessment autoprovisioning configuration type DefenderForServersGcpOfferingVaAutoProvisioning struct { // configuration for Vulnerability Assessment autoprovisioning @@ -3541,7 +3716,8 @@ type DeviceSecurityGroupsClientGetOptions struct { // placeholder for future optional parameters } -// DeviceSecurityGroupsClientListOptions contains the optional parameters for the DeviceSecurityGroupsClient.List method. +// DeviceSecurityGroupsClientListOptions contains the optional parameters for the DeviceSecurityGroupsClient.NewListPager +// method. type DeviceSecurityGroupsClientListOptions struct { // placeholder for future optional parameters } @@ -3649,13 +3825,13 @@ type DiscoveredSecuritySolutionsClientGetOptions struct { // placeholder for future optional parameters } -// DiscoveredSecuritySolutionsClientListByHomeRegionOptions contains the optional parameters for the DiscoveredSecuritySolutionsClient.ListByHomeRegion +// DiscoveredSecuritySolutionsClientListByHomeRegionOptions contains the optional parameters for the DiscoveredSecuritySolutionsClient.NewListByHomeRegionPager // method. type DiscoveredSecuritySolutionsClientListByHomeRegionOptions struct { // placeholder for future optional parameters } -// DiscoveredSecuritySolutionsClientListOptions contains the optional parameters for the DiscoveredSecuritySolutionsClient.List +// DiscoveredSecuritySolutionsClientListOptions contains the optional parameters for the DiscoveredSecuritySolutionsClient.NewListPager // method. type DiscoveredSecuritySolutionsClientListOptions struct { // placeholder for future optional parameters @@ -3679,7 +3855,8 @@ type EffectiveNetworkSecurityGroups struct { // EnvironmentDataClassification provides polymorphic access to related types. // Call the interface's GetEnvironmentData() method to access the common type. // Use a type switch to determine the concrete type. The possible types are: -// - *AwsEnvironmentData, *AzureDevOpsScopeEnvironmentData, *EnvironmentData, *GcpProjectEnvironmentData, *GithubScopeEnvironmentData +// - *AwsEnvironmentData, *AzureDevOpsScopeEnvironmentData, *EnvironmentData, *GcpProjectEnvironmentData, *GithubScopeEnvironmentData, +// - *GitlabScopeEnvironmentData type EnvironmentDataClassification interface { // GetEnvironmentData returns the EnvironmentData content of the underlying type. GetEnvironmentData() *EnvironmentData @@ -3694,25 +3871,115 @@ type EnvironmentData struct { // GetEnvironmentData implements the EnvironmentDataClassification interface for type EnvironmentData. func (e *EnvironmentData) GetEnvironmentData() *EnvironmentData { return e } +// EnvironmentDetails - The environment details of the resource +type EnvironmentDetails struct { + // The hierarchy id of the connector (in case of Azure - the subscription Id, in case of MC - the hierarchyId id) + EnvironmentHierarchyID *string `json:"environmentHierarchyId,omitempty"` + + // The native resource id of the resource (in case of Azure - the resource Id, in case of MC - the native resource id) + NativeResourceID *string `json:"nativeResourceId,omitempty"` + + // The organizational hierarchy id of the connector (in case of Azure - the subscription Id, in case of MC - the organizational + // hierarchyId id) + OrganizationalHierarchyID *string `json:"organizationalHierarchyId,omitempty"` + + // The subscription Id + SubscriptionID *string `json:"subscriptionId,omitempty"` + + // The tenant Id + TenantID *string `json:"tenantId,omitempty"` +} + // ErrorAdditionalInfo - The resource management error additional info. type ErrorAdditionalInfo struct { // READ-ONLY; The additional info. - Info interface{} `json:"info,omitempty" azure:"ro"` + Info any `json:"info,omitempty" azure:"ro"` // READ-ONLY; The additional info type. Type *string `json:"type,omitempty" azure:"ro"` } +// ErrorDetail - The error detail. +type ErrorDetail struct { + // READ-ONLY; The error additional info. + AdditionalInfo []*ErrorAdditionalInfo `json:"additionalInfo,omitempty" azure:"ro"` + + // READ-ONLY; The error code. + Code *string `json:"code,omitempty" azure:"ro"` + + // READ-ONLY; The error details. + Details []*ErrorDetail `json:"details,omitempty" azure:"ro"` + + // READ-ONLY; The error message. + Message *string `json:"message,omitempty" azure:"ro"` + + // READ-ONLY; The error target. + Target *string `json:"target,omitempty" azure:"ro"` +} + +// ErrorDetailAutoGenerated - The error detail. +type ErrorDetailAutoGenerated struct { + // READ-ONLY; The error additional info. + AdditionalInfo []*ErrorAdditionalInfo `json:"additionalInfo,omitempty" azure:"ro"` + + // READ-ONLY; The error code. + Code *string `json:"code,omitempty" azure:"ro"` + + // READ-ONLY; The error details. + Details []*ErrorDetailAutoGenerated `json:"details,omitempty" azure:"ro"` + + // READ-ONLY; The error message. + Message *string `json:"message,omitempty" azure:"ro"` + + // READ-ONLY; The error target. + Target *string `json:"target,omitempty" azure:"ro"` +} + +// ErrorResponse - Common error response for all Azure Resource Manager APIs to return error details for failed operations. +// (This also follows the OData error response format.). +type ErrorResponse struct { + // The error object. + Error *ErrorDetail `json:"error,omitempty"` +} + +// ErrorResponseAutoGenerated - Common error response for all Azure Resource Manager APIs to return error details for failed +// operations. (This also follows the OData error response format.). +type ErrorResponseAutoGenerated struct { + // The error object. + Error *ErrorDetailAutoGenerated `json:"error,omitempty"` +} + // ExecuteGovernanceRuleParams - Governance rule execution parameters type ExecuteGovernanceRuleParams struct { // Describe if governance rule should be override Override *bool `json:"override,omitempty"` } -// ExecuteRuleStatus - Execute status of Security GovernanceRule over a given scope -type ExecuteRuleStatus struct { - // READ-ONLY; Unique key for the execution of GovernanceRule - OperationID *string `json:"operationId,omitempty" azure:"ro"` +// Extension - A plan's extension properties +type Extension struct { + // REQUIRED; Indicates whether the extension is enabled. + IsEnabled *IsEnabled `json:"isEnabled,omitempty"` + + // REQUIRED; The extension name. Supported values are: + // AgentlessDiscoveryForKubernetes - API-based discovery of information about Kubernetes cluster architecture, workload objects, + // and setup. Required for Kubernetes inventory, identity and network + // exposure detection, attack path analysis and risk hunting as part of the cloud security explorer. Available for CloudPosture + // plan. + // OnUploadMalwareScanning - Limits the GB to be scanned per month for each storage account within the subscription. Once + // this limit reached on a given storage account, Blobs won't be scanned during + // current calendar month. Available for StorageAccounts plan. + // SensitiveDataDiscovery - Sensitive data discovery identifies Blob storage container with sensitive data such as credentials, + // credit cards, and more, to help prioritize and investigate security events. + // Available for StorageAccounts and CloudPosture plans. + // ContainerRegistriesVulnerabilityAssessments - Provides vulnerability management for images stored in your container registries. + // Available for CloudPosture and Containers plans. + Name *string `json:"name,omitempty"` + + // Property values associated with the extension. + AdditionalExtensionProperties map[string]any `json:"additionalExtensionProperties,omitempty"` + + // READ-ONLY; Optional. A status describing the success/failure of the extension's enablement/disablement operation. + OperationStatus *OperationStatus `json:"operationStatus,omitempty" azure:"ro"` } // ExternalSecuritySolution - Represents a security solution external to Microsoft Defender for Cloud which sends information @@ -3750,7 +4017,7 @@ type ExternalSecuritySolutionList struct { // ExternalSecuritySolutionProperties - The solution properties (correspond to the solution kind) type ExternalSecuritySolutionProperties struct { // OPTIONAL; Contains additional key/value pairs not defined in the schema. - AdditionalProperties map[string]interface{} + AdditionalProperties map[string]any DeviceType *string `json:"deviceType,omitempty"` DeviceVendor *string `json:"deviceVendor,omitempty"` @@ -3764,13 +4031,13 @@ type ExternalSecuritySolutionsClientGetOptions struct { // placeholder for future optional parameters } -// ExternalSecuritySolutionsClientListByHomeRegionOptions contains the optional parameters for the ExternalSecuritySolutionsClient.ListByHomeRegion +// ExternalSecuritySolutionsClientListByHomeRegionOptions contains the optional parameters for the ExternalSecuritySolutionsClient.NewListByHomeRegionPager // method. type ExternalSecuritySolutionsClientListByHomeRegionOptions struct { // placeholder for future optional parameters } -// ExternalSecuritySolutionsClientListOptions contains the optional parameters for the ExternalSecuritySolutionsClient.List +// ExternalSecuritySolutionsClientListOptions contains the optional parameters for the ExternalSecuritySolutionsClient.NewListPager // method. type ExternalSecuritySolutionsClientListOptions struct { // placeholder for future optional parameters @@ -4000,6 +4267,9 @@ type GcpOrganizationalDataOrganization struct { // The GCP workload identity provider id which represents the permissions required to auto provision security connectors WorkloadIdentityProviderID *string `json:"workloadIdentityProviderId,omitempty"` + + // READ-ONLY; GCP organization name + OrganizationName *string `json:"organizationName,omitempty" azure:"ro"` } // GetGcpOrganizationalData implements the GcpOrganizationalDataClassification interface for type GcpOrganizationalDataOrganization. @@ -4017,6 +4287,9 @@ type GcpProjectDetails struct { // The unique GCP Project number ProjectNumber *string `json:"projectNumber,omitempty"` + // READ-ONLY; GCP project name + ProjectName *string `json:"projectName,omitempty" azure:"ro"` + // READ-ONLY; The GCP workload identity federation pool id WorkloadIdentityPoolID *string `json:"workloadIdentityPoolId,omitempty" azure:"ro"` } @@ -4053,9 +4326,22 @@ func (g *GithubScopeEnvironmentData) GetEnvironmentData() *EnvironmentData { } } -// GovernanceAssignment - Security GovernanceAssignment over a given scope +// GitlabScopeEnvironmentData - The GitLab scope connector's environment data +type GitlabScopeEnvironmentData struct { + // REQUIRED; The type of the environment data. + EnvironmentType *EnvironmentType `json:"environmentType,omitempty"` +} + +// GetEnvironmentData implements the EnvironmentDataClassification interface for type GitlabScopeEnvironmentData. +func (g *GitlabScopeEnvironmentData) GetEnvironmentData() *EnvironmentData { + return &EnvironmentData{ + EnvironmentType: g.EnvironmentType, + } +} + +// GovernanceAssignment - Governance assignment over a given scope type GovernanceAssignment struct { - // Properties of a security governanceAssignment + // The properties of a governance assignment Properties *GovernanceAssignmentProperties `json:"properties,omitempty"` // READ-ONLY; Resource Id @@ -4068,15 +4354,15 @@ type GovernanceAssignment struct { Type *string `json:"type,omitempty" azure:"ro"` } -// GovernanceAssignmentAdditionalData - Describe the additional data of GovernanceAssignment - optional +// GovernanceAssignmentAdditionalData - Describe the additional data of governance assignment - optional type GovernanceAssignmentAdditionalData struct { - // Ticket link associated with this GovernanceAssignment - for example: https://snow.com + // Ticket link associated with this governance assignment - for example: https://snow.com TicketLink *string `json:"ticketLink,omitempty"` - // Ticket number associated with this GovernanceAssignment + // Ticket number associated with this governance assignment TicketNumber *int32 `json:"ticketNumber,omitempty"` - // The ticket status associated with this GovernanceAssignment - for example: Active + // The ticket status associated with this governance assignment - for example: Active TicketStatus *string `json:"ticketStatus,omitempty"` } @@ -4117,12 +4403,13 @@ type GovernanceAssignmentsClientGetOptions struct { // placeholder for future optional parameters } -// GovernanceAssignmentsClientListOptions contains the optional parameters for the GovernanceAssignmentsClient.List method. +// GovernanceAssignmentsClientListOptions contains the optional parameters for the GovernanceAssignmentsClient.NewListPager +// method. type GovernanceAssignmentsClientListOptions struct { // placeholder for future optional parameters } -// GovernanceAssignmentsList - Page of a security governance assignments list +// GovernanceAssignmentsList - Page of a governance assignments list type GovernanceAssignmentsList struct { // READ-ONLY; The URI to fetch the next page NextLink *string `json:"nextLink,omitempty" azure:"ro"` @@ -4140,9 +4427,9 @@ type GovernanceEmailNotification struct { DisableOwnerEmailNotification *bool `json:"disableOwnerEmailNotification,omitempty"` } -// GovernanceRule - Security GovernanceRule over a given scope +// GovernanceRule - Governance rule over a given scope type GovernanceRule struct { - // Properties of a security governanceRule + // Properties of a governance rule Properties *GovernanceRuleProperties `json:"properties,omitempty"` // READ-ONLY; Resource Id @@ -4155,29 +4442,39 @@ type GovernanceRule struct { Type *string `json:"type,omitempty" azure:"ro"` } -// GovernanceRuleClientListOptions contains the optional parameters for the GovernanceRuleClient.List method. -type GovernanceRuleClientListOptions struct { - // placeholder for future optional parameters -} - -// GovernanceRuleEmailNotification - The governance email weekly notification configuration. +// GovernanceRuleEmailNotification - The governance email weekly notification configuration type GovernanceRuleEmailNotification struct { - // Defines whether manager email notifications are disabled. + // Defines whether manager email notifications are disabled DisableManagerEmailNotification *bool `json:"disableManagerEmailNotification,omitempty"` - // Defines whether owner email notifications are disabled. + // Defines whether owner email notifications are disabled DisableOwnerEmailNotification *bool `json:"disableOwnerEmailNotification,omitempty"` } -// GovernanceRuleList - Page of a security governanceRules list +// GovernanceRuleList - Page of a governance rules list type GovernanceRuleList struct { // READ-ONLY; The URI to fetch the next page NextLink *string `json:"nextLink,omitempty" azure:"ro"` - // READ-ONLY; Collection of governanceRules in this page + // READ-ONLY; Collection of governance rules in this page Value []*GovernanceRule `json:"value,omitempty" azure:"ro"` } +// GovernanceRuleMetadata - The governance rule metadata +type GovernanceRuleMetadata struct { + // READ-ONLY; Governance rule Created by object id (GUID) + CreatedBy *string `json:"createdBy,omitempty" azure:"ro"` + + // READ-ONLY; Governance rule creation date + CreatedOn *time.Time `json:"createdOn,omitempty" azure:"ro"` + + // READ-ONLY; Governance rule last updated by object id (GUID) + UpdatedBy *string `json:"updatedBy,omitempty" azure:"ro"` + + // READ-ONLY; Governance rule last update date + UpdatedOn *time.Time `json:"updatedOn,omitempty" azure:"ro"` +} + // GovernanceRuleOwnerSource - Describe the owner source of governance rule type GovernanceRuleOwnerSource struct { // The owner type for the governance rule owner source @@ -4187,19 +4484,19 @@ type GovernanceRuleOwnerSource struct { Value *string `json:"value,omitempty"` } -// GovernanceRuleProperties - Describes properties of an governanceRule +// GovernanceRuleProperties - Describes properties of an governance rule type GovernanceRuleProperties struct { // REQUIRED; The governance rule conditionSets - see examples - ConditionSets []interface{} `json:"conditionSets,omitempty"` + ConditionSets []any `json:"conditionSets,omitempty"` - // REQUIRED; display name of the governanceRule + // REQUIRED; Display name of the governance rule DisplayName *string `json:"displayName,omitempty"` - // REQUIRED; The Owner source for the governance rule - e.g. Manually by user@contoso.com - see example + // REQUIRED; The owner source for the governance rule - e.g. Manually by user@contoso.com - see example OwnerSource *GovernanceRuleOwnerSource `json:"ownerSource,omitempty"` - // REQUIRED; The governance rule priority, priority to the lower number. Rules with the same priority on the same subscription - // will not be allowed + // REQUIRED; The governance rule priority, priority to the lower number. Rules with the same priority on the same scope will + // not be allowed RulePriority *int32 `json:"rulePriority,omitempty"` // REQUIRED; The rule type of the governance rule, defines the source of the rule e.g. Integrated @@ -4208,36 +4505,44 @@ type GovernanceRuleProperties struct { // REQUIRED; The governance rule source, what the rule affects, e.g. Assessments SourceResourceType *GovernanceRuleSourceResourceType `json:"sourceResourceType,omitempty"` - // description of the governanceRule + // Description of the governance rule Description *string `json:"description,omitempty"` + // Excluded scopes, filter out the descendants of the scope (on management scopes) + ExcludedScopes []*string `json:"excludedScopes,omitempty"` + // The email notifications settings for the governance rule, states whether to disable notifications for mangers and owners GovernanceEmailNotification *GovernanceRuleEmailNotification `json:"governanceEmailNotification,omitempty"` + // Defines whether the rule is management scope rule (master connector as a single scope or management scope) + IncludeMemberScopes *bool `json:"includeMemberScopes,omitempty"` + // Defines whether the rule is active/inactive IsDisabled *bool `json:"isDisabled,omitempty"` // Defines whether there is a grace period on the governance rule IsGracePeriod *bool `json:"isGracePeriod,omitempty"` + // The governance rule metadata + Metadata *GovernanceRuleMetadata `json:"metadata,omitempty"` + // Governance rule remediation timeframe - this is the time that will affect on the grace-period duration e.g. 7.00:00:00 // - means 7 days RemediationTimeframe *string `json:"remediationTimeframe,omitempty"` + + // READ-ONLY; The tenantId (GUID) + TenantID *string `json:"tenantId,omitempty" azure:"ro"` } -// GovernanceRulesClientBeginRuleIDExecuteSingleSecurityConnectorOptions contains the optional parameters for the GovernanceRulesClient.BeginRuleIDExecuteSingleSecurityConnector -// method. -type GovernanceRulesClientBeginRuleIDExecuteSingleSecurityConnectorOptions struct { - // GovernanceRule over a subscription scope - ExecuteGovernanceRuleParams *ExecuteGovernanceRuleParams +// GovernanceRulesClientBeginDeleteOptions contains the optional parameters for the GovernanceRulesClient.BeginDelete method. +type GovernanceRulesClientBeginDeleteOptions struct { // Resumes the LRO from the provided token. ResumeToken string } -// GovernanceRulesClientBeginRuleIDExecuteSingleSubscriptionOptions contains the optional parameters for the GovernanceRulesClient.BeginRuleIDExecuteSingleSubscription -// method. -type GovernanceRulesClientBeginRuleIDExecuteSingleSubscriptionOptions struct { - // GovernanceRule over a subscription scope +// GovernanceRulesClientBeginExecuteOptions contains the optional parameters for the GovernanceRulesClient.BeginExecute method. +type GovernanceRulesClientBeginExecuteOptions struct { + // Execute governance rule over a given scope ExecuteGovernanceRuleParams *ExecuteGovernanceRuleParams // Resumes the LRO from the provided token. ResumeToken string @@ -4249,13 +4554,19 @@ type GovernanceRulesClientCreateOrUpdateOptions struct { // placeholder for future optional parameters } -// GovernanceRulesClientDeleteOptions contains the optional parameters for the GovernanceRulesClient.Delete method. -type GovernanceRulesClientDeleteOptions struct { +// GovernanceRulesClientGetOptions contains the optional parameters for the GovernanceRulesClient.Get method. +type GovernanceRulesClientGetOptions struct { // placeholder for future optional parameters } -// GovernanceRulesClientGetOptions contains the optional parameters for the GovernanceRulesClient.Get method. -type GovernanceRulesClientGetOptions struct { +// GovernanceRulesClientListOptions contains the optional parameters for the GovernanceRulesClient.NewListPager method. +type GovernanceRulesClientListOptions struct { + // placeholder for future optional parameters +} + +// GovernanceRulesClientOperationResultsOptions contains the optional parameters for the GovernanceRulesClient.OperationResults +// method. +type GovernanceRulesClientOperationResultsOptions struct { // placeholder for future optional parameters } @@ -4437,6 +4748,73 @@ func (h *HTTPD2CMessagesNotInAllowedRange) GetTimeWindowCustomAlertRule() *TimeW } } +// HealthDataClassification - The classification of the health report +type HealthDataClassification struct { + // The component describes the name of the agent/service that scans the issue + Component *string `json:"component,omitempty"` + + // The scenario describes the health scenario issue of the component + Scenario *string `json:"scenario,omitempty"` + + // The resource scope of the health report + Scope *ScopeName `json:"scope,omitempty"` +} + +// HealthReport - The health report resource +type HealthReport struct { + // Properties of a health report + Properties *HealthReportProperties `json:"properties,omitempty"` + + // READ-ONLY; Resource Id + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; Resource name + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Resource type + Type *string `json:"type,omitempty" azure:"ro"` +} + +// HealthReportClientGetOptions contains the optional parameters for the HealthReportClient.Get method. +type HealthReportClientGetOptions struct { + // placeholder for future optional parameters +} + +// HealthReportProperties - Describes properties of the health report +type HealthReportProperties struct { + // The affected defenders plans by unhealthy report + AffectedDefendersPlans []*string `json:"affectedDefendersPlans,omitempty"` + + // The environment details of the resource + EnvironmentDetails *EnvironmentDetails `json:"environmentDetails,omitempty"` + + // The classification of the health report + HealthDataClassification *HealthDataClassification `json:"healthDataClassification,omitempty"` + + // A collection of the issues in the report + Issues []*Issue `json:"issues,omitempty"` + + // The resource details of the health report + ResourceDetails *ResourceDetailsAutoGenerated `json:"resourceDetails,omitempty"` + + // The status of the health report + Status *StatusAutoGenerated `json:"status,omitempty"` +} + +// HealthReportsClientListOptions contains the optional parameters for the HealthReportsClient.NewListPager method. +type HealthReportsClientListOptions struct { + // placeholder for future optional parameters +} + +// HealthReportsList - Page of health reports list +type HealthReportsList struct { + // READ-ONLY; The URI to fetch the next page + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; Collection of health reports in this page + Value []*HealthReport `json:"value,omitempty" azure:"ro"` +} + // HybridComputeSettingsProperties - Settings for hybrid compute management type HybridComputeSettingsProperties struct { // REQUIRED; Whether or not to automatically install Azure Arc (hybrid compute) agents on machines @@ -4512,7 +4890,7 @@ type InformationProtectionPoliciesClientGetOptions struct { // placeholder for future optional parameters } -// InformationProtectionPoliciesClientListOptions contains the optional parameters for the InformationProtectionPoliciesClient.List +// InformationProtectionPoliciesClientListOptions contains the optional parameters for the InformationProtectionPoliciesClient.NewListPager // method. type InformationProtectionPoliciesClientListOptions struct { // placeholder for future optional parameters @@ -4593,7 +4971,7 @@ type IngestionConnectionString struct { // IngestionSetting - Configures how to correlate scan data and logs with resources associated with the subscription. type IngestionSetting struct { // Ingestion setting data - Properties interface{} `json:"properties,omitempty"` + Properties any `json:"properties,omitempty"` // READ-ONLY; Resource Id ID *string `json:"id,omitempty" azure:"ro"` @@ -4641,7 +5019,7 @@ type IngestionSettingsClientListConnectionStringsOptions struct { // placeholder for future optional parameters } -// IngestionSettingsClientListOptions contains the optional parameters for the IngestionSettingsClient.List method. +// IngestionSettingsClientListOptions contains the optional parameters for the IngestionSettingsClient.NewListPager method. type IngestionSettingsClientListOptions struct { // placeholder for future optional parameters } @@ -4987,14 +5365,14 @@ type IotSecuritySolutionClientGetOptions struct { // placeholder for future optional parameters } -// IotSecuritySolutionClientListByResourceGroupOptions contains the optional parameters for the IotSecuritySolutionClient.ListByResourceGroup +// IotSecuritySolutionClientListByResourceGroupOptions contains the optional parameters for the IotSecuritySolutionClient.NewListByResourceGroupPager // method. type IotSecuritySolutionClientListByResourceGroupOptions struct { // Filter the IoT Security solution with OData syntax. Supports filtering by iotHubs. Filter *string } -// IotSecuritySolutionClientListBySubscriptionOptions contains the optional parameters for the IotSecuritySolutionClient.ListBySubscription +// IotSecuritySolutionClientListBySubscriptionOptions contains the optional parameters for the IotSecuritySolutionClient.NewListBySubscriptionPager // method. type IotSecuritySolutionClientListBySubscriptionOptions struct { // Filter the IoT Security solution with OData syntax. Supports filtering by iotHubs. @@ -5018,7 +5396,7 @@ type IotSecuritySolutionsAnalyticsAggregatedAlertClientGetOptions struct { // placeholder for future optional parameters } -// IotSecuritySolutionsAnalyticsAggregatedAlertClientListOptions contains the optional parameters for the IotSecuritySolutionsAnalyticsAggregatedAlertClient.List +// IotSecuritySolutionsAnalyticsAggregatedAlertClientListOptions contains the optional parameters for the IotSecuritySolutionsAnalyticsAggregatedAlertClient.NewListPager // method. type IotSecuritySolutionsAnalyticsAggregatedAlertClientListOptions struct { // Number of results to retrieve. @@ -5031,13 +5409,38 @@ type IotSecuritySolutionsAnalyticsRecommendationClientGetOptions struct { // placeholder for future optional parameters } -// IotSecuritySolutionsAnalyticsRecommendationClientListOptions contains the optional parameters for the IotSecuritySolutionsAnalyticsRecommendationClient.List +// IotSecuritySolutionsAnalyticsRecommendationClientListOptions contains the optional parameters for the IotSecuritySolutionsAnalyticsRecommendationClient.NewListPager // method. type IotSecuritySolutionsAnalyticsRecommendationClientListOptions struct { // Number of results to retrieve. Top *int32 } +// Issue - The issue that caused the resource to by unhealthy +type Issue struct { + // REQUIRED; The unique issue key + IssueKey *string `json:"issueKey,omitempty"` + + // Additional data for the given issue. The additional data depends on the issue type + IssueAdditionalData map[string]*string `json:"issueAdditionalData,omitempty"` + + // The issue description + IssueDescription *string `json:"issueDescription,omitempty"` + + // The issue name + IssueName *string `json:"issueName,omitempty"` + + // The remediation script to solve this issue + RemediationScript *string `json:"remediationScript,omitempty"` + + // Human readable description of what you should do to mitigate this health issue + RemediationSteps *string `json:"remediationSteps,omitempty"` + + // The affected security values that MDC offers that will be affected by the issue, for example: recommendations, alerts, + // etc + SecurityValues []*string `json:"securityValues,omitempty"` +} + // JitNetworkAccessPoliciesClientCreateOrUpdateOptions contains the optional parameters for the JitNetworkAccessPoliciesClient.CreateOrUpdate // method. type JitNetworkAccessPoliciesClientCreateOrUpdateOptions struct { @@ -5061,25 +5464,25 @@ type JitNetworkAccessPoliciesClientInitiateOptions struct { // placeholder for future optional parameters } -// JitNetworkAccessPoliciesClientListByRegionOptions contains the optional parameters for the JitNetworkAccessPoliciesClient.ListByRegion +// JitNetworkAccessPoliciesClientListByRegionOptions contains the optional parameters for the JitNetworkAccessPoliciesClient.NewListByRegionPager // method. type JitNetworkAccessPoliciesClientListByRegionOptions struct { // placeholder for future optional parameters } -// JitNetworkAccessPoliciesClientListByResourceGroupAndRegionOptions contains the optional parameters for the JitNetworkAccessPoliciesClient.ListByResourceGroupAndRegion +// JitNetworkAccessPoliciesClientListByResourceGroupAndRegionOptions contains the optional parameters for the JitNetworkAccessPoliciesClient.NewListByResourceGroupAndRegionPager // method. type JitNetworkAccessPoliciesClientListByResourceGroupAndRegionOptions struct { // placeholder for future optional parameters } -// JitNetworkAccessPoliciesClientListByResourceGroupOptions contains the optional parameters for the JitNetworkAccessPoliciesClient.ListByResourceGroup +// JitNetworkAccessPoliciesClientListByResourceGroupOptions contains the optional parameters for the JitNetworkAccessPoliciesClient.NewListByResourceGroupPager // method. type JitNetworkAccessPoliciesClientListByResourceGroupOptions struct { // placeholder for future optional parameters } -// JitNetworkAccessPoliciesClientListOptions contains the optional parameters for the JitNetworkAccessPoliciesClient.List +// JitNetworkAccessPoliciesClientListOptions contains the optional parameters for the JitNetworkAccessPoliciesClient.NewListPager // method. type JitNetworkAccessPoliciesClientListOptions struct { // placeholder for future optional parameters @@ -5336,7 +5739,7 @@ type LocationsClientGetOptions struct { // placeholder for future optional parameters } -// LocationsClientListOptions contains the optional parameters for the LocationsClient.List method. +// LocationsClientListOptions contains the optional parameters for the LocationsClient.NewListPager method. type LocationsClientListOptions struct { // placeholder for future optional parameters } @@ -5702,7 +6105,22 @@ type OperationList struct { NextLink *string `json:"nextLink,omitempty" azure:"ro"` } -// OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// OperationResultAutoGenerated - Long run operation status of governance rule over a given scope +type OperationResultAutoGenerated struct { + // READ-ONLY; The status of the long run operation result of governance rule + Status *OperationResult `json:"status,omitempty" azure:"ro"` +} + +// OperationStatus - A status describing the success/failure of the extension's enablement/disablement operation. +type OperationStatus struct { + // The operation status code. + Code *Code `json:"code,omitempty"` + + // Additional information regarding the success/failure of the operation. + Message *string `json:"message,omitempty"` +} + +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. type OperationsClientListOptions struct { // placeholder for future optional parameters } @@ -5733,9 +6151,8 @@ type PathRecommendation struct { Usernames []*UserRecommendation `json:"usernames,omitempty"` } -// Pricing - Microsoft Defender for Cloud is provided in two pricing tiers: free and standard, with the standard tier available -// with a trial period. The standard tier offers advanced security capabilities, while -// the free tier offers basic security features. +// Pricing - Microsoft Defender for Cloud is provided in two pricing tiers: free and standard. The standard tier offers advanced +// security capabilities, while the free tier offers basic security features. type Pricing struct { // Pricing data Properties *PricingProperties `json:"properties,omitempty"` @@ -5758,11 +6175,14 @@ type PricingList struct { // PricingProperties - Pricing properties for the relevant scope type PricingProperties struct { - // REQUIRED; The pricing tier value. Microsoft Defender for Cloud is provided in two pricing tiers: free and standard, with - // the standard tier available with a trial period. The standard tier offers advanced - // security capabilities, while the free tier offers basic security features. + // REQUIRED; The pricing tier value. Microsoft Defender for Cloud is provided in two pricing tiers: free and standard. The + // standard tier offers advanced security capabilities, while the free tier offers basic + // security features. PricingTier *PricingTier `json:"pricingTier,omitempty"` + // Optional. List of extensions offered under a plan. + Extensions []*Extension `json:"extensions,omitempty"` + // The sub-plan selected for a Standard pricing configuration, when more than one sub-plan is available. Each sub-plan enables // a set of security features. When not specified, full plan is applied. SubPlan *string `json:"subPlan,omitempty"` @@ -5770,6 +6190,10 @@ type PricingProperties struct { // READ-ONLY; Optional. True if the plan is deprecated. If there are replacing plans they will appear in replacedBy property Deprecated *bool `json:"deprecated,omitempty" azure:"ro"` + // READ-ONLY; Optional. If pricingTier is Standard then this property holds the date of the last time the pricingTier was + // set to Standard, when available (e.g 2023-03-01T12:42:42.1921106Z). + EnablementTime *time.Time `json:"enablementTime,omitempty" azure:"ro"` + // READ-ONLY; The duration left for the subscriptions free trial period - in ISO 8601 format (e.g. P3Y6M4DT12H30M5S). FreeTrialRemainingTime *string `json:"freeTrialRemainingTime,omitempty" azure:"ro"` @@ -6028,7 +6452,7 @@ type RegulatoryComplianceAssessmentsClientGetOptions struct { // placeholder for future optional parameters } -// RegulatoryComplianceAssessmentsClientListOptions contains the optional parameters for the RegulatoryComplianceAssessmentsClient.List +// RegulatoryComplianceAssessmentsClientListOptions contains the optional parameters for the RegulatoryComplianceAssessmentsClient.NewListPager // method. type RegulatoryComplianceAssessmentsClientListOptions struct { // OData filter. Optional. @@ -6083,7 +6507,7 @@ type RegulatoryComplianceControlsClientGetOptions struct { // placeholder for future optional parameters } -// RegulatoryComplianceControlsClientListOptions contains the optional parameters for the RegulatoryComplianceControlsClient.List +// RegulatoryComplianceControlsClientListOptions contains the optional parameters for the RegulatoryComplianceControlsClient.NewListPager // method. type RegulatoryComplianceControlsClientListOptions struct { // OData filter. Optional. @@ -6138,7 +6562,7 @@ type RegulatoryComplianceStandardsClientGetOptions struct { // placeholder for future optional parameters } -// RegulatoryComplianceStandardsClientListOptions contains the optional parameters for the RegulatoryComplianceStandardsClient.List +// RegulatoryComplianceStandardsClientListOptions contains the optional parameters for the RegulatoryComplianceStandardsClient.NewListPager // method. type RegulatoryComplianceStandardsClientListOptions struct { // OData filter. Optional. @@ -6199,6 +6623,18 @@ type ResourceDetails struct { // GetResourceDetails implements the ResourceDetailsClassification interface for type ResourceDetails. func (r *ResourceDetails) GetResourceDetails() *ResourceDetails { return r } +// ResourceDetailsAutoGenerated - The resource details of the health report +type ResourceDetailsAutoGenerated struct { + // The status of the health report + Source *Source `json:"source,omitempty"` + + // READ-ONLY; The id of the connector + ConnectorID *string `json:"connectorId,omitempty" azure:"ro"` + + // READ-ONLY; The azure id of the resource + ID *string `json:"id,omitempty" azure:"ro"` +} + // ResourceIdentifierClassification provides polymorphic access to related types. // Call the interface's GetResourceIdentifier() method to access the common type. // Use a type switch to determine the concrete type. The possible types are: @@ -6386,6 +6822,9 @@ type ScanProperties struct { // Baseline created for this database, and has one or more rules. IsBaselineApplied *bool `json:"isBaselineApplied,omitempty"` + // Last scan time. + LastScanTime *time.Time `json:"lastScanTime,omitempty"` + // The number of failed rules with low severity. LowSeverityFailedRulesCount *int32 `json:"lowSeverityFailedRulesCount,omitempty"` @@ -6471,7 +6910,7 @@ type Scans struct { // ScopeElement - A more specific scope used to identify the alerts to suppress. type ScopeElement struct { // OPTIONAL; Contains additional key/value pairs not defined in the schema. - AdditionalProperties map[string]interface{} + AdditionalProperties map[string]any // The alert entity type to suppress by. Field *string `json:"field,omitempty"` @@ -6537,13 +6976,13 @@ type SecureScoreControlDefinitionSource struct { SourceType *ControlType `json:"sourceType,omitempty"` } -// SecureScoreControlDefinitionsClientListBySubscriptionOptions contains the optional parameters for the SecureScoreControlDefinitionsClient.ListBySubscription +// SecureScoreControlDefinitionsClientListBySubscriptionOptions contains the optional parameters for the SecureScoreControlDefinitionsClient.NewListBySubscriptionPager // method. type SecureScoreControlDefinitionsClientListBySubscriptionOptions struct { // placeholder for future optional parameters } -// SecureScoreControlDefinitionsClientListOptions contains the optional parameters for the SecureScoreControlDefinitionsClient.List +// SecureScoreControlDefinitionsClientListOptions contains the optional parameters for the SecureScoreControlDefinitionsClient.NewListPager // method. type SecureScoreControlDefinitionsClientListOptions struct { // placeholder for future optional parameters @@ -6611,14 +7050,14 @@ type SecureScoreControlScoreDetails struct { Weight *int64 `json:"weight,omitempty" azure:"ro"` } -// SecureScoreControlsClientListBySecureScoreOptions contains the optional parameters for the SecureScoreControlsClient.ListBySecureScore +// SecureScoreControlsClientListBySecureScoreOptions contains the optional parameters for the SecureScoreControlsClient.NewListBySecureScorePager // method. type SecureScoreControlsClientListBySecureScoreOptions struct { // OData expand. Optional. Expand *ExpandControlsEnum } -// SecureScoreControlsClientListOptions contains the optional parameters for the SecureScoreControlsClient.List method. +// SecureScoreControlsClientListOptions contains the optional parameters for the SecureScoreControlsClient.NewListPager method. type SecureScoreControlsClientListOptions struct { // OData expand. Optional. Expand *ExpandControlsEnum @@ -6656,7 +7095,7 @@ type SecureScoresClientGetOptions struct { // placeholder for future optional parameters } -// SecureScoresClientListOptions contains the optional parameters for the SecureScoresClient.List method. +// SecureScoresClientListOptions contains the optional parameters for the SecureScoresClient.NewListPager method. type SecureScoresClientListOptions struct { // placeholder for future optional parameters } @@ -6815,7 +7254,7 @@ type SettingsClientGetOptions struct { // placeholder for future optional parameters } -// SettingsClientListOptions contains the optional parameters for the SettingsClient.List method. +// SettingsClientListOptions contains the optional parameters for the SettingsClient.NewListPager method. type SettingsClientListOptions struct { // placeholder for future optional parameters } @@ -6854,13 +7293,13 @@ type SoftwareInventoriesClientGetOptions struct { // placeholder for future optional parameters } -// SoftwareInventoriesClientListByExtendedResourceOptions contains the optional parameters for the SoftwareInventoriesClient.ListByExtendedResource +// SoftwareInventoriesClientListByExtendedResourceOptions contains the optional parameters for the SoftwareInventoriesClient.NewListByExtendedResourcePager // method. type SoftwareInventoriesClientListByExtendedResourceOptions struct { // placeholder for future optional parameters } -// SoftwareInventoriesClientListBySubscriptionOptions contains the optional parameters for the SoftwareInventoriesClient.ListBySubscription +// SoftwareInventoriesClientListBySubscriptionOptions contains the optional parameters for the SoftwareInventoriesClient.NewListBySubscriptionPager // method. type SoftwareInventoriesClientListBySubscriptionOptions struct { // placeholder for future optional parameters @@ -6946,7 +7385,7 @@ type SolutionsClientGetOptions struct { // placeholder for future optional parameters } -// SolutionsClientListOptions contains the optional parameters for the SolutionsClient.List method. +// SolutionsClientListOptions contains the optional parameters for the SolutionsClient.NewListPager method. type SolutionsClientListOptions struct { // placeholder for future optional parameters } @@ -7006,6 +7445,18 @@ type SolutionsReferenceDataProperties struct { Template *string `json:"template,omitempty"` } +// StatusAutoGenerated - The status of the health report +type StatusAutoGenerated struct { + // The status of the health report + Code *StatusName `json:"code,omitempty"` + + // READ-ONLY; The date of when the resource of the health report was scanned in the first time + FirstEvaluationDate *time.Time `json:"firstEvaluationDate,omitempty" azure:"ro"` + + // READ-ONLY; The date of when the status of the health report was changed in the last time + StatusChangeDate *time.Time `json:"statusChangeDate,omitempty" azure:"ro"` +} + // SubAssessment - Security sub-assessment on a resource type SubAssessment struct { // Describes properties of an sub-assessment. @@ -7083,23 +7534,16 @@ type SubAssessmentsClientGetOptions struct { // placeholder for future optional parameters } -// SubAssessmentsClientListAllOptions contains the optional parameters for the SubAssessmentsClient.ListAll method. +// SubAssessmentsClientListAllOptions contains the optional parameters for the SubAssessmentsClient.NewListAllPager method. type SubAssessmentsClientListAllOptions struct { // placeholder for future optional parameters } -// SubAssessmentsClientListOptions contains the optional parameters for the SubAssessmentsClient.List method. +// SubAssessmentsClientListOptions contains the optional parameters for the SubAssessmentsClient.NewListPager method. type SubAssessmentsClientListOptions struct { // placeholder for future optional parameters } -// SubscriptionGovernanceRulesExecuteStatusClientBeginGetOptions contains the optional parameters for the SubscriptionGovernanceRulesExecuteStatusClient.BeginGet -// method. -type SubscriptionGovernanceRulesExecuteStatusClientBeginGetOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - type SuppressionAlertsScope struct { // REQUIRED; All the conditions inside need to be true in order to suppress the alert AllOf []*ScopeElement `json:"allOf,omitempty"` @@ -7165,7 +7609,7 @@ type TaskList struct { // TaskParameters - Changing set of properties, depending on the task type that is derived from the name field type TaskParameters struct { // OPTIONAL; Contains additional key/value pairs not defined in the schema. - AdditionalProperties map[string]interface{} + AdditionalProperties map[string]any // READ-ONLY; Name of the task type Name *string `json:"name,omitempty" azure:"ro"` @@ -7201,19 +7645,20 @@ type TasksClientGetSubscriptionLevelTaskOptions struct { // placeholder for future optional parameters } -// TasksClientListByHomeRegionOptions contains the optional parameters for the TasksClient.ListByHomeRegion method. +// TasksClientListByHomeRegionOptions contains the optional parameters for the TasksClient.NewListByHomeRegionPager method. type TasksClientListByHomeRegionOptions struct { // OData filter. Optional. Filter *string } -// TasksClientListByResourceGroupOptions contains the optional parameters for the TasksClient.ListByResourceGroup method. +// TasksClientListByResourceGroupOptions contains the optional parameters for the TasksClient.NewListByResourceGroupPager +// method. type TasksClientListByResourceGroupOptions struct { // OData filter. Optional. Filter *string } -// TasksClientListOptions contains the optional parameters for the TasksClient.List method. +// TasksClientListOptions contains the optional parameters for the TasksClient.NewListPager method. type TasksClientListOptions struct { // OData filter. Optional. Filter *string @@ -7351,12 +7796,13 @@ type TopologyClientGetOptions struct { // placeholder for future optional parameters } -// TopologyClientListByHomeRegionOptions contains the optional parameters for the TopologyClient.ListByHomeRegion method. +// TopologyClientListByHomeRegionOptions contains the optional parameters for the TopologyClient.NewListByHomeRegionPager +// method. type TopologyClientListByHomeRegionOptions struct { // placeholder for future optional parameters } -// TopologyClientListOptions contains the optional parameters for the TopologyClient.List method. +// TopologyClientListOptions contains the optional parameters for the TopologyClient.NewListPager method. type TopologyClientListOptions struct { // placeholder for future optional parameters } @@ -7711,7 +8157,7 @@ type WorkspaceSettingsClientGetOptions struct { // placeholder for future optional parameters } -// WorkspaceSettingsClientListOptions contains the optional parameters for the WorkspaceSettingsClient.List method. +// WorkspaceSettingsClientListOptions contains the optional parameters for the WorkspaceSettingsClient.NewListPager method. type WorkspaceSettingsClientListOptions struct { // placeholder for future optional parameters } diff --git a/sdk/resourcemanager/security/armsecurity/models_serde.go b/sdk/resourcemanager/security/armsecurity/models_serde.go index 7712659e0a20..22248fc3c316 100644 --- a/sdk/resourcemanager/security/armsecurity/models_serde.go +++ b/sdk/resourcemanager/security/armsecurity/models_serde.go @@ -20,7 +20,7 @@ import ( // MarshalJSON implements the json.Marshaller interface for type AADConnectivityStateAutoGenerated. func (a AADConnectivityStateAutoGenerated) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "connectivityState", a.ConnectivityState) return json.Marshal(objectMap) } @@ -47,7 +47,7 @@ func (a *AADConnectivityStateAutoGenerated) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AADExternalSecuritySolution. func (a AADExternalSecuritySolution) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", a.ID) populate(objectMap, "kind", a.Kind) populate(objectMap, "location", a.Location) @@ -94,7 +94,7 @@ func (a *AADExternalSecuritySolution) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AADSolutionProperties. func (a AADSolutionProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "connectivityState", a.ConnectivityState) populate(objectMap, "deviceType", a.DeviceType) populate(objectMap, "deviceVendor", a.DeviceVendor) @@ -130,10 +130,10 @@ func (a *AADSolutionProperties) UnmarshalJSON(data []byte) error { delete(rawMsg, key) default: if a.AdditionalProperties == nil { - a.AdditionalProperties = map[string]interface{}{} + a.AdditionalProperties = map[string]any{} } if val != nil { - var aux interface{} + var aux any err = json.Unmarshal(val, &aux) a.AdditionalProperties[key] = aux } @@ -146,9 +146,110 @@ func (a *AADSolutionProperties) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type APICollectionProperties. +func (a APICollectionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "additionalData", a.AdditionalData) + populate(objectMap, "displayName", a.DisplayName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type APICollectionProperties. +func (a *APICollectionProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "additionalData": + err = unpopulate(val, "AdditionalData", &a.AdditionalData) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &a.DisplayName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type APICollectionResponse. +func (a APICollectionResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", a.ID) + populate(objectMap, "name", a.Name) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "type", a.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type APICollectionResponse. +func (a *APICollectionResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &a.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &a.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type APICollectionResponseList. +func (a APICollectionResponseList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", a.NextLink) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type APICollectionResponseList. +func (a *APICollectionResponseList) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &a.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &a.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type ActiveConnectionsNotInAllowedRange. func (a ActiveConnectionsNotInAllowedRange) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "description", a.Description) populate(objectMap, "displayName", a.DisplayName) populate(objectMap, "isEnabled", a.IsEnabled) @@ -199,7 +300,7 @@ func (a *ActiveConnectionsNotInAllowedRange) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AdaptiveApplicationControlGroup. func (a AdaptiveApplicationControlGroup) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", a.ID) populate(objectMap, "location", a.Location) populate(objectMap, "name", a.Name) @@ -242,7 +343,7 @@ func (a *AdaptiveApplicationControlGroup) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AdaptiveApplicationControlGroupData. func (a AdaptiveApplicationControlGroupData) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "configurationStatus", a.ConfigurationStatus) populate(objectMap, "enforcementMode", a.EnforcementMode) populate(objectMap, "issues", a.Issues) @@ -297,7 +398,7 @@ func (a *AdaptiveApplicationControlGroupData) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AdaptiveApplicationControlGroups. func (a AdaptiveApplicationControlGroups) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "value", a.Value) return json.Marshal(objectMap) } @@ -324,7 +425,7 @@ func (a *AdaptiveApplicationControlGroups) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AdaptiveApplicationControlIssueSummary. func (a AdaptiveApplicationControlIssueSummary) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "issue", a.Issue) populate(objectMap, "numberOfVms", a.NumberOfVMs) return json.Marshal(objectMap) @@ -355,7 +456,7 @@ func (a *AdaptiveApplicationControlIssueSummary) UnmarshalJSON(data []byte) erro // MarshalJSON implements the json.Marshaller interface for type AdaptiveNetworkHardening. func (a AdaptiveNetworkHardening) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", a.ID) populate(objectMap, "name", a.Name) populate(objectMap, "properties", a.Properties) @@ -394,7 +495,7 @@ func (a *AdaptiveNetworkHardening) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AdaptiveNetworkHardeningEnforceRequest. func (a AdaptiveNetworkHardeningEnforceRequest) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "networkSecurityGroups", a.NetworkSecurityGroups) populate(objectMap, "rules", a.Rules) return json.Marshal(objectMap) @@ -425,7 +526,7 @@ func (a *AdaptiveNetworkHardeningEnforceRequest) UnmarshalJSON(data []byte) erro // MarshalJSON implements the json.Marshaller interface for type AdaptiveNetworkHardeningProperties. func (a AdaptiveNetworkHardeningProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "effectiveNetworkSecurityGroups", a.EffectiveNetworkSecurityGroups) populate(objectMap, "rules", a.Rules) populateTimeRFC3339(objectMap, "rulesCalculationTime", a.RulesCalculationTime) @@ -460,7 +561,7 @@ func (a *AdaptiveNetworkHardeningProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AdaptiveNetworkHardeningsList. func (a AdaptiveNetworkHardeningsList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", a.NextLink) populate(objectMap, "value", a.Value) return json.Marshal(objectMap) @@ -491,7 +592,7 @@ func (a *AdaptiveNetworkHardeningsList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AdditionalData. func (a AdditionalData) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["assessedResourceType"] = a.AssessedResourceType return json.Marshal(objectMap) } @@ -518,7 +619,7 @@ func (a *AdditionalData) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AdditionalWorkspacesProperties. func (a AdditionalWorkspacesProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "dataTypes", a.DataTypes) populate(objectMap, "type", a.Type) populate(objectMap, "workspace", a.Workspace) @@ -553,7 +654,7 @@ func (a *AdditionalWorkspacesProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AdvancedThreatProtectionProperties. func (a AdvancedThreatProtectionProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "isEnabled", a.IsEnabled) return json.Marshal(objectMap) } @@ -580,7 +681,7 @@ func (a *AdvancedThreatProtectionProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AdvancedThreatProtectionSetting. func (a AdvancedThreatProtectionSetting) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", a.ID) populate(objectMap, "name", a.Name) populate(objectMap, "properties", a.Properties) @@ -619,7 +720,7 @@ func (a *AdvancedThreatProtectionSetting) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Alert. func (a Alert) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", a.ID) populate(objectMap, "name", a.Name) populate(objectMap, "properties", a.Properties) @@ -658,7 +759,7 @@ func (a *Alert) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AlertEntity. func (a AlertEntity) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "type", a.Type) if a.AdditionalProperties != nil { for key, val := range a.AdditionalProperties { @@ -682,10 +783,10 @@ func (a *AlertEntity) UnmarshalJSON(data []byte) error { delete(rawMsg, key) default: if a.AdditionalProperties == nil { - a.AdditionalProperties = map[string]interface{}{} + a.AdditionalProperties = map[string]any{} } if val != nil { - var aux interface{} + var aux any err = json.Unmarshal(val, &aux) a.AdditionalProperties[key] = aux } @@ -700,7 +801,7 @@ func (a *AlertEntity) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AlertList. func (a AlertList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", a.NextLink) populate(objectMap, "value", a.Value) return json.Marshal(objectMap) @@ -731,7 +832,7 @@ func (a *AlertList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AlertProperties. func (a AlertProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "alertDisplayName", a.AlertDisplayName) populate(objectMap, "alertType", a.AlertType) populate(objectMap, "alertUri", a.AlertURI) @@ -862,7 +963,7 @@ func (a *AlertProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AlertPropertiesSupportingEvidence. func (a AlertPropertiesSupportingEvidence) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "type", a.Type) if a.AdditionalProperties != nil { for key, val := range a.AdditionalProperties { @@ -886,10 +987,10 @@ func (a *AlertPropertiesSupportingEvidence) UnmarshalJSON(data []byte) error { delete(rawMsg, key) default: if a.AdditionalProperties == nil { - a.AdditionalProperties = map[string]interface{}{} + a.AdditionalProperties = map[string]any{} } if val != nil { - var aux interface{} + var aux any err = json.Unmarshal(val, &aux) a.AdditionalProperties[key] = aux } @@ -904,7 +1005,7 @@ func (a *AlertPropertiesSupportingEvidence) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AlertSimulatorBundlesRequestProperties. func (a AlertSimulatorBundlesRequestProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "bundles", a.Bundles) objectMap["kind"] = KindBundles if a.AdditionalProperties != nil { @@ -932,10 +1033,10 @@ func (a *AlertSimulatorBundlesRequestProperties) UnmarshalJSON(data []byte) erro delete(rawMsg, key) default: if a.AdditionalProperties == nil { - a.AdditionalProperties = map[string]interface{}{} + a.AdditionalProperties = map[string]any{} } if val != nil { - var aux interface{} + var aux any err = json.Unmarshal(val, &aux) a.AdditionalProperties[key] = aux } @@ -950,7 +1051,7 @@ func (a *AlertSimulatorBundlesRequestProperties) UnmarshalJSON(data []byte) erro // MarshalJSON implements the json.Marshaller interface for type AlertSimulatorRequestBody. func (a AlertSimulatorRequestBody) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "properties", a.Properties) return json.Marshal(objectMap) } @@ -977,7 +1078,7 @@ func (a *AlertSimulatorRequestBody) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AlertSimulatorRequestProperties. func (a AlertSimulatorRequestProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["kind"] = a.Kind if a.AdditionalProperties != nil { for key, val := range a.AdditionalProperties { @@ -1001,10 +1102,10 @@ func (a *AlertSimulatorRequestProperties) UnmarshalJSON(data []byte) error { delete(rawMsg, key) default: if a.AdditionalProperties == nil { - a.AdditionalProperties = map[string]interface{}{} + a.AdditionalProperties = map[string]any{} } if val != nil { - var aux interface{} + var aux any err = json.Unmarshal(val, &aux) a.AdditionalProperties[key] = aux } @@ -1019,7 +1120,7 @@ func (a *AlertSimulatorRequestProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AlertSyncSettingProperties. func (a AlertSyncSettingProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "enabled", a.Enabled) return json.Marshal(objectMap) } @@ -1046,7 +1147,7 @@ func (a *AlertSyncSettingProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AlertSyncSettings. func (a AlertSyncSettings) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", a.ID) objectMap["kind"] = SettingKindAlertSyncSettings populate(objectMap, "name", a.Name) @@ -1089,7 +1190,7 @@ func (a *AlertSyncSettings) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AlertsSuppressionRule. func (a AlertsSuppressionRule) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", a.ID) populate(objectMap, "name", a.Name) populate(objectMap, "properties", a.Properties) @@ -1128,7 +1229,7 @@ func (a *AlertsSuppressionRule) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AlertsSuppressionRuleProperties. func (a AlertsSuppressionRuleProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "alertType", a.AlertType) populate(objectMap, "comment", a.Comment) populateTimeRFC3339(objectMap, "expirationDateUtc", a.ExpirationDateUTC) @@ -1179,7 +1280,7 @@ func (a *AlertsSuppressionRuleProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AlertsSuppressionRulesList. func (a AlertsSuppressionRulesList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", a.NextLink) populate(objectMap, "value", a.Value) return json.Marshal(objectMap) @@ -1210,7 +1311,7 @@ func (a *AlertsSuppressionRulesList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AllowedConnectionsList. func (a AllowedConnectionsList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", a.NextLink) populate(objectMap, "value", a.Value) return json.Marshal(objectMap) @@ -1241,7 +1342,7 @@ func (a *AllowedConnectionsList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AllowedConnectionsResource. func (a AllowedConnectionsResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", a.ID) populate(objectMap, "location", a.Location) populate(objectMap, "name", a.Name) @@ -1284,7 +1385,7 @@ func (a *AllowedConnectionsResource) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AllowedConnectionsResourceProperties. func (a AllowedConnectionsResourceProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populateTimeRFC3339(objectMap, "calculatedDateTime", a.CalculatedDateTime) populate(objectMap, "connectableResources", a.ConnectableResources) return json.Marshal(objectMap) @@ -1315,7 +1416,7 @@ func (a *AllowedConnectionsResourceProperties) UnmarshalJSON(data []byte) error // MarshalJSON implements the json.Marshaller interface for type AllowlistCustomAlertRule. func (a AllowlistCustomAlertRule) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "allowlistValues", a.AllowlistValues) populate(objectMap, "description", a.Description) populate(objectMap, "displayName", a.DisplayName) @@ -1362,7 +1463,7 @@ func (a *AllowlistCustomAlertRule) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AmqpC2DMessagesNotInAllowedRange. func (a AmqpC2DMessagesNotInAllowedRange) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "description", a.Description) populate(objectMap, "displayName", a.DisplayName) populate(objectMap, "isEnabled", a.IsEnabled) @@ -1413,7 +1514,7 @@ func (a *AmqpC2DMessagesNotInAllowedRange) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AmqpC2DRejectedMessagesNotInAllowedRange. func (a AmqpC2DRejectedMessagesNotInAllowedRange) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "description", a.Description) populate(objectMap, "displayName", a.DisplayName) populate(objectMap, "isEnabled", a.IsEnabled) @@ -1464,7 +1565,7 @@ func (a *AmqpC2DRejectedMessagesNotInAllowedRange) UnmarshalJSON(data []byte) er // MarshalJSON implements the json.Marshaller interface for type AmqpD2CMessagesNotInAllowedRange. func (a AmqpD2CMessagesNotInAllowedRange) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "description", a.Description) populate(objectMap, "displayName", a.DisplayName) populate(objectMap, "isEnabled", a.IsEnabled) @@ -1515,7 +1616,7 @@ func (a *AmqpD2CMessagesNotInAllowedRange) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Application. func (a Application) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", a.ID) populate(objectMap, "name", a.Name) populate(objectMap, "properties", a.Properties) @@ -1554,7 +1655,7 @@ func (a *Application) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ApplicationCondition. func (a ApplicationCondition) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "operator", a.Operator) populate(objectMap, "property", a.Property) populate(objectMap, "value", a.Value) @@ -1589,7 +1690,7 @@ func (a *ApplicationCondition) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ApplicationProperties. func (a ApplicationProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "conditionSets", a.ConditionSets) populate(objectMap, "description", a.Description) populate(objectMap, "displayName", a.DisplayName) @@ -1628,7 +1729,7 @@ func (a *ApplicationProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ApplicationsList. func (a ApplicationsList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", a.NextLink) populate(objectMap, "value", a.Value) return json.Marshal(objectMap) @@ -1659,7 +1760,7 @@ func (a *ApplicationsList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AscLocation. func (a AscLocation) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", a.ID) populate(objectMap, "name", a.Name) populate(objectMap, "properties", &a.Properties) @@ -1698,7 +1799,7 @@ func (a *AscLocation) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AscLocationList. func (a AscLocationList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", a.NextLink) populate(objectMap, "value", a.Value) return json.Marshal(objectMap) @@ -1729,7 +1830,7 @@ func (a *AscLocationList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Assessment. func (a Assessment) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", a.ID) populate(objectMap, "name", a.Name) populate(objectMap, "properties", a.Properties) @@ -1768,7 +1869,7 @@ func (a *Assessment) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AssessmentLinks. func (a AssessmentLinks) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "azurePortalUri", a.AzurePortalURI) return json.Marshal(objectMap) } @@ -1795,7 +1896,7 @@ func (a *AssessmentLinks) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AssessmentList. func (a AssessmentList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", a.NextLink) populate(objectMap, "value", a.Value) return json.Marshal(objectMap) @@ -1826,7 +1927,7 @@ func (a *AssessmentList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AssessmentMetadata. func (a AssessmentMetadata) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", a.ID) populate(objectMap, "name", a.Name) populate(objectMap, "properties", a.Properties) @@ -1865,7 +1966,7 @@ func (a *AssessmentMetadata) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AssessmentMetadataPartnerData. func (a AssessmentMetadataPartnerData) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "partnerName", a.PartnerName) populate(objectMap, "productName", a.ProductName) populate(objectMap, "secret", a.Secret) @@ -1900,7 +2001,7 @@ func (a *AssessmentMetadataPartnerData) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AssessmentMetadataProperties. func (a AssessmentMetadataProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "assessmentType", a.AssessmentType) populate(objectMap, "categories", a.Categories) populate(objectMap, "description", a.Description) @@ -1971,7 +2072,7 @@ func (a *AssessmentMetadataProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AssessmentMetadataPropertiesResponse. func (a AssessmentMetadataPropertiesResponse) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "assessmentType", a.AssessmentType) populate(objectMap, "categories", a.Categories) populate(objectMap, "description", a.Description) @@ -2058,7 +2159,7 @@ func (a *AssessmentMetadataPropertiesResponse) UnmarshalJSON(data []byte) error // MarshalJSON implements the json.Marshaller interface for type AssessmentMetadataPropertiesResponsePublishDates. func (a AssessmentMetadataPropertiesResponsePublishDates) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "GA", a.GA) populate(objectMap, "public", a.Public) return json.Marshal(objectMap) @@ -2089,7 +2190,7 @@ func (a *AssessmentMetadataPropertiesResponsePublishDates) UnmarshalJSON(data [] // MarshalJSON implements the json.Marshaller interface for type AssessmentMetadataResponse. func (a AssessmentMetadataResponse) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", a.ID) populate(objectMap, "name", a.Name) populate(objectMap, "properties", a.Properties) @@ -2128,7 +2229,7 @@ func (a *AssessmentMetadataResponse) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AssessmentMetadataResponseList. func (a AssessmentMetadataResponseList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", a.NextLink) populate(objectMap, "value", a.Value) return json.Marshal(objectMap) @@ -2159,7 +2260,7 @@ func (a *AssessmentMetadataResponseList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AssessmentPartnerData. func (a AssessmentPartnerData) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "partnerName", a.PartnerName) populate(objectMap, "secret", a.Secret) return json.Marshal(objectMap) @@ -2190,7 +2291,7 @@ func (a *AssessmentPartnerData) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AssessmentProperties. func (a AssessmentProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "additionalData", a.AdditionalData) populate(objectMap, "displayName", a.DisplayName) populate(objectMap, "links", a.Links) @@ -2241,7 +2342,7 @@ func (a *AssessmentProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AssessmentPropertiesBase. func (a AssessmentPropertiesBase) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "additionalData", a.AdditionalData) populate(objectMap, "displayName", a.DisplayName) populate(objectMap, "links", a.Links) @@ -2288,7 +2389,7 @@ func (a *AssessmentPropertiesBase) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AssessmentPropertiesResponse. func (a AssessmentPropertiesResponse) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "additionalData", a.AdditionalData) populate(objectMap, "displayName", a.DisplayName) populate(objectMap, "links", a.Links) @@ -2339,7 +2440,7 @@ func (a *AssessmentPropertiesResponse) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AssessmentResponse. func (a AssessmentResponse) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", a.ID) populate(objectMap, "name", a.Name) populate(objectMap, "properties", a.Properties) @@ -2378,7 +2479,7 @@ func (a *AssessmentResponse) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AssessmentStatus. func (a AssessmentStatus) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "cause", a.Cause) populate(objectMap, "code", a.Code) populate(objectMap, "description", a.Description) @@ -2413,7 +2514,7 @@ func (a *AssessmentStatus) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AssessmentStatusResponse. func (a AssessmentStatusResponse) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "cause", a.Cause) populate(objectMap, "code", a.Code) populate(objectMap, "description", a.Description) @@ -2456,7 +2557,7 @@ func (a *AssessmentStatusResponse) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AtaExternalSecuritySolution. func (a AtaExternalSecuritySolution) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", a.ID) populate(objectMap, "kind", a.Kind) populate(objectMap, "location", a.Location) @@ -2503,7 +2604,7 @@ func (a *AtaExternalSecuritySolution) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AtaSolutionProperties. func (a AtaSolutionProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "deviceType", a.DeviceType) populate(objectMap, "deviceVendor", a.DeviceVendor) populate(objectMap, "lastEventReceived", a.LastEventReceived) @@ -2539,10 +2640,10 @@ func (a *AtaSolutionProperties) UnmarshalJSON(data []byte) error { delete(rawMsg, key) default: if a.AdditionalProperties == nil { - a.AdditionalProperties = map[string]interface{}{} + a.AdditionalProperties = map[string]any{} } if val != nil { - var aux interface{} + var aux any err = json.Unmarshal(val, &aux) a.AdditionalProperties[key] = aux } @@ -2557,7 +2658,7 @@ func (a *AtaSolutionProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AuthenticationDetailsProperties. func (a AuthenticationDetailsProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "authenticationProvisioningState", a.AuthenticationProvisioningState) objectMap["authenticationType"] = a.AuthenticationType populate(objectMap, "grantedPermissions", a.GrantedPermissions) @@ -2592,7 +2693,7 @@ func (a *AuthenticationDetailsProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AutoProvisioningSetting. func (a AutoProvisioningSetting) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", a.ID) populate(objectMap, "name", a.Name) populate(objectMap, "properties", a.Properties) @@ -2631,7 +2732,7 @@ func (a *AutoProvisioningSetting) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AutoProvisioningSettingList. func (a AutoProvisioningSettingList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", a.NextLink) populate(objectMap, "value", a.Value) return json.Marshal(objectMap) @@ -2662,7 +2763,7 @@ func (a *AutoProvisioningSettingList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AutoProvisioningSettingProperties. func (a AutoProvisioningSettingProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "autoProvision", a.AutoProvision) return json.Marshal(objectMap) } @@ -2689,7 +2790,7 @@ func (a *AutoProvisioningSettingProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Automation. func (a Automation) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "etag", a.Etag) populate(objectMap, "id", a.ID) populate(objectMap, "kind", a.Kind) @@ -2744,7 +2845,7 @@ func (a *Automation) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AutomationAction. func (a AutomationAction) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["actionType"] = a.ActionType return json.Marshal(objectMap) } @@ -2771,7 +2872,7 @@ func (a *AutomationAction) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AutomationActionEventHub. func (a AutomationActionEventHub) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["actionType"] = ActionTypeEventHub populate(objectMap, "connectionString", a.ConnectionString) populate(objectMap, "eventHubResourceId", a.EventHubResourceID) @@ -2810,7 +2911,7 @@ func (a *AutomationActionEventHub) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AutomationActionLogicApp. func (a AutomationActionLogicApp) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["actionType"] = ActionTypeLogicApp populate(objectMap, "logicAppResourceId", a.LogicAppResourceID) populate(objectMap, "uri", a.URI) @@ -2845,7 +2946,7 @@ func (a *AutomationActionLogicApp) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AutomationActionWorkspace. func (a AutomationActionWorkspace) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["actionType"] = ActionTypeWorkspace populate(objectMap, "workspaceResourceId", a.WorkspaceResourceID) return json.Marshal(objectMap) @@ -2876,7 +2977,7 @@ func (a *AutomationActionWorkspace) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AutomationList. func (a AutomationList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", a.NextLink) populate(objectMap, "value", a.Value) return json.Marshal(objectMap) @@ -2907,7 +3008,7 @@ func (a *AutomationList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AutomationProperties. func (a AutomationProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "actions", a.Actions) populate(objectMap, "description", a.Description) populate(objectMap, "isEnabled", a.IsEnabled) @@ -2950,7 +3051,7 @@ func (a *AutomationProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AutomationRuleSet. func (a AutomationRuleSet) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "rules", a.Rules) return json.Marshal(objectMap) } @@ -2977,7 +3078,7 @@ func (a *AutomationRuleSet) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AutomationScope. func (a AutomationScope) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "description", a.Description) populate(objectMap, "scopePath", a.ScopePath) return json.Marshal(objectMap) @@ -3008,7 +3109,7 @@ func (a *AutomationScope) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AutomationSource. func (a AutomationSource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "eventSource", a.EventSource) populate(objectMap, "ruleSets", a.RuleSets) return json.Marshal(objectMap) @@ -3039,7 +3140,7 @@ func (a *AutomationSource) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AutomationTriggeringRule. func (a AutomationTriggeringRule) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "expectedValue", a.ExpectedValue) populate(objectMap, "operator", a.Operator) populate(objectMap, "propertyJPath", a.PropertyJPath) @@ -3078,7 +3179,7 @@ func (a *AutomationTriggeringRule) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AutomationValidationStatus. func (a AutomationValidationStatus) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "isValid", a.IsValid) populate(objectMap, "message", a.Message) return json.Marshal(objectMap) @@ -3109,7 +3210,7 @@ func (a *AutomationValidationStatus) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AwAssumeRoleAuthenticationDetailsProperties. func (a AwAssumeRoleAuthenticationDetailsProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "accountId", a.AccountID) populate(objectMap, "authenticationProvisioningState", a.AuthenticationProvisioningState) objectMap["authenticationType"] = AuthenticationTypeAwsAssumeRole @@ -3156,7 +3257,7 @@ func (a *AwAssumeRoleAuthenticationDetailsProperties) UnmarshalJSON(data []byte) // MarshalJSON implements the json.Marshaller interface for type AwsCredsAuthenticationDetailsProperties. func (a AwsCredsAuthenticationDetailsProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "accountId", a.AccountID) populate(objectMap, "authenticationProvisioningState", a.AuthenticationProvisioningState) objectMap["authenticationType"] = AuthenticationTypeAwsCreds @@ -3203,9 +3304,11 @@ func (a *AwsCredsAuthenticationDetailsProperties) UnmarshalJSON(data []byte) err // MarshalJSON implements the json.Marshaller interface for type AwsEnvironmentData. func (a AwsEnvironmentData) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) + populate(objectMap, "accountName", a.AccountName) objectMap["environmentType"] = EnvironmentTypeAwsAccount populate(objectMap, "organizationalData", a.OrganizationalData) + populate(objectMap, "regions", a.Regions) return json.Marshal(objectMap) } @@ -3218,12 +3321,18 @@ func (a *AwsEnvironmentData) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "accountName": + err = unpopulate(val, "AccountName", &a.AccountName) + delete(rawMsg, key) case "environmentType": err = unpopulate(val, "EnvironmentType", &a.EnvironmentType) delete(rawMsg, key) case "organizationalData": a.OrganizationalData, err = unmarshalAwsOrganizationalDataClassification(val) delete(rawMsg, key) + case "regions": + err = unpopulate(val, "Regions", &a.Regions) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", a, err) @@ -3234,7 +3343,7 @@ func (a *AwsEnvironmentData) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AwsOrganizationalData. func (a AwsOrganizationalData) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["organizationMembershipType"] = a.OrganizationMembershipType return json.Marshal(objectMap) } @@ -3261,7 +3370,7 @@ func (a *AwsOrganizationalData) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AwsOrganizationalDataMaster. func (a AwsOrganizationalDataMaster) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "excludedAccountIds", a.ExcludedAccountIDs) objectMap["organizationMembershipType"] = OrganizationMembershipTypeOrganization populate(objectMap, "stacksetName", a.StacksetName) @@ -3296,7 +3405,7 @@ func (a *AwsOrganizationalDataMaster) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AwsOrganizationalDataMember. func (a AwsOrganizationalDataMember) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["organizationMembershipType"] = OrganizationMembershipTypeMember populate(objectMap, "parentHierarchyId", a.ParentHierarchyID) return json.Marshal(objectMap) @@ -3327,7 +3436,7 @@ func (a *AwsOrganizationalDataMember) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AzureDevOpsScopeEnvironmentData. func (a AzureDevOpsScopeEnvironmentData) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["environmentType"] = EnvironmentTypeAzureDevOpsScope return json.Marshal(objectMap) } @@ -3354,7 +3463,7 @@ func (a *AzureDevOpsScopeEnvironmentData) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AzureResourceDetails. func (a AzureResourceDetails) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", a.ID) objectMap["source"] = SourceAzure return json.Marshal(objectMap) @@ -3385,7 +3494,7 @@ func (a *AzureResourceDetails) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AzureResourceIdentifier. func (a AzureResourceIdentifier) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "azureResourceId", a.AzureResourceID) objectMap["type"] = ResourceIdentifierTypeAzureResource return json.Marshal(objectMap) @@ -3416,7 +3525,7 @@ func (a *AzureResourceIdentifier) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AzureResourceLink. func (a AzureResourceLink) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", a.ID) return json.Marshal(objectMap) } @@ -3443,7 +3552,7 @@ func (a *AzureResourceLink) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AzureTrackedResourceLocation. func (a AzureTrackedResourceLocation) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "location", a.Location) return json.Marshal(objectMap) } @@ -3470,7 +3579,7 @@ func (a *AzureTrackedResourceLocation) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Baseline. func (b Baseline) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "expectedResults", b.ExpectedResults) populateTimeRFC3339(objectMap, "updatedTime", b.UpdatedTime) return json.Marshal(objectMap) @@ -3501,7 +3610,7 @@ func (b *Baseline) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type BaselineAdjustedResult. func (b BaselineAdjustedResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "baseline", b.Baseline) populate(objectMap, "resultsNotInBaseline", b.ResultsNotInBaseline) populate(objectMap, "resultsOnlyInBaseline", b.ResultsOnlyInBaseline) @@ -3540,7 +3649,7 @@ func (b *BaselineAdjustedResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type BenchmarkReference. func (b BenchmarkReference) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "benchmark", b.Benchmark) populate(objectMap, "reference", b.Reference) return json.Marshal(objectMap) @@ -3571,7 +3680,7 @@ func (b *BenchmarkReference) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type CVE. func (c CVE) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "link", c.Link) populate(objectMap, "title", c.Title) return json.Marshal(objectMap) @@ -3602,7 +3711,7 @@ func (c *CVE) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type CVSS. func (c CVSS) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "base", c.Base) return json.Marshal(objectMap) } @@ -3629,7 +3738,7 @@ func (c *CVSS) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type CefExternalSecuritySolution. func (c CefExternalSecuritySolution) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", c.ID) populate(objectMap, "kind", c.Kind) populate(objectMap, "location", c.Location) @@ -3676,7 +3785,7 @@ func (c *CefExternalSecuritySolution) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type CefSolutionProperties. func (c CefSolutionProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "agent", c.Agent) populate(objectMap, "deviceType", c.DeviceType) populate(objectMap, "deviceVendor", c.DeviceVendor) @@ -3720,10 +3829,10 @@ func (c *CefSolutionProperties) UnmarshalJSON(data []byte) error { delete(rawMsg, key) default: if c.AdditionalProperties == nil { - c.AdditionalProperties = map[string]interface{}{} + c.AdditionalProperties = map[string]any{} } if val != nil { - var aux interface{} + var aux any err = json.Unmarshal(val, &aux) c.AdditionalProperties[key] = aux } @@ -3738,7 +3847,7 @@ func (c *CefSolutionProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type CloudOffering. func (c CloudOffering) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "description", c.Description) objectMap["offeringType"] = c.OfferingType return json.Marshal(objectMap) @@ -3769,7 +3878,7 @@ func (c *CloudOffering) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Compliance. func (c Compliance) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", c.ID) populate(objectMap, "name", c.Name) populate(objectMap, "properties", c.Properties) @@ -3808,7 +3917,7 @@ func (c *Compliance) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ComplianceList. func (c ComplianceList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", c.NextLink) populate(objectMap, "value", c.Value) return json.Marshal(objectMap) @@ -3839,7 +3948,7 @@ func (c *ComplianceList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ComplianceProperties. func (c ComplianceProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "assessmentResult", c.AssessmentResult) populateTimeRFC3339(objectMap, "assessmentTimestampUtcDate", c.AssessmentTimestampUTCDate) populate(objectMap, "resourceCount", c.ResourceCount) @@ -3874,7 +3983,7 @@ func (c *ComplianceProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ComplianceResult. func (c ComplianceResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", c.ID) populate(objectMap, "name", c.Name) populate(objectMap, "properties", c.Properties) @@ -3913,7 +4022,7 @@ func (c *ComplianceResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ComplianceResultList. func (c ComplianceResultList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", c.NextLink) populate(objectMap, "value", c.Value) return json.Marshal(objectMap) @@ -3944,7 +4053,7 @@ func (c *ComplianceResultList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ComplianceResultProperties. func (c ComplianceResultProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "resourceStatus", c.ResourceStatus) return json.Marshal(objectMap) } @@ -3971,7 +4080,7 @@ func (c *ComplianceResultProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ComplianceSegment. func (c ComplianceSegment) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "percentage", c.Percentage) populate(objectMap, "segmentType", c.SegmentType) return json.Marshal(objectMap) @@ -4002,7 +4111,7 @@ func (c *ComplianceSegment) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Condition. func (c Condition) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "operator", c.Operator) populate(objectMap, "property", c.Property) populate(objectMap, "value", c.Value) @@ -4037,7 +4146,7 @@ func (c *Condition) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ConnectableResource. func (c ConnectableResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", c.ID) populate(objectMap, "inboundConnectedResources", c.InboundConnectedResources) populate(objectMap, "outboundConnectedResources", c.OutboundConnectedResources) @@ -4072,7 +4181,7 @@ func (c *ConnectableResource) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ConnectedResource. func (c ConnectedResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "connectedResourceId", c.ConnectedResourceID) populate(objectMap, "tcpPorts", c.TCPPorts) populate(objectMap, "udpPorts", c.UDPPorts) @@ -4107,7 +4216,7 @@ func (c *ConnectedResource) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ConnectedWorkspace. func (c ConnectedWorkspace) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", c.ID) return json.Marshal(objectMap) } @@ -4134,7 +4243,7 @@ func (c *ConnectedWorkspace) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ConnectionFromIPNotAllowed. func (c ConnectionFromIPNotAllowed) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "allowlistValues", c.AllowlistValues) populate(objectMap, "description", c.Description) populate(objectMap, "displayName", c.DisplayName) @@ -4181,7 +4290,7 @@ func (c *ConnectionFromIPNotAllowed) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ConnectionStrings. func (c ConnectionStrings) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "value", c.Value) return json.Marshal(objectMap) } @@ -4208,7 +4317,7 @@ func (c *ConnectionStrings) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ConnectionToIPNotAllowed. func (c ConnectionToIPNotAllowed) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "allowlistValues", c.AllowlistValues) populate(objectMap, "description", c.Description) populate(objectMap, "displayName", c.DisplayName) @@ -4255,7 +4364,7 @@ func (c *ConnectionToIPNotAllowed) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Connector. func (c Connector) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "etag", c.Etag) populate(objectMap, "id", c.ID) populate(objectMap, "kind", c.Kind) @@ -4314,7 +4423,7 @@ func (c *Connector) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ConnectorProperties. func (c ConnectorProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "environmentData", c.EnvironmentData) populate(objectMap, "environmentName", c.EnvironmentName) populate(objectMap, "hierarchyIdentifier", c.HierarchyIdentifier) @@ -4357,7 +4466,7 @@ func (c *ConnectorProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ConnectorSetting. func (c ConnectorSetting) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", c.ID) populate(objectMap, "name", c.Name) populate(objectMap, "properties", c.Properties) @@ -4396,7 +4505,7 @@ func (c *ConnectorSetting) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ConnectorSettingList. func (c ConnectorSettingList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", c.NextLink) populate(objectMap, "value", c.Value) return json.Marshal(objectMap) @@ -4427,7 +4536,7 @@ func (c *ConnectorSettingList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ConnectorSettingProperties. func (c ConnectorSettingProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "authenticationDetails", c.AuthenticationDetails) populate(objectMap, "hybridComputeSettings", c.HybridComputeSettings) return json.Marshal(objectMap) @@ -4458,7 +4567,7 @@ func (c *ConnectorSettingProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ConnectorsList. func (c ConnectorsList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", c.NextLink) populate(objectMap, "value", c.Value) return json.Marshal(objectMap) @@ -4489,7 +4598,7 @@ func (c *ConnectorsList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Contact. func (c Contact) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", c.ID) populate(objectMap, "name", c.Name) populate(objectMap, "properties", c.Properties) @@ -4528,7 +4637,7 @@ func (c *Contact) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ContactList. func (c ContactList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", c.NextLink) populate(objectMap, "value", c.Value) return json.Marshal(objectMap) @@ -4559,7 +4668,7 @@ func (c *ContactList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ContactProperties. func (c ContactProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "alertNotifications", c.AlertNotifications) populate(objectMap, "emails", c.Emails) populate(objectMap, "notificationsByRole", c.NotificationsByRole) @@ -4598,7 +4707,7 @@ func (c *ContactProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ContactPropertiesAlertNotifications. func (c ContactPropertiesAlertNotifications) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "minimalSeverity", c.MinimalSeverity) populate(objectMap, "state", c.State) return json.Marshal(objectMap) @@ -4629,7 +4738,7 @@ func (c *ContactPropertiesAlertNotifications) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ContactPropertiesNotificationsByRole. func (c ContactPropertiesNotificationsByRole) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "roles", c.Roles) populate(objectMap, "state", c.State) return json.Marshal(objectMap) @@ -4660,7 +4769,7 @@ func (c *ContactPropertiesNotificationsByRole) UnmarshalJSON(data []byte) error // MarshalJSON implements the json.Marshaller interface for type ContainerRegistryVulnerabilityProperties. func (c ContainerRegistryVulnerabilityProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["assessedResourceType"] = AssessedResourceTypeContainerRegistryVulnerability populate(objectMap, "cve", c.Cve) populate(objectMap, "cvss", c.Cvss) @@ -4719,7 +4828,7 @@ func (c *ContainerRegistryVulnerabilityProperties) UnmarshalJSON(data []byte) er // MarshalJSON implements the json.Marshaller interface for type CspmMonitorAwsOffering. func (c CspmMonitorAwsOffering) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "description", c.Description) populate(objectMap, "nativeCloudConnection", c.NativeCloudConnection) objectMap["offeringType"] = OfferingTypeCspmMonitorAws @@ -4754,7 +4863,7 @@ func (c *CspmMonitorAwsOffering) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type CspmMonitorAwsOfferingNativeCloudConnection. func (c CspmMonitorAwsOfferingNativeCloudConnection) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "cloudRoleArn", c.CloudRoleArn) return json.Marshal(objectMap) } @@ -4781,7 +4890,7 @@ func (c *CspmMonitorAwsOfferingNativeCloudConnection) UnmarshalJSON(data []byte) // MarshalJSON implements the json.Marshaller interface for type CspmMonitorAzureDevOpsOffering. func (c CspmMonitorAzureDevOpsOffering) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "description", c.Description) objectMap["offeringType"] = OfferingTypeCspmMonitorAzureDevOps return json.Marshal(objectMap) @@ -4812,7 +4921,7 @@ func (c *CspmMonitorAzureDevOpsOffering) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type CspmMonitorGcpOffering. func (c CspmMonitorGcpOffering) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "description", c.Description) populate(objectMap, "nativeCloudConnection", c.NativeCloudConnection) objectMap["offeringType"] = OfferingTypeCspmMonitorGcp @@ -4847,7 +4956,7 @@ func (c *CspmMonitorGcpOffering) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type CspmMonitorGcpOfferingNativeCloudConnection. func (c CspmMonitorGcpOfferingNativeCloudConnection) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "serviceAccountEmailAddress", c.ServiceAccountEmailAddress) populate(objectMap, "workloadIdentityProviderId", c.WorkloadIdentityProviderID) return json.Marshal(objectMap) @@ -4876,9 +4985,40 @@ func (c *CspmMonitorGcpOfferingNativeCloudConnection) UnmarshalJSON(data []byte) return nil } +// MarshalJSON implements the json.Marshaller interface for type CspmMonitorGitLabOffering. +func (c CspmMonitorGitLabOffering) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", c.Description) + objectMap["offeringType"] = OfferingTypeCspmMonitorGitLab + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CspmMonitorGitLabOffering. +func (c *CspmMonitorGitLabOffering) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &c.Description) + delete(rawMsg, key) + case "offeringType": + err = unpopulate(val, "OfferingType", &c.OfferingType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type CspmMonitorGithubOffering. func (c CspmMonitorGithubOffering) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "description", c.Description) objectMap["offeringType"] = OfferingTypeCspmMonitorGithub return json.Marshal(objectMap) @@ -4909,7 +5049,7 @@ func (c *CspmMonitorGithubOffering) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type CustomAlertRule. func (c CustomAlertRule) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "description", c.Description) populate(objectMap, "displayName", c.DisplayName) populate(objectMap, "isEnabled", c.IsEnabled) @@ -4948,7 +5088,7 @@ func (c *CustomAlertRule) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type CustomAssessmentAutomation. func (c CustomAssessmentAutomation) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", c.ID) populate(objectMap, "name", c.Name) populate(objectMap, "properties", c.Properties) @@ -4991,7 +5131,7 @@ func (c *CustomAssessmentAutomation) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type CustomAssessmentAutomationProperties. func (c CustomAssessmentAutomationProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "assessmentKey", c.AssessmentKey) populate(objectMap, "compressedQuery", c.CompressedQuery) populate(objectMap, "description", c.Description) @@ -5048,7 +5188,7 @@ func (c *CustomAssessmentAutomationProperties) UnmarshalJSON(data []byte) error // MarshalJSON implements the json.Marshaller interface for type CustomAssessmentAutomationRequest. func (c CustomAssessmentAutomationRequest) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", c.ID) populate(objectMap, "name", c.Name) populate(objectMap, "properties", c.Properties) @@ -5087,7 +5227,7 @@ func (c *CustomAssessmentAutomationRequest) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type CustomAssessmentAutomationRequestProperties. func (c CustomAssessmentAutomationRequestProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "compressedQuery", c.CompressedQuery) populate(objectMap, "description", c.Description) populate(objectMap, "displayName", c.DisplayName) @@ -5140,7 +5280,7 @@ func (c *CustomAssessmentAutomationRequestProperties) UnmarshalJSON(data []byte) // MarshalJSON implements the json.Marshaller interface for type CustomAssessmentAutomationsListResult. func (c CustomAssessmentAutomationsListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", c.NextLink) populate(objectMap, "value", c.Value) return json.Marshal(objectMap) @@ -5171,7 +5311,7 @@ func (c *CustomAssessmentAutomationsListResult) UnmarshalJSON(data []byte) error // MarshalJSON implements the json.Marshaller interface for type CustomEntityStoreAssignment. func (c CustomEntityStoreAssignment) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", c.ID) populate(objectMap, "name", c.Name) populate(objectMap, "properties", c.Properties) @@ -5214,7 +5354,7 @@ func (c *CustomEntityStoreAssignment) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type CustomEntityStoreAssignmentProperties. func (c CustomEntityStoreAssignmentProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "entityStoreDatabaseLink", c.EntityStoreDatabaseLink) populate(objectMap, "principal", c.Principal) return json.Marshal(objectMap) @@ -5245,7 +5385,7 @@ func (c *CustomEntityStoreAssignmentProperties) UnmarshalJSON(data []byte) error // MarshalJSON implements the json.Marshaller interface for type CustomEntityStoreAssignmentRequest. func (c CustomEntityStoreAssignmentRequest) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "properties", c.Properties) return json.Marshal(objectMap) } @@ -5272,7 +5412,7 @@ func (c *CustomEntityStoreAssignmentRequest) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type CustomEntityStoreAssignmentRequestProperties. func (c CustomEntityStoreAssignmentRequestProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "principal", c.Principal) return json.Marshal(objectMap) } @@ -5299,7 +5439,7 @@ func (c *CustomEntityStoreAssignmentRequestProperties) UnmarshalJSON(data []byte // MarshalJSON implements the json.Marshaller interface for type CustomEntityStoreAssignmentsListResult. func (c CustomEntityStoreAssignmentsListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", c.NextLink) populate(objectMap, "value", c.Value) return json.Marshal(objectMap) @@ -5330,7 +5470,7 @@ func (c *CustomEntityStoreAssignmentsListResult) UnmarshalJSON(data []byte) erro // MarshalJSON implements the json.Marshaller interface for type DataExportSettingProperties. func (d DataExportSettingProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "enabled", d.Enabled) return json.Marshal(objectMap) } @@ -5357,7 +5497,7 @@ func (d *DataExportSettingProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DataExportSettings. func (d DataExportSettings) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", d.ID) objectMap["kind"] = SettingKindDataExportSettings populate(objectMap, "name", d.Name) @@ -5400,7 +5540,9 @@ func (d *DataExportSettings) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DefenderCspmAwsOffering. func (d DefenderCspmAwsOffering) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) + populate(objectMap, "dataSensitivityDiscovery", d.DataSensitivityDiscovery) + populate(objectMap, "databasesDspm", d.DatabasesDspm) populate(objectMap, "description", d.Description) objectMap["offeringType"] = OfferingTypeDefenderCspmAws populate(objectMap, "vmScanners", d.VMScanners) @@ -5416,6 +5558,12 @@ func (d *DefenderCspmAwsOffering) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "dataSensitivityDiscovery": + err = unpopulate(val, "DataSensitivityDiscovery", &d.DataSensitivityDiscovery) + delete(rawMsg, key) + case "databasesDspm": + err = unpopulate(val, "DatabasesDspm", &d.DatabasesDspm) + delete(rawMsg, key) case "description": err = unpopulate(val, "Description", &d.Description) delete(rawMsg, key) @@ -5433,9 +5581,71 @@ func (d *DefenderCspmAwsOffering) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type DefenderCspmAwsOfferingDataSensitivityDiscovery. +func (d DefenderCspmAwsOfferingDataSensitivityDiscovery) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "cloudRoleArn", d.CloudRoleArn) + populate(objectMap, "enabled", d.Enabled) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DefenderCspmAwsOfferingDataSensitivityDiscovery. +func (d *DefenderCspmAwsOfferingDataSensitivityDiscovery) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "cloudRoleArn": + err = unpopulate(val, "CloudRoleArn", &d.CloudRoleArn) + delete(rawMsg, key) + case "enabled": + err = unpopulate(val, "Enabled", &d.Enabled) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DefenderCspmAwsOfferingDatabasesDspm. +func (d DefenderCspmAwsOfferingDatabasesDspm) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "cloudRoleArn", d.CloudRoleArn) + populate(objectMap, "enabled", d.Enabled) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DefenderCspmAwsOfferingDatabasesDspm. +func (d *DefenderCspmAwsOfferingDatabasesDspm) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "cloudRoleArn": + err = unpopulate(val, "CloudRoleArn", &d.CloudRoleArn) + delete(rawMsg, key) + case "enabled": + err = unpopulate(val, "Enabled", &d.Enabled) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type DefenderCspmAwsOfferingVMScanners. func (d DefenderCspmAwsOfferingVMScanners) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "configuration", d.Configuration) populate(objectMap, "enabled", d.Enabled) return json.Marshal(objectMap) @@ -5466,7 +5676,7 @@ func (d *DefenderCspmAwsOfferingVMScanners) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DefenderCspmAwsOfferingVMScannersConfiguration. func (d DefenderCspmAwsOfferingVMScannersConfiguration) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "cloudRoleArn", d.CloudRoleArn) populate(objectMap, "exclusionTags", d.ExclusionTags) populate(objectMap, "scanningMode", d.ScanningMode) @@ -5501,7 +5711,7 @@ func (d *DefenderCspmAwsOfferingVMScannersConfiguration) UnmarshalJSON(data []by // MarshalJSON implements the json.Marshaller interface for type DefenderCspmGcpOffering. func (d DefenderCspmGcpOffering) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "description", d.Description) objectMap["offeringType"] = OfferingTypeDefenderCspmGcp return json.Marshal(objectMap) @@ -5532,8 +5742,9 @@ func (d *DefenderCspmGcpOffering) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DefenderFoDatabasesAwsOffering. func (d DefenderFoDatabasesAwsOffering) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "arcAutoProvisioning", d.ArcAutoProvisioning) + populate(objectMap, "databasesDspm", d.DatabasesDspm) populate(objectMap, "description", d.Description) objectMap["offeringType"] = OfferingTypeDefenderForDatabasesAws populate(objectMap, "rds", d.Rds) @@ -5552,6 +5763,9 @@ func (d *DefenderFoDatabasesAwsOffering) UnmarshalJSON(data []byte) error { case "arcAutoProvisioning": err = unpopulate(val, "ArcAutoProvisioning", &d.ArcAutoProvisioning) delete(rawMsg, key) + case "databasesDspm": + err = unpopulate(val, "DatabasesDspm", &d.DatabasesDspm) + delete(rawMsg, key) case "description": err = unpopulate(val, "Description", &d.Description) delete(rawMsg, key) @@ -5571,14 +5785,80 @@ func (d *DefenderFoDatabasesAwsOffering) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DefenderFoDatabasesAwsOfferingArcAutoProvisioning. func (d DefenderFoDatabasesAwsOfferingArcAutoProvisioning) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "cloudRoleArn", d.CloudRoleArn) + populate(objectMap, "configuration", d.Configuration) populate(objectMap, "enabled", d.Enabled) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type DefenderFoDatabasesAwsOfferingArcAutoProvisioning. func (d *DefenderFoDatabasesAwsOfferingArcAutoProvisioning) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "cloudRoleArn": + err = unpopulate(val, "CloudRoleArn", &d.CloudRoleArn) + delete(rawMsg, key) + case "configuration": + err = unpopulate(val, "Configuration", &d.Configuration) + delete(rawMsg, key) + case "enabled": + err = unpopulate(val, "Enabled", &d.Enabled) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DefenderFoDatabasesAwsOfferingArcAutoProvisioningConfiguration. +func (d DefenderFoDatabasesAwsOfferingArcAutoProvisioningConfiguration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "privateLinkScope", d.PrivateLinkScope) + populate(objectMap, "proxy", d.Proxy) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DefenderFoDatabasesAwsOfferingArcAutoProvisioningConfiguration. +func (d *DefenderFoDatabasesAwsOfferingArcAutoProvisioningConfiguration) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "privateLinkScope": + err = unpopulate(val, "PrivateLinkScope", &d.PrivateLinkScope) + delete(rawMsg, key) + case "proxy": + err = unpopulate(val, "Proxy", &d.Proxy) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DefenderFoDatabasesAwsOfferingDatabasesDspm. +func (d DefenderFoDatabasesAwsOfferingDatabasesDspm) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "cloudRoleArn", d.CloudRoleArn) + populate(objectMap, "enabled", d.Enabled) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DefenderFoDatabasesAwsOfferingDatabasesDspm. +func (d *DefenderFoDatabasesAwsOfferingDatabasesDspm) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", d, err) @@ -5602,7 +5882,7 @@ func (d *DefenderFoDatabasesAwsOfferingArcAutoProvisioning) UnmarshalJSON(data [ // MarshalJSON implements the json.Marshaller interface for type DefenderFoDatabasesAwsOfferingRds. func (d DefenderFoDatabasesAwsOfferingRds) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "cloudRoleArn", d.CloudRoleArn) populate(objectMap, "enabled", d.Enabled) return json.Marshal(objectMap) @@ -5633,7 +5913,7 @@ func (d *DefenderFoDatabasesAwsOfferingRds) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DefenderForContainersAwsOffering. func (d DefenderForContainersAwsOffering) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "autoProvisioning", d.AutoProvisioning) populate(objectMap, "cloudWatchToKinesis", d.CloudWatchToKinesis) populate(objectMap, "containerVulnerabilityAssessment", d.ContainerVulnerabilityAssessment) @@ -5704,7 +5984,7 @@ func (d *DefenderForContainersAwsOffering) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DefenderForContainersAwsOfferingCloudWatchToKinesis. func (d DefenderForContainersAwsOfferingCloudWatchToKinesis) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "cloudRoleArn", d.CloudRoleArn) return json.Marshal(objectMap) } @@ -5731,7 +6011,7 @@ func (d *DefenderForContainersAwsOfferingCloudWatchToKinesis) UnmarshalJSON(data // MarshalJSON implements the json.Marshaller interface for type DefenderForContainersAwsOfferingContainerVulnerabilityAssessment. func (d DefenderForContainersAwsOfferingContainerVulnerabilityAssessment) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "cloudRoleArn", d.CloudRoleArn) return json.Marshal(objectMap) } @@ -5758,7 +6038,7 @@ func (d *DefenderForContainersAwsOfferingContainerVulnerabilityAssessment) Unmar // MarshalJSON implements the json.Marshaller interface for type DefenderForContainersAwsOfferingContainerVulnerabilityAssessmentTask. func (d DefenderForContainersAwsOfferingContainerVulnerabilityAssessmentTask) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "cloudRoleArn", d.CloudRoleArn) return json.Marshal(objectMap) } @@ -5785,7 +6065,7 @@ func (d *DefenderForContainersAwsOfferingContainerVulnerabilityAssessmentTask) U // MarshalJSON implements the json.Marshaller interface for type DefenderForContainersAwsOfferingKinesisToS3. func (d DefenderForContainersAwsOfferingKinesisToS3) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "cloudRoleArn", d.CloudRoleArn) return json.Marshal(objectMap) } @@ -5812,7 +6092,7 @@ func (d *DefenderForContainersAwsOfferingKinesisToS3) UnmarshalJSON(data []byte) // MarshalJSON implements the json.Marshaller interface for type DefenderForContainersAwsOfferingKubernetesScubaReader. func (d DefenderForContainersAwsOfferingKubernetesScubaReader) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "cloudRoleArn", d.CloudRoleArn) return json.Marshal(objectMap) } @@ -5839,7 +6119,7 @@ func (d *DefenderForContainersAwsOfferingKubernetesScubaReader) UnmarshalJSON(da // MarshalJSON implements the json.Marshaller interface for type DefenderForContainersAwsOfferingKubernetesService. func (d DefenderForContainersAwsOfferingKubernetesService) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "cloudRoleArn", d.CloudRoleArn) return json.Marshal(objectMap) } @@ -5866,7 +6146,7 @@ func (d *DefenderForContainersAwsOfferingKubernetesService) UnmarshalJSON(data [ // MarshalJSON implements the json.Marshaller interface for type DefenderForContainersGcpOffering. func (d DefenderForContainersGcpOffering) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "auditLogsAutoProvisioningFlag", d.AuditLogsAutoProvisioningFlag) populate(objectMap, "dataPipelineNativeCloudConnection", d.DataPipelineNativeCloudConnection) populate(objectMap, "defenderAgentAutoProvisioningFlag", d.DefenderAgentAutoProvisioningFlag) @@ -5917,7 +6197,7 @@ func (d *DefenderForContainersGcpOffering) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DefenderForContainersGcpOfferingDataPipelineNativeCloudConnection. func (d DefenderForContainersGcpOfferingDataPipelineNativeCloudConnection) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "serviceAccountEmailAddress", d.ServiceAccountEmailAddress) populate(objectMap, "workloadIdentityProviderId", d.WorkloadIdentityProviderID) return json.Marshal(objectMap) @@ -5948,7 +6228,7 @@ func (d *DefenderForContainersGcpOfferingDataPipelineNativeCloudConnection) Unma // MarshalJSON implements the json.Marshaller interface for type DefenderForContainersGcpOfferingNativeCloudConnection. func (d DefenderForContainersGcpOfferingNativeCloudConnection) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "serviceAccountEmailAddress", d.ServiceAccountEmailAddress) populate(objectMap, "workloadIdentityProviderId", d.WorkloadIdentityProviderID) return json.Marshal(objectMap) @@ -5979,7 +6259,7 @@ func (d *DefenderForContainersGcpOfferingNativeCloudConnection) UnmarshalJSON(da // MarshalJSON implements the json.Marshaller interface for type DefenderForDatabasesGcpOffering. func (d DefenderForDatabasesGcpOffering) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "arcAutoProvisioning", d.ArcAutoProvisioning) populate(objectMap, "defenderForDatabasesArcAutoProvisioning", d.DefenderForDatabasesArcAutoProvisioning) populate(objectMap, "description", d.Description) @@ -6018,7 +6298,8 @@ func (d *DefenderForDatabasesGcpOffering) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DefenderForDatabasesGcpOfferingArcAutoProvisioning. func (d DefenderForDatabasesGcpOfferingArcAutoProvisioning) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) + populate(objectMap, "configuration", d.Configuration) populate(objectMap, "enabled", d.Enabled) return json.Marshal(objectMap) } @@ -6032,6 +6313,9 @@ func (d *DefenderForDatabasesGcpOfferingArcAutoProvisioning) UnmarshalJSON(data for key, val := range rawMsg { var err error switch key { + case "configuration": + err = unpopulate(val, "Configuration", &d.Configuration) + delete(rawMsg, key) case "enabled": err = unpopulate(val, "Enabled", &d.Enabled) delete(rawMsg, key) @@ -6043,9 +6327,40 @@ func (d *DefenderForDatabasesGcpOfferingArcAutoProvisioning) UnmarshalJSON(data return nil } +// MarshalJSON implements the json.Marshaller interface for type DefenderForDatabasesGcpOfferingArcAutoProvisioningConfiguration. +func (d DefenderForDatabasesGcpOfferingArcAutoProvisioningConfiguration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "privateLinkScope", d.PrivateLinkScope) + populate(objectMap, "proxy", d.Proxy) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DefenderForDatabasesGcpOfferingArcAutoProvisioningConfiguration. +func (d *DefenderForDatabasesGcpOfferingArcAutoProvisioningConfiguration) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "privateLinkScope": + err = unpopulate(val, "PrivateLinkScope", &d.PrivateLinkScope) + delete(rawMsg, key) + case "proxy": + err = unpopulate(val, "Proxy", &d.Proxy) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type DefenderForDatabasesGcpOfferingDefenderForDatabasesArcAutoProvisioning. func (d DefenderForDatabasesGcpOfferingDefenderForDatabasesArcAutoProvisioning) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "serviceAccountEmailAddress", d.ServiceAccountEmailAddress) populate(objectMap, "workloadIdentityProviderId", d.WorkloadIdentityProviderID) return json.Marshal(objectMap) @@ -6076,7 +6391,7 @@ func (d *DefenderForDatabasesGcpOfferingDefenderForDatabasesArcAutoProvisioning) // MarshalJSON implements the json.Marshaller interface for type DefenderForDevOpsAzureDevOpsOffering. func (d DefenderForDevOpsAzureDevOpsOffering) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "description", d.Description) objectMap["offeringType"] = OfferingTypeDefenderForDevOpsAzureDevOps return json.Marshal(objectMap) @@ -6105,16 +6420,16 @@ func (d *DefenderForDevOpsAzureDevOpsOffering) UnmarshalJSON(data []byte) error return nil } -// MarshalJSON implements the json.Marshaller interface for type DefenderForDevOpsGithubOffering. -func (d DefenderForDevOpsGithubOffering) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) +// MarshalJSON implements the json.Marshaller interface for type DefenderForDevOpsGitLabOffering. +func (d DefenderForDevOpsGitLabOffering) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) populate(objectMap, "description", d.Description) - objectMap["offeringType"] = OfferingTypeDefenderForDevOpsGithub + objectMap["offeringType"] = OfferingTypeDefenderForDevOpsGitLab return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type DefenderForDevOpsGithubOffering. -func (d *DefenderForDevOpsGithubOffering) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type DefenderForDevOpsGitLabOffering. +func (d *DefenderForDevOpsGitLabOffering) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", d, err) @@ -6136,15 +6451,46 @@ func (d *DefenderForDevOpsGithubOffering) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type DefenderForServersAwsOffering. -func (d DefenderForServersAwsOffering) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "arcAutoProvisioning", d.ArcAutoProvisioning) - populate(objectMap, "defenderForServers", d.DefenderForServers) +// MarshalJSON implements the json.Marshaller interface for type DefenderForDevOpsGithubOffering. +func (d DefenderForDevOpsGithubOffering) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) populate(objectMap, "description", d.Description) - populate(objectMap, "mdeAutoProvisioning", d.MdeAutoProvisioning) - objectMap["offeringType"] = OfferingTypeDefenderForServersAws - populate(objectMap, "subPlan", d.SubPlan) + objectMap["offeringType"] = OfferingTypeDefenderForDevOpsGithub + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DefenderForDevOpsGithubOffering. +func (d *DefenderForDevOpsGithubOffering) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &d.Description) + delete(rawMsg, key) + case "offeringType": + err = unpopulate(val, "OfferingType", &d.OfferingType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DefenderForServersAwsOffering. +func (d DefenderForServersAwsOffering) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "arcAutoProvisioning", d.ArcAutoProvisioning) + populate(objectMap, "defenderForServers", d.DefenderForServers) + populate(objectMap, "description", d.Description) + populate(objectMap, "mdeAutoProvisioning", d.MdeAutoProvisioning) + objectMap["offeringType"] = OfferingTypeDefenderForServersAws + populate(objectMap, "subPlan", d.SubPlan) populate(objectMap, "vmScanners", d.VMScanners) populate(objectMap, "vaAutoProvisioning", d.VaAutoProvisioning) return json.Marshal(objectMap) @@ -6193,8 +6539,9 @@ func (d *DefenderForServersAwsOffering) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DefenderForServersAwsOfferingArcAutoProvisioning. func (d DefenderForServersAwsOfferingArcAutoProvisioning) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "cloudRoleArn", d.CloudRoleArn) + populate(objectMap, "configuration", d.Configuration) populate(objectMap, "enabled", d.Enabled) return json.Marshal(objectMap) } @@ -6211,6 +6558,9 @@ func (d *DefenderForServersAwsOfferingArcAutoProvisioning) UnmarshalJSON(data [] case "cloudRoleArn": err = unpopulate(val, "CloudRoleArn", &d.CloudRoleArn) delete(rawMsg, key) + case "configuration": + err = unpopulate(val, "Configuration", &d.Configuration) + delete(rawMsg, key) case "enabled": err = unpopulate(val, "Enabled", &d.Enabled) delete(rawMsg, key) @@ -6222,9 +6572,40 @@ func (d *DefenderForServersAwsOfferingArcAutoProvisioning) UnmarshalJSON(data [] return nil } +// MarshalJSON implements the json.Marshaller interface for type DefenderForServersAwsOfferingArcAutoProvisioningConfiguration. +func (d DefenderForServersAwsOfferingArcAutoProvisioningConfiguration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "privateLinkScope", d.PrivateLinkScope) + populate(objectMap, "proxy", d.Proxy) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DefenderForServersAwsOfferingArcAutoProvisioningConfiguration. +func (d *DefenderForServersAwsOfferingArcAutoProvisioningConfiguration) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "privateLinkScope": + err = unpopulate(val, "PrivateLinkScope", &d.PrivateLinkScope) + delete(rawMsg, key) + case "proxy": + err = unpopulate(val, "Proxy", &d.Proxy) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type DefenderForServersAwsOfferingDefenderForServers. func (d DefenderForServersAwsOfferingDefenderForServers) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "cloudRoleArn", d.CloudRoleArn) return json.Marshal(objectMap) } @@ -6251,7 +6632,7 @@ func (d *DefenderForServersAwsOfferingDefenderForServers) UnmarshalJSON(data []b // MarshalJSON implements the json.Marshaller interface for type DefenderForServersAwsOfferingMdeAutoProvisioning. func (d DefenderForServersAwsOfferingMdeAutoProvisioning) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "configuration", &d.Configuration) populate(objectMap, "enabled", d.Enabled) return json.Marshal(objectMap) @@ -6282,7 +6663,7 @@ func (d *DefenderForServersAwsOfferingMdeAutoProvisioning) UnmarshalJSON(data [] // MarshalJSON implements the json.Marshaller interface for type DefenderForServersAwsOfferingSubPlan. func (d DefenderForServersAwsOfferingSubPlan) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "type", d.Type) return json.Marshal(objectMap) } @@ -6309,7 +6690,7 @@ func (d *DefenderForServersAwsOfferingSubPlan) UnmarshalJSON(data []byte) error // MarshalJSON implements the json.Marshaller interface for type DefenderForServersAwsOfferingVMScanners. func (d DefenderForServersAwsOfferingVMScanners) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "configuration", d.Configuration) populate(objectMap, "enabled", d.Enabled) return json.Marshal(objectMap) @@ -6340,7 +6721,7 @@ func (d *DefenderForServersAwsOfferingVMScanners) UnmarshalJSON(data []byte) err // MarshalJSON implements the json.Marshaller interface for type DefenderForServersAwsOfferingVMScannersConfiguration. func (d DefenderForServersAwsOfferingVMScannersConfiguration) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "cloudRoleArn", d.CloudRoleArn) populate(objectMap, "exclusionTags", d.ExclusionTags) populate(objectMap, "scanningMode", d.ScanningMode) @@ -6375,7 +6756,7 @@ func (d *DefenderForServersAwsOfferingVMScannersConfiguration) UnmarshalJSON(dat // MarshalJSON implements the json.Marshaller interface for type DefenderForServersAwsOfferingVaAutoProvisioning. func (d DefenderForServersAwsOfferingVaAutoProvisioning) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "configuration", d.Configuration) populate(objectMap, "enabled", d.Enabled) return json.Marshal(objectMap) @@ -6406,7 +6787,7 @@ func (d *DefenderForServersAwsOfferingVaAutoProvisioning) UnmarshalJSON(data []b // MarshalJSON implements the json.Marshaller interface for type DefenderForServersAwsOfferingVaAutoProvisioningConfiguration. func (d DefenderForServersAwsOfferingVaAutoProvisioningConfiguration) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "type", d.Type) return json.Marshal(objectMap) } @@ -6433,13 +6814,14 @@ func (d *DefenderForServersAwsOfferingVaAutoProvisioningConfiguration) Unmarshal // MarshalJSON implements the json.Marshaller interface for type DefenderForServersGcpOffering. func (d DefenderForServersGcpOffering) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "arcAutoProvisioning", d.ArcAutoProvisioning) populate(objectMap, "defenderForServers", d.DefenderForServers) populate(objectMap, "description", d.Description) populate(objectMap, "mdeAutoProvisioning", d.MdeAutoProvisioning) objectMap["offeringType"] = OfferingTypeDefenderForServersGcp populate(objectMap, "subPlan", d.SubPlan) + populate(objectMap, "vmScanners", d.VMScanners) populate(objectMap, "vaAutoProvisioning", d.VaAutoProvisioning) return json.Marshal(objectMap) } @@ -6471,6 +6853,9 @@ func (d *DefenderForServersGcpOffering) UnmarshalJSON(data []byte) error { case "subPlan": err = unpopulate(val, "SubPlan", &d.SubPlan) delete(rawMsg, key) + case "vmScanners": + err = unpopulate(val, "VMScanners", &d.VMScanners) + delete(rawMsg, key) case "vaAutoProvisioning": err = unpopulate(val, "VaAutoProvisioning", &d.VaAutoProvisioning) delete(rawMsg, key) @@ -6484,7 +6869,8 @@ func (d *DefenderForServersGcpOffering) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DefenderForServersGcpOfferingArcAutoProvisioning. func (d DefenderForServersGcpOfferingArcAutoProvisioning) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) + populate(objectMap, "configuration", d.Configuration) populate(objectMap, "enabled", d.Enabled) return json.Marshal(objectMap) } @@ -6498,6 +6884,9 @@ func (d *DefenderForServersGcpOfferingArcAutoProvisioning) UnmarshalJSON(data [] for key, val := range rawMsg { var err error switch key { + case "configuration": + err = unpopulate(val, "Configuration", &d.Configuration) + delete(rawMsg, key) case "enabled": err = unpopulate(val, "Enabled", &d.Enabled) delete(rawMsg, key) @@ -6509,9 +6898,40 @@ func (d *DefenderForServersGcpOfferingArcAutoProvisioning) UnmarshalJSON(data [] return nil } +// MarshalJSON implements the json.Marshaller interface for type DefenderForServersGcpOfferingArcAutoProvisioningConfiguration. +func (d DefenderForServersGcpOfferingArcAutoProvisioningConfiguration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "privateLinkScope", d.PrivateLinkScope) + populate(objectMap, "proxy", d.Proxy) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DefenderForServersGcpOfferingArcAutoProvisioningConfiguration. +func (d *DefenderForServersGcpOfferingArcAutoProvisioningConfiguration) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "privateLinkScope": + err = unpopulate(val, "PrivateLinkScope", &d.PrivateLinkScope) + delete(rawMsg, key) + case "proxy": + err = unpopulate(val, "Proxy", &d.Proxy) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type DefenderForServersGcpOfferingDefenderForServers. func (d DefenderForServersGcpOfferingDefenderForServers) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "serviceAccountEmailAddress", d.ServiceAccountEmailAddress) populate(objectMap, "workloadIdentityProviderId", d.WorkloadIdentityProviderID) return json.Marshal(objectMap) @@ -6542,7 +6962,7 @@ func (d *DefenderForServersGcpOfferingDefenderForServers) UnmarshalJSON(data []b // MarshalJSON implements the json.Marshaller interface for type DefenderForServersGcpOfferingMdeAutoProvisioning. func (d DefenderForServersGcpOfferingMdeAutoProvisioning) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "configuration", &d.Configuration) populate(objectMap, "enabled", d.Enabled) return json.Marshal(objectMap) @@ -6573,7 +6993,7 @@ func (d *DefenderForServersGcpOfferingMdeAutoProvisioning) UnmarshalJSON(data [] // MarshalJSON implements the json.Marshaller interface for type DefenderForServersGcpOfferingSubPlan. func (d DefenderForServersGcpOfferingSubPlan) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "type", d.Type) return json.Marshal(objectMap) } @@ -6598,9 +7018,71 @@ func (d *DefenderForServersGcpOfferingSubPlan) UnmarshalJSON(data []byte) error return nil } +// MarshalJSON implements the json.Marshaller interface for type DefenderForServersGcpOfferingVMScanners. +func (d DefenderForServersGcpOfferingVMScanners) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "configuration", d.Configuration) + populate(objectMap, "enabled", d.Enabled) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DefenderForServersGcpOfferingVMScanners. +func (d *DefenderForServersGcpOfferingVMScanners) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "configuration": + err = unpopulate(val, "Configuration", &d.Configuration) + delete(rawMsg, key) + case "enabled": + err = unpopulate(val, "Enabled", &d.Enabled) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DefenderForServersGcpOfferingVMScannersConfiguration. +func (d DefenderForServersGcpOfferingVMScannersConfiguration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "exclusionTags", d.ExclusionTags) + populate(objectMap, "scanningMode", d.ScanningMode) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DefenderForServersGcpOfferingVMScannersConfiguration. +func (d *DefenderForServersGcpOfferingVMScannersConfiguration) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "exclusionTags": + err = unpopulate(val, "ExclusionTags", &d.ExclusionTags) + delete(rawMsg, key) + case "scanningMode": + err = unpopulate(val, "ScanningMode", &d.ScanningMode) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type DefenderForServersGcpOfferingVaAutoProvisioning. func (d DefenderForServersGcpOfferingVaAutoProvisioning) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "configuration", d.Configuration) populate(objectMap, "enabled", d.Enabled) return json.Marshal(objectMap) @@ -6631,7 +7113,7 @@ func (d *DefenderForServersGcpOfferingVaAutoProvisioning) UnmarshalJSON(data []b // MarshalJSON implements the json.Marshaller interface for type DefenderForServersGcpOfferingVaAutoProvisioningConfiguration. func (d DefenderForServersGcpOfferingVaAutoProvisioningConfiguration) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "type", d.Type) return json.Marshal(objectMap) } @@ -6658,7 +7140,7 @@ func (d *DefenderForServersGcpOfferingVaAutoProvisioningConfiguration) Unmarshal // MarshalJSON implements the json.Marshaller interface for type DenylistCustomAlertRule. func (d DenylistCustomAlertRule) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "denylistValues", d.DenylistValues) populate(objectMap, "description", d.Description) populate(objectMap, "displayName", d.DisplayName) @@ -6705,7 +7187,7 @@ func (d *DenylistCustomAlertRule) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DeviceSecurityGroup. func (d DeviceSecurityGroup) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", d.ID) populate(objectMap, "name", d.Name) populate(objectMap, "properties", d.Properties) @@ -6744,7 +7226,7 @@ func (d *DeviceSecurityGroup) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DeviceSecurityGroupList. func (d DeviceSecurityGroupList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", d.NextLink) populate(objectMap, "value", d.Value) return json.Marshal(objectMap) @@ -6775,7 +7257,7 @@ func (d *DeviceSecurityGroupList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DeviceSecurityGroupProperties. func (d DeviceSecurityGroupProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "allowlistRules", d.AllowlistRules) populate(objectMap, "denylistRules", d.DenylistRules) populate(objectMap, "thresholdRules", d.ThresholdRules) @@ -6814,7 +7296,7 @@ func (d *DeviceSecurityGroupProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DirectMethodInvokesNotInAllowedRange. func (d DirectMethodInvokesNotInAllowedRange) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "description", d.Description) populate(objectMap, "displayName", d.DisplayName) populate(objectMap, "isEnabled", d.IsEnabled) @@ -6865,7 +7347,7 @@ func (d *DirectMethodInvokesNotInAllowedRange) UnmarshalJSON(data []byte) error // MarshalJSON implements the json.Marshaller interface for type DiscoveredSecuritySolution. func (d DiscoveredSecuritySolution) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", d.ID) populate(objectMap, "location", d.Location) populate(objectMap, "name", d.Name) @@ -6908,7 +7390,7 @@ func (d *DiscoveredSecuritySolution) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DiscoveredSecuritySolutionList. func (d DiscoveredSecuritySolutionList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", d.NextLink) populate(objectMap, "value", d.Value) return json.Marshal(objectMap) @@ -6939,7 +7421,7 @@ func (d *DiscoveredSecuritySolutionList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DiscoveredSecuritySolutionProperties. func (d DiscoveredSecuritySolutionProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "offer", d.Offer) populate(objectMap, "publisher", d.Publisher) populate(objectMap, "sku", d.SKU) @@ -6978,7 +7460,7 @@ func (d *DiscoveredSecuritySolutionProperties) UnmarshalJSON(data []byte) error // MarshalJSON implements the json.Marshaller interface for type ETag. func (e ETag) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "etag", e.Etag) return json.Marshal(objectMap) } @@ -7005,7 +7487,7 @@ func (e *ETag) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type EffectiveNetworkSecurityGroups. func (e EffectiveNetworkSecurityGroups) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "networkInterface", e.NetworkInterface) populate(objectMap, "networkSecurityGroups", e.NetworkSecurityGroups) return json.Marshal(objectMap) @@ -7036,7 +7518,7 @@ func (e *EffectiveNetworkSecurityGroups) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type EnvironmentData. func (e EnvironmentData) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["environmentType"] = e.EnvironmentType return json.Marshal(objectMap) } @@ -7061,9 +7543,52 @@ func (e *EnvironmentData) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type EnvironmentDetails. +func (e EnvironmentDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "environmentHierarchyId", e.EnvironmentHierarchyID) + populate(objectMap, "nativeResourceId", e.NativeResourceID) + populate(objectMap, "organizationalHierarchyId", e.OrganizationalHierarchyID) + populate(objectMap, "subscriptionId", e.SubscriptionID) + populate(objectMap, "tenantId", e.TenantID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EnvironmentDetails. +func (e *EnvironmentDetails) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "environmentHierarchyId": + err = unpopulate(val, "EnvironmentHierarchyID", &e.EnvironmentHierarchyID) + delete(rawMsg, key) + case "nativeResourceId": + err = unpopulate(val, "NativeResourceID", &e.NativeResourceID) + delete(rawMsg, key) + case "organizationalHierarchyId": + err = unpopulate(val, "OrganizationalHierarchyID", &e.OrganizationalHierarchyID) + delete(rawMsg, key) + case "subscriptionId": + err = unpopulate(val, "SubscriptionID", &e.SubscriptionID) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &e.TenantID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type ErrorAdditionalInfo. func (e ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "info", &e.Info) populate(objectMap, "type", e.Type) return json.Marshal(objectMap) @@ -7092,9 +7617,149 @@ func (e *ErrorAdditionalInfo) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type ErrorDetail. +func (e ErrorDetail) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "additionalInfo", e.AdditionalInfo) + populate(objectMap, "code", e.Code) + populate(objectMap, "details", e.Details) + populate(objectMap, "message", e.Message) + populate(objectMap, "target", e.Target) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorDetail. +func (e *ErrorDetail) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "additionalInfo": + err = unpopulate(val, "AdditionalInfo", &e.AdditionalInfo) + delete(rawMsg, key) + case "code": + err = unpopulate(val, "Code", &e.Code) + delete(rawMsg, key) + case "details": + err = unpopulate(val, "Details", &e.Details) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &e.Message) + delete(rawMsg, key) + case "target": + err = unpopulate(val, "Target", &e.Target) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorDetailAutoGenerated. +func (e ErrorDetailAutoGenerated) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "additionalInfo", e.AdditionalInfo) + populate(objectMap, "code", e.Code) + populate(objectMap, "details", e.Details) + populate(objectMap, "message", e.Message) + populate(objectMap, "target", e.Target) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorDetailAutoGenerated. +func (e *ErrorDetailAutoGenerated) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "additionalInfo": + err = unpopulate(val, "AdditionalInfo", &e.AdditionalInfo) + delete(rawMsg, key) + case "code": + err = unpopulate(val, "Code", &e.Code) + delete(rawMsg, key) + case "details": + err = unpopulate(val, "Details", &e.Details) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &e.Message) + delete(rawMsg, key) + case "target": + err = unpopulate(val, "Target", &e.Target) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorResponse. +func (e ErrorResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "error", e.Error) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorResponse. +func (e *ErrorResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "error": + err = unpopulate(val, "Error", &e.Error) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorResponseAutoGenerated. +func (e ErrorResponseAutoGenerated) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "error", e.Error) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorResponseAutoGenerated. +func (e *ErrorResponseAutoGenerated) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "error": + err = unpopulate(val, "Error", &e.Error) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type ExecuteGovernanceRuleParams. func (e ExecuteGovernanceRuleParams) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "override", e.Override) return json.Marshal(objectMap) } @@ -7119,15 +7784,18 @@ func (e *ExecuteGovernanceRuleParams) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type ExecuteRuleStatus. -func (e ExecuteRuleStatus) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "operationId", e.OperationID) +// MarshalJSON implements the json.Marshaller interface for type Extension. +func (e Extension) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "additionalExtensionProperties", e.AdditionalExtensionProperties) + populate(objectMap, "isEnabled", e.IsEnabled) + populate(objectMap, "name", e.Name) + populate(objectMap, "operationStatus", e.OperationStatus) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ExecuteRuleStatus. -func (e *ExecuteRuleStatus) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type Extension. +func (e *Extension) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", e, err) @@ -7135,8 +7803,17 @@ func (e *ExecuteRuleStatus) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "operationId": - err = unpopulate(val, "OperationID", &e.OperationID) + case "additionalExtensionProperties": + err = unpopulate(val, "AdditionalExtensionProperties", &e.AdditionalExtensionProperties) + delete(rawMsg, key) + case "isEnabled": + err = unpopulate(val, "IsEnabled", &e.IsEnabled) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &e.Name) + delete(rawMsg, key) + case "operationStatus": + err = unpopulate(val, "OperationStatus", &e.OperationStatus) delete(rawMsg, key) } if err != nil { @@ -7148,7 +7825,7 @@ func (e *ExecuteRuleStatus) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ExternalSecuritySolution. func (e ExternalSecuritySolution) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", e.ID) populate(objectMap, "kind", e.Kind) populate(objectMap, "location", e.Location) @@ -7191,7 +7868,7 @@ func (e *ExternalSecuritySolution) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ExternalSecuritySolutionKindAutoGenerated. func (e ExternalSecuritySolutionKindAutoGenerated) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "kind", e.Kind) return json.Marshal(objectMap) } @@ -7218,7 +7895,7 @@ func (e *ExternalSecuritySolutionKindAutoGenerated) UnmarshalJSON(data []byte) e // MarshalJSON implements the json.Marshaller interface for type ExternalSecuritySolutionList. func (e ExternalSecuritySolutionList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", e.NextLink) populate(objectMap, "value", e.Value) return json.Marshal(objectMap) @@ -7249,7 +7926,7 @@ func (e *ExternalSecuritySolutionList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ExternalSecuritySolutionProperties. func (e ExternalSecuritySolutionProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "deviceType", e.DeviceType) populate(objectMap, "deviceVendor", e.DeviceVendor) populate(objectMap, "workspace", e.Workspace) @@ -7281,10 +7958,10 @@ func (e *ExternalSecuritySolutionProperties) UnmarshalJSON(data []byte) error { delete(rawMsg, key) default: if e.AdditionalProperties == nil { - e.AdditionalProperties = map[string]interface{}{} + e.AdditionalProperties = map[string]any{} } if val != nil { - var aux interface{} + var aux any err = json.Unmarshal(val, &aux) e.AdditionalProperties[key] = aux } @@ -7299,7 +7976,7 @@ func (e *ExternalSecuritySolutionProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type FailedLocalLoginsNotInAllowedRange. func (f FailedLocalLoginsNotInAllowedRange) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "description", f.Description) populate(objectMap, "displayName", f.DisplayName) populate(objectMap, "isEnabled", f.IsEnabled) @@ -7350,7 +8027,7 @@ func (f *FailedLocalLoginsNotInAllowedRange) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type FileUploadsNotInAllowedRange. func (f FileUploadsNotInAllowedRange) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "description", f.Description) populate(objectMap, "displayName", f.DisplayName) populate(objectMap, "isEnabled", f.IsEnabled) @@ -7401,7 +8078,7 @@ func (f *FileUploadsNotInAllowedRange) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type GcpCredentialsDetailsProperties. func (g GcpCredentialsDetailsProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "authProviderX509CertUrl", g.AuthProviderX509CertURL) populate(objectMap, "authUri", g.AuthURI) populate(objectMap, "authenticationProvisioningState", g.AuthenticationProvisioningState) @@ -7480,7 +8157,7 @@ func (g *GcpCredentialsDetailsProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type GcpOrganizationalData. func (g GcpOrganizationalData) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["organizationMembershipType"] = g.OrganizationMembershipType return json.Marshal(objectMap) } @@ -7507,7 +8184,7 @@ func (g *GcpOrganizationalData) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type GcpOrganizationalDataMember. func (g GcpOrganizationalDataMember) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "managementProjectNumber", g.ManagementProjectNumber) objectMap["organizationMembershipType"] = OrganizationMembershipTypeMember populate(objectMap, "parentHierarchyId", g.ParentHierarchyID) @@ -7542,9 +8219,10 @@ func (g *GcpOrganizationalDataMember) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type GcpOrganizationalDataOrganization. func (g GcpOrganizationalDataOrganization) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "excludedProjectNumbers", g.ExcludedProjectNumbers) objectMap["organizationMembershipType"] = OrganizationMembershipTypeOrganization + populate(objectMap, "organizationName", g.OrganizationName) populate(objectMap, "serviceAccountEmailAddress", g.ServiceAccountEmailAddress) populate(objectMap, "workloadIdentityProviderId", g.WorkloadIdentityProviderID) return json.Marshal(objectMap) @@ -7565,6 +8243,9 @@ func (g *GcpOrganizationalDataOrganization) UnmarshalJSON(data []byte) error { case "organizationMembershipType": err = unpopulate(val, "OrganizationMembershipType", &g.OrganizationMembershipType) delete(rawMsg, key) + case "organizationName": + err = unpopulate(val, "OrganizationName", &g.OrganizationName) + delete(rawMsg, key) case "serviceAccountEmailAddress": err = unpopulate(val, "ServiceAccountEmailAddress", &g.ServiceAccountEmailAddress) delete(rawMsg, key) @@ -7581,8 +8262,9 @@ func (g *GcpOrganizationalDataOrganization) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type GcpProjectDetails. func (g GcpProjectDetails) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "projectId", g.ProjectID) + populate(objectMap, "projectName", g.ProjectName) populate(objectMap, "projectNumber", g.ProjectNumber) populate(objectMap, "workloadIdentityPoolId", g.WorkloadIdentityPoolID) return json.Marshal(objectMap) @@ -7600,6 +8282,9 @@ func (g *GcpProjectDetails) UnmarshalJSON(data []byte) error { case "projectId": err = unpopulate(val, "ProjectID", &g.ProjectID) delete(rawMsg, key) + case "projectName": + err = unpopulate(val, "ProjectName", &g.ProjectName) + delete(rawMsg, key) case "projectNumber": err = unpopulate(val, "ProjectNumber", &g.ProjectNumber) delete(rawMsg, key) @@ -7616,7 +8301,7 @@ func (g *GcpProjectDetails) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type GcpProjectEnvironmentData. func (g GcpProjectEnvironmentData) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["environmentType"] = EnvironmentTypeGcpProject populate(objectMap, "organizationalData", g.OrganizationalData) populate(objectMap, "projectDetails", g.ProjectDetails) @@ -7649,15 +8334,42 @@ func (g *GcpProjectEnvironmentData) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type GithubScopeEnvironmentData. -func (g GithubScopeEnvironmentData) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - objectMap["environmentType"] = EnvironmentTypeGithubScope +// MarshalJSON implements the json.Marshaller interface for type GithubScopeEnvironmentData. +func (g GithubScopeEnvironmentData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + objectMap["environmentType"] = EnvironmentTypeGithubScope + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GithubScopeEnvironmentData. +func (g *GithubScopeEnvironmentData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "environmentType": + err = unpopulate(val, "EnvironmentType", &g.EnvironmentType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type GitlabScopeEnvironmentData. +func (g GitlabScopeEnvironmentData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + objectMap["environmentType"] = EnvironmentTypeGitlabScope return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type GithubScopeEnvironmentData. -func (g *GithubScopeEnvironmentData) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type GitlabScopeEnvironmentData. +func (g *GitlabScopeEnvironmentData) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", g, err) @@ -7678,7 +8390,7 @@ func (g *GithubScopeEnvironmentData) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type GovernanceAssignment. func (g GovernanceAssignment) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", g.ID) populate(objectMap, "name", g.Name) populate(objectMap, "properties", g.Properties) @@ -7717,7 +8429,7 @@ func (g *GovernanceAssignment) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type GovernanceAssignmentAdditionalData. func (g GovernanceAssignmentAdditionalData) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "ticketLink", g.TicketLink) populate(objectMap, "ticketNumber", g.TicketNumber) populate(objectMap, "ticketStatus", g.TicketStatus) @@ -7752,7 +8464,7 @@ func (g *GovernanceAssignmentAdditionalData) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type GovernanceAssignmentProperties. func (g GovernanceAssignmentProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "additionalData", g.AdditionalData) populate(objectMap, "governanceEmailNotification", g.GovernanceEmailNotification) populate(objectMap, "isGracePeriod", g.IsGracePeriod) @@ -7799,7 +8511,7 @@ func (g *GovernanceAssignmentProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type GovernanceAssignmentsList. func (g GovernanceAssignmentsList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", g.NextLink) populate(objectMap, "value", g.Value) return json.Marshal(objectMap) @@ -7830,7 +8542,7 @@ func (g *GovernanceAssignmentsList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type GovernanceEmailNotification. func (g GovernanceEmailNotification) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "disableManagerEmailNotification", g.DisableManagerEmailNotification) populate(objectMap, "disableOwnerEmailNotification", g.DisableOwnerEmailNotification) return json.Marshal(objectMap) @@ -7861,7 +8573,7 @@ func (g *GovernanceEmailNotification) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type GovernanceRule. func (g GovernanceRule) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", g.ID) populate(objectMap, "name", g.Name) populate(objectMap, "properties", g.Properties) @@ -7900,7 +8612,7 @@ func (g *GovernanceRule) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type GovernanceRuleEmailNotification. func (g GovernanceRuleEmailNotification) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "disableManagerEmailNotification", g.DisableManagerEmailNotification) populate(objectMap, "disableOwnerEmailNotification", g.DisableOwnerEmailNotification) return json.Marshal(objectMap) @@ -7931,7 +8643,7 @@ func (g *GovernanceRuleEmailNotification) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type GovernanceRuleList. func (g GovernanceRuleList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", g.NextLink) populate(objectMap, "value", g.Value) return json.Marshal(objectMap) @@ -7960,9 +8672,48 @@ func (g *GovernanceRuleList) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type GovernanceRuleMetadata. +func (g GovernanceRuleMetadata) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "createdBy", g.CreatedBy) + populateTimeRFC3339(objectMap, "createdOn", g.CreatedOn) + populate(objectMap, "updatedBy", g.UpdatedBy) + populateTimeRFC3339(objectMap, "updatedOn", g.UpdatedOn) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GovernanceRuleMetadata. +func (g *GovernanceRuleMetadata) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createdBy": + err = unpopulate(val, "CreatedBy", &g.CreatedBy) + delete(rawMsg, key) + case "createdOn": + err = unpopulateTimeRFC3339(val, "CreatedOn", &g.CreatedOn) + delete(rawMsg, key) + case "updatedBy": + err = unpopulate(val, "UpdatedBy", &g.UpdatedBy) + delete(rawMsg, key) + case "updatedOn": + err = unpopulateTimeRFC3339(val, "UpdatedOn", &g.UpdatedOn) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type GovernanceRuleOwnerSource. func (g GovernanceRuleOwnerSource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "type", g.Type) populate(objectMap, "value", g.Value) return json.Marshal(objectMap) @@ -7993,18 +8744,22 @@ func (g *GovernanceRuleOwnerSource) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type GovernanceRuleProperties. func (g GovernanceRuleProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "conditionSets", g.ConditionSets) populate(objectMap, "description", g.Description) populate(objectMap, "displayName", g.DisplayName) + populate(objectMap, "excludedScopes", g.ExcludedScopes) populate(objectMap, "governanceEmailNotification", g.GovernanceEmailNotification) + populate(objectMap, "includeMemberScopes", g.IncludeMemberScopes) populate(objectMap, "isDisabled", g.IsDisabled) populate(objectMap, "isGracePeriod", g.IsGracePeriod) + populate(objectMap, "metadata", g.Metadata) populate(objectMap, "ownerSource", g.OwnerSource) populate(objectMap, "remediationTimeframe", g.RemediationTimeframe) populate(objectMap, "rulePriority", g.RulePriority) populate(objectMap, "ruleType", g.RuleType) populate(objectMap, "sourceResourceType", g.SourceResourceType) + populate(objectMap, "tenantId", g.TenantID) return json.Marshal(objectMap) } @@ -8026,15 +8781,24 @@ func (g *GovernanceRuleProperties) UnmarshalJSON(data []byte) error { case "displayName": err = unpopulate(val, "DisplayName", &g.DisplayName) delete(rawMsg, key) + case "excludedScopes": + err = unpopulate(val, "ExcludedScopes", &g.ExcludedScopes) + delete(rawMsg, key) case "governanceEmailNotification": err = unpopulate(val, "GovernanceEmailNotification", &g.GovernanceEmailNotification) delete(rawMsg, key) + case "includeMemberScopes": + err = unpopulate(val, "IncludeMemberScopes", &g.IncludeMemberScopes) + delete(rawMsg, key) case "isDisabled": err = unpopulate(val, "IsDisabled", &g.IsDisabled) delete(rawMsg, key) case "isGracePeriod": err = unpopulate(val, "IsGracePeriod", &g.IsGracePeriod) delete(rawMsg, key) + case "metadata": + err = unpopulate(val, "Metadata", &g.Metadata) + delete(rawMsg, key) case "ownerSource": err = unpopulate(val, "OwnerSource", &g.OwnerSource) delete(rawMsg, key) @@ -8050,6 +8814,9 @@ func (g *GovernanceRuleProperties) UnmarshalJSON(data []byte) error { case "sourceResourceType": err = unpopulate(val, "SourceResourceType", &g.SourceResourceType) delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &g.TenantID) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", g, err) @@ -8060,7 +8827,7 @@ func (g *GovernanceRuleProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type HTTPC2DMessagesNotInAllowedRange. func (h HTTPC2DMessagesNotInAllowedRange) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "description", h.Description) populate(objectMap, "displayName", h.DisplayName) populate(objectMap, "isEnabled", h.IsEnabled) @@ -8111,7 +8878,7 @@ func (h *HTTPC2DMessagesNotInAllowedRange) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type HTTPC2DRejectedMessagesNotInAllowedRange. func (h HTTPC2DRejectedMessagesNotInAllowedRange) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "description", h.Description) populate(objectMap, "displayName", h.DisplayName) populate(objectMap, "isEnabled", h.IsEnabled) @@ -8162,7 +8929,7 @@ func (h *HTTPC2DRejectedMessagesNotInAllowedRange) UnmarshalJSON(data []byte) er // MarshalJSON implements the json.Marshaller interface for type HTTPD2CMessagesNotInAllowedRange. func (h HTTPD2CMessagesNotInAllowedRange) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "description", h.Description) populate(objectMap, "displayName", h.DisplayName) populate(objectMap, "isEnabled", h.IsEnabled) @@ -8211,9 +8978,161 @@ func (h *HTTPD2CMessagesNotInAllowedRange) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type HealthDataClassification. +func (h HealthDataClassification) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "component", h.Component) + populate(objectMap, "scenario", h.Scenario) + populate(objectMap, "scope", h.Scope) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type HealthDataClassification. +func (h *HealthDataClassification) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "component": + err = unpopulate(val, "Component", &h.Component) + delete(rawMsg, key) + case "scenario": + err = unpopulate(val, "Scenario", &h.Scenario) + delete(rawMsg, key) + case "scope": + err = unpopulate(val, "Scope", &h.Scope) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type HealthReport. +func (h HealthReport) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", h.ID) + populate(objectMap, "name", h.Name) + populate(objectMap, "properties", h.Properties) + populate(objectMap, "type", h.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type HealthReport. +func (h *HealthReport) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &h.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &h.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &h.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &h.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type HealthReportProperties. +func (h HealthReportProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "affectedDefendersPlans", h.AffectedDefendersPlans) + populate(objectMap, "environmentDetails", h.EnvironmentDetails) + populate(objectMap, "healthDataClassification", h.HealthDataClassification) + populate(objectMap, "issues", h.Issues) + populate(objectMap, "resourceDetails", h.ResourceDetails) + populate(objectMap, "status", h.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type HealthReportProperties. +func (h *HealthReportProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "affectedDefendersPlans": + err = unpopulate(val, "AffectedDefendersPlans", &h.AffectedDefendersPlans) + delete(rawMsg, key) + case "environmentDetails": + err = unpopulate(val, "EnvironmentDetails", &h.EnvironmentDetails) + delete(rawMsg, key) + case "healthDataClassification": + err = unpopulate(val, "HealthDataClassification", &h.HealthDataClassification) + delete(rawMsg, key) + case "issues": + err = unpopulate(val, "Issues", &h.Issues) + delete(rawMsg, key) + case "resourceDetails": + err = unpopulate(val, "ResourceDetails", &h.ResourceDetails) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &h.Status) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type HealthReportsList. +func (h HealthReportsList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", h.NextLink) + populate(objectMap, "value", h.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type HealthReportsList. +func (h *HealthReportsList) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &h.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &h.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type HybridComputeSettingsProperties. func (h HybridComputeSettingsProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "autoProvision", h.AutoProvision) populate(objectMap, "hybridComputeProvisioningState", h.HybridComputeProvisioningState) populate(objectMap, "proxyServer", h.ProxyServer) @@ -8260,7 +9179,7 @@ func (h *HybridComputeSettingsProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type InformationProtectionAwsOffering. func (i InformationProtectionAwsOffering) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "description", i.Description) populate(objectMap, "informationProtection", i.InformationProtection) objectMap["offeringType"] = OfferingTypeInformationProtectionAws @@ -8295,7 +9214,7 @@ func (i *InformationProtectionAwsOffering) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type InformationProtectionAwsOfferingInformationProtection. func (i InformationProtectionAwsOfferingInformationProtection) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "cloudRoleArn", i.CloudRoleArn) return json.Marshal(objectMap) } @@ -8322,7 +9241,7 @@ func (i *InformationProtectionAwsOfferingInformationProtection) UnmarshalJSON(da // MarshalJSON implements the json.Marshaller interface for type InformationProtectionKeyword. func (i InformationProtectionKeyword) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "canBeNumeric", i.CanBeNumeric) populate(objectMap, "custom", i.Custom) populate(objectMap, "excluded", i.Excluded) @@ -8361,7 +9280,7 @@ func (i *InformationProtectionKeyword) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type InformationProtectionPolicy. func (i InformationProtectionPolicy) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", i.ID) populate(objectMap, "name", i.Name) populate(objectMap, "properties", i.Properties) @@ -8400,7 +9319,7 @@ func (i *InformationProtectionPolicy) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type InformationProtectionPolicyList. func (i InformationProtectionPolicyList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", i.NextLink) populate(objectMap, "value", i.Value) return json.Marshal(objectMap) @@ -8431,7 +9350,7 @@ func (i *InformationProtectionPolicyList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type InformationProtectionPolicyProperties. func (i InformationProtectionPolicyProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "informationTypes", i.InformationTypes) populate(objectMap, "labels", i.Labels) populateTimeRFC3339(objectMap, "lastModifiedUtc", i.LastModifiedUTC) @@ -8470,7 +9389,7 @@ func (i *InformationProtectionPolicyProperties) UnmarshalJSON(data []byte) error // MarshalJSON implements the json.Marshaller interface for type InformationType. func (i InformationType) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "custom", i.Custom) populate(objectMap, "description", i.Description) populate(objectMap, "displayName", i.DisplayName) @@ -8521,7 +9440,7 @@ func (i *InformationType) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type IngestionConnectionString. func (i IngestionConnectionString) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "location", i.Location) populate(objectMap, "value", i.Value) return json.Marshal(objectMap) @@ -8552,7 +9471,7 @@ func (i *IngestionConnectionString) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type IngestionSetting. func (i IngestionSetting) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", i.ID) populate(objectMap, "name", i.Name) populate(objectMap, "properties", &i.Properties) @@ -8591,7 +9510,7 @@ func (i *IngestionSetting) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type IngestionSettingList. func (i IngestionSettingList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", i.NextLink) populate(objectMap, "value", i.Value) return json.Marshal(objectMap) @@ -8622,7 +9541,7 @@ func (i *IngestionSettingList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type IngestionSettingToken. func (i IngestionSettingToken) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "token", i.Token) return json.Marshal(objectMap) } @@ -8649,7 +9568,7 @@ func (i *IngestionSettingToken) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type IoTSecurityAggregatedAlert. func (i IoTSecurityAggregatedAlert) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", i.ID) populate(objectMap, "name", i.Name) populate(objectMap, "properties", i.Properties) @@ -8692,7 +9611,7 @@ func (i *IoTSecurityAggregatedAlert) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type IoTSecurityAggregatedAlertList. func (i IoTSecurityAggregatedAlertList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", i.NextLink) populate(objectMap, "value", i.Value) return json.Marshal(objectMap) @@ -8723,7 +9642,7 @@ func (i *IoTSecurityAggregatedAlertList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type IoTSecurityAggregatedAlertProperties. func (i IoTSecurityAggregatedAlertProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "actionTaken", i.ActionTaken) populateDateType(objectMap, "aggregatedDateUtc", i.AggregatedDateUTC) populate(objectMap, "alertDisplayName", i.AlertDisplayName) @@ -8798,7 +9717,7 @@ func (i *IoTSecurityAggregatedAlertProperties) UnmarshalJSON(data []byte) error // MarshalJSON implements the json.Marshaller interface for type IoTSecurityAggregatedAlertPropertiesTopDevicesListItem. func (i IoTSecurityAggregatedAlertPropertiesTopDevicesListItem) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "alertsCount", i.AlertsCount) populate(objectMap, "deviceId", i.DeviceID) populate(objectMap, "lastOccurrence", i.LastOccurrence) @@ -8833,7 +9752,7 @@ func (i *IoTSecurityAggregatedAlertPropertiesTopDevicesListItem) UnmarshalJSON(d // MarshalJSON implements the json.Marshaller interface for type IoTSecurityAggregatedRecommendation. func (i IoTSecurityAggregatedRecommendation) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", i.ID) populate(objectMap, "name", i.Name) populate(objectMap, "properties", i.Properties) @@ -8876,7 +9795,7 @@ func (i *IoTSecurityAggregatedRecommendation) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type IoTSecurityAggregatedRecommendationList. func (i IoTSecurityAggregatedRecommendationList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", i.NextLink) populate(objectMap, "value", i.Value) return json.Marshal(objectMap) @@ -8907,7 +9826,7 @@ func (i *IoTSecurityAggregatedRecommendationList) UnmarshalJSON(data []byte) err // MarshalJSON implements the json.Marshaller interface for type IoTSecurityAggregatedRecommendationProperties. func (i IoTSecurityAggregatedRecommendationProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "description", i.Description) populate(objectMap, "detectedBy", i.DetectedBy) populate(objectMap, "healthyDevices", i.HealthyDevices) @@ -8970,7 +9889,7 @@ func (i *IoTSecurityAggregatedRecommendationProperties) UnmarshalJSON(data []byt // MarshalJSON implements the json.Marshaller interface for type IoTSecurityAlertedDevice. func (i IoTSecurityAlertedDevice) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "alertsCount", i.AlertsCount) populate(objectMap, "deviceId", i.DeviceID) return json.Marshal(objectMap) @@ -9001,7 +9920,7 @@ func (i *IoTSecurityAlertedDevice) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type IoTSecurityDeviceAlert. func (i IoTSecurityDeviceAlert) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "alertDisplayName", i.AlertDisplayName) populate(objectMap, "alertsCount", i.AlertsCount) populate(objectMap, "reportedSeverity", i.ReportedSeverity) @@ -9036,7 +9955,7 @@ func (i *IoTSecurityDeviceAlert) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type IoTSecurityDeviceRecommendation. func (i IoTSecurityDeviceRecommendation) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "devicesCount", i.DevicesCount) populate(objectMap, "recommendationDisplayName", i.RecommendationDisplayName) populate(objectMap, "reportedSeverity", i.ReportedSeverity) @@ -9071,7 +9990,7 @@ func (i *IoTSecurityDeviceRecommendation) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type IoTSecuritySolutionAnalyticsModel. func (i IoTSecuritySolutionAnalyticsModel) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", i.ID) populate(objectMap, "name", i.Name) populate(objectMap, "properties", i.Properties) @@ -9110,7 +10029,7 @@ func (i *IoTSecuritySolutionAnalyticsModel) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type IoTSecuritySolutionAnalyticsModelList. func (i IoTSecuritySolutionAnalyticsModelList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", i.NextLink) populate(objectMap, "value", i.Value) return json.Marshal(objectMap) @@ -9141,7 +10060,7 @@ func (i *IoTSecuritySolutionAnalyticsModelList) UnmarshalJSON(data []byte) error // MarshalJSON implements the json.Marshaller interface for type IoTSecuritySolutionAnalyticsModelProperties. func (i IoTSecuritySolutionAnalyticsModelProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "devicesMetrics", i.DevicesMetrics) populate(objectMap, "metrics", i.Metrics) populate(objectMap, "mostPrevalentDeviceAlerts", i.MostPrevalentDeviceAlerts) @@ -9188,7 +10107,7 @@ func (i *IoTSecuritySolutionAnalyticsModelProperties) UnmarshalJSON(data []byte) // MarshalJSON implements the json.Marshaller interface for type IoTSecuritySolutionAnalyticsModelPropertiesDevicesMetricsItem. func (i IoTSecuritySolutionAnalyticsModelPropertiesDevicesMetricsItem) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populateTimeRFC3339(objectMap, "date", i.Date) populate(objectMap, "devicesMetrics", i.DevicesMetrics) return json.Marshal(objectMap) @@ -9219,7 +10138,7 @@ func (i *IoTSecuritySolutionAnalyticsModelPropertiesDevicesMetricsItem) Unmarsha // MarshalJSON implements the json.Marshaller interface for type IoTSecuritySolutionModel. func (i IoTSecuritySolutionModel) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", i.ID) populate(objectMap, "location", i.Location) populate(objectMap, "name", i.Name) @@ -9270,7 +10189,7 @@ func (i *IoTSecuritySolutionModel) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type IoTSecuritySolutionProperties. func (i IoTSecuritySolutionProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "additionalWorkspaces", i.AdditionalWorkspaces) populate(objectMap, "autoDiscoveredResources", i.AutoDiscoveredResources) populate(objectMap, "disabledDataSources", i.DisabledDataSources) @@ -9337,7 +10256,7 @@ func (i *IoTSecuritySolutionProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type IoTSecuritySolutionsList. func (i IoTSecuritySolutionsList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", i.NextLink) populate(objectMap, "value", i.Value) return json.Marshal(objectMap) @@ -9368,7 +10287,7 @@ func (i *IoTSecuritySolutionsList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type IoTSeverityMetrics. func (i IoTSeverityMetrics) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "high", i.High) populate(objectMap, "low", i.Low) populate(objectMap, "medium", i.Medium) @@ -9401,9 +10320,60 @@ func (i *IoTSeverityMetrics) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type Issue. +func (i Issue) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "issueAdditionalData", i.IssueAdditionalData) + populate(objectMap, "issueDescription", i.IssueDescription) + populate(objectMap, "issueKey", i.IssueKey) + populate(objectMap, "issueName", i.IssueName) + populate(objectMap, "remediationScript", i.RemediationScript) + populate(objectMap, "remediationSteps", i.RemediationSteps) + populate(objectMap, "securityValues", i.SecurityValues) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Issue. +func (i *Issue) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "issueAdditionalData": + err = unpopulate(val, "IssueAdditionalData", &i.IssueAdditionalData) + delete(rawMsg, key) + case "issueDescription": + err = unpopulate(val, "IssueDescription", &i.IssueDescription) + delete(rawMsg, key) + case "issueKey": + err = unpopulate(val, "IssueKey", &i.IssueKey) + delete(rawMsg, key) + case "issueName": + err = unpopulate(val, "IssueName", &i.IssueName) + delete(rawMsg, key) + case "remediationScript": + err = unpopulate(val, "RemediationScript", &i.RemediationScript) + delete(rawMsg, key) + case "remediationSteps": + err = unpopulate(val, "RemediationSteps", &i.RemediationSteps) + delete(rawMsg, key) + case "securityValues": + err = unpopulate(val, "SecurityValues", &i.SecurityValues) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type JitNetworkAccessPoliciesList. func (j JitNetworkAccessPoliciesList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", j.NextLink) populate(objectMap, "value", j.Value) return json.Marshal(objectMap) @@ -9434,7 +10404,7 @@ func (j *JitNetworkAccessPoliciesList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type JitNetworkAccessPolicy. func (j JitNetworkAccessPolicy) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", j.ID) populate(objectMap, "kind", j.Kind) populate(objectMap, "location", j.Location) @@ -9481,7 +10451,7 @@ func (j *JitNetworkAccessPolicy) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type JitNetworkAccessPolicyInitiatePort. func (j JitNetworkAccessPolicyInitiatePort) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "allowedSourceAddressPrefix", j.AllowedSourceAddressPrefix) populateTimeRFC3339(objectMap, "endTimeUtc", j.EndTimeUTC) populate(objectMap, "number", j.Number) @@ -9516,7 +10486,7 @@ func (j *JitNetworkAccessPolicyInitiatePort) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type JitNetworkAccessPolicyInitiateRequest. func (j JitNetworkAccessPolicyInitiateRequest) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "justification", j.Justification) populate(objectMap, "virtualMachines", j.VirtualMachines) return json.Marshal(objectMap) @@ -9547,7 +10517,7 @@ func (j *JitNetworkAccessPolicyInitiateRequest) UnmarshalJSON(data []byte) error // MarshalJSON implements the json.Marshaller interface for type JitNetworkAccessPolicyInitiateVirtualMachine. func (j JitNetworkAccessPolicyInitiateVirtualMachine) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", j.ID) populate(objectMap, "ports", j.Ports) return json.Marshal(objectMap) @@ -9578,7 +10548,7 @@ func (j *JitNetworkAccessPolicyInitiateVirtualMachine) UnmarshalJSON(data []byte // MarshalJSON implements the json.Marshaller interface for type JitNetworkAccessPolicyProperties. func (j JitNetworkAccessPolicyProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "provisioningState", j.ProvisioningState) populate(objectMap, "requests", j.Requests) populate(objectMap, "virtualMachines", j.VirtualMachines) @@ -9613,7 +10583,7 @@ func (j *JitNetworkAccessPolicyProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type JitNetworkAccessPolicyVirtualMachine. func (j JitNetworkAccessPolicyVirtualMachine) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", j.ID) populate(objectMap, "ports", j.Ports) populate(objectMap, "publicIpAddress", j.PublicIPAddress) @@ -9648,7 +10618,7 @@ func (j *JitNetworkAccessPolicyVirtualMachine) UnmarshalJSON(data []byte) error // MarshalJSON implements the json.Marshaller interface for type JitNetworkAccessPortRule. func (j JitNetworkAccessPortRule) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "allowedSourceAddressPrefix", j.AllowedSourceAddressPrefix) populate(objectMap, "allowedSourceAddressPrefixes", j.AllowedSourceAddressPrefixes) populate(objectMap, "maxRequestAccessDuration", j.MaxRequestAccessDuration) @@ -9691,7 +10661,7 @@ func (j *JitNetworkAccessPortRule) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type JitNetworkAccessRequest. func (j JitNetworkAccessRequest) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "justification", j.Justification) populate(objectMap, "requestor", j.Requestor) populateTimeRFC3339(objectMap, "startTimeUtc", j.StartTimeUTC) @@ -9730,7 +10700,7 @@ func (j *JitNetworkAccessRequest) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type JitNetworkAccessRequestPort. func (j JitNetworkAccessRequestPort) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "allowedSourceAddressPrefix", j.AllowedSourceAddressPrefix) populate(objectMap, "allowedSourceAddressPrefixes", j.AllowedSourceAddressPrefixes) populateTimeRFC3339(objectMap, "endTimeUtc", j.EndTimeUTC) @@ -9781,7 +10751,7 @@ func (j *JitNetworkAccessRequestPort) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type JitNetworkAccessRequestVirtualMachine. func (j JitNetworkAccessRequestVirtualMachine) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", j.ID) populate(objectMap, "ports", j.Ports) return json.Marshal(objectMap) @@ -9812,7 +10782,7 @@ func (j *JitNetworkAccessRequestVirtualMachine) UnmarshalJSON(data []byte) error // MarshalJSON implements the json.Marshaller interface for type KindAutoGenerated. func (k KindAutoGenerated) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "kind", k.Kind) return json.Marshal(objectMap) } @@ -9839,7 +10809,7 @@ func (k *KindAutoGenerated) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ListCustomAlertRule. func (l ListCustomAlertRule) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "description", l.Description) populate(objectMap, "displayName", l.DisplayName) populate(objectMap, "isEnabled", l.IsEnabled) @@ -9882,7 +10852,7 @@ func (l *ListCustomAlertRule) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type LocalUserNotAllowed. func (l LocalUserNotAllowed) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "allowlistValues", l.AllowlistValues) populate(objectMap, "description", l.Description) populate(objectMap, "displayName", l.DisplayName) @@ -9929,7 +10899,7 @@ func (l *LocalUserNotAllowed) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Location. func (l Location) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "location", l.Location) return json.Marshal(objectMap) } @@ -9956,7 +10926,7 @@ func (l *Location) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type LogAnalyticsIdentifier. func (l LogAnalyticsIdentifier) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "agentId", l.AgentID) objectMap["type"] = ResourceIdentifierTypeLogAnalytics populate(objectMap, "workspaceId", l.WorkspaceID) @@ -9999,7 +10969,7 @@ func (l *LogAnalyticsIdentifier) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type MdeOnboardingData. func (m MdeOnboardingData) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", m.ID) populate(objectMap, "name", m.Name) populate(objectMap, "properties", m.Properties) @@ -10038,7 +11008,7 @@ func (m *MdeOnboardingData) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type MdeOnboardingDataList. func (m MdeOnboardingDataList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "value", m.Value) return json.Marshal(objectMap) } @@ -10065,7 +11035,7 @@ func (m *MdeOnboardingDataList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type MdeOnboardingDataProperties. func (m MdeOnboardingDataProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populateByteArray(objectMap, "onboardingPackageLinux", m.OnboardingPackageLinux, runtime.Base64StdFormat) populateByteArray(objectMap, "onboardingPackageWindows", m.OnboardingPackageWindows, runtime.Base64StdFormat) return json.Marshal(objectMap) @@ -10096,7 +11066,7 @@ func (m *MdeOnboardingDataProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type MqttC2DMessagesNotInAllowedRange. func (m MqttC2DMessagesNotInAllowedRange) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "description", m.Description) populate(objectMap, "displayName", m.DisplayName) populate(objectMap, "isEnabled", m.IsEnabled) @@ -10147,7 +11117,7 @@ func (m *MqttC2DMessagesNotInAllowedRange) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type MqttC2DRejectedMessagesNotInAllowedRange. func (m MqttC2DRejectedMessagesNotInAllowedRange) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "description", m.Description) populate(objectMap, "displayName", m.DisplayName) populate(objectMap, "isEnabled", m.IsEnabled) @@ -10198,7 +11168,7 @@ func (m *MqttC2DRejectedMessagesNotInAllowedRange) UnmarshalJSON(data []byte) er // MarshalJSON implements the json.Marshaller interface for type MqttD2CMessagesNotInAllowedRange. func (m MqttD2CMessagesNotInAllowedRange) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "description", m.Description) populate(objectMap, "displayName", m.DisplayName) populate(objectMap, "isEnabled", m.IsEnabled) @@ -10249,7 +11219,7 @@ func (m *MqttD2CMessagesNotInAllowedRange) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type OnPremiseResourceDetails. func (o OnPremiseResourceDetails) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "machineName", o.MachineName) objectMap["source"] = SourceOnPremise populate(objectMap, "sourceComputerId", o.SourceComputerID) @@ -10292,7 +11262,7 @@ func (o *OnPremiseResourceDetails) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type OnPremiseSQLResourceDetails. func (o OnPremiseSQLResourceDetails) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "databaseName", o.DatabaseName) populate(objectMap, "machineName", o.MachineName) populate(objectMap, "serverName", o.ServerName) @@ -10343,7 +11313,7 @@ func (o *OnPremiseSQLResourceDetails) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Operation. func (o Operation) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "display", o.Display) populate(objectMap, "name", o.Name) populate(objectMap, "origin", o.Origin) @@ -10378,7 +11348,7 @@ func (o *Operation) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type OperationDisplay. func (o OperationDisplay) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "description", o.Description) populate(objectMap, "operation", o.Operation) populate(objectMap, "provider", o.Provider) @@ -10417,7 +11387,7 @@ func (o *OperationDisplay) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type OperationList. func (o OperationList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", o.NextLink) populate(objectMap, "value", o.Value) return json.Marshal(objectMap) @@ -10446,9 +11416,67 @@ func (o *OperationList) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type OperationResultAutoGenerated. +func (o OperationResultAutoGenerated) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "status", o.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationResultAutoGenerated. +func (o *OperationResultAutoGenerated) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "status": + err = unpopulate(val, "Status", &o.Status) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationStatus. +func (o OperationStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "code", o.Code) + populate(objectMap, "message", o.Message) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationStatus. +func (o *OperationStatus) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "code": + err = unpopulate(val, "Code", &o.Code) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &o.Message) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type PathRecommendation. func (p PathRecommendation) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "action", p.Action) populate(objectMap, "common", p.Common) populate(objectMap, "configurationStatus", p.ConfigurationStatus) @@ -10507,7 +11535,7 @@ func (p *PathRecommendation) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Pricing. func (p Pricing) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", p.ID) populate(objectMap, "name", p.Name) populate(objectMap, "properties", p.Properties) @@ -10546,7 +11574,7 @@ func (p *Pricing) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PricingList. func (p PricingList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "value", p.Value) return json.Marshal(objectMap) } @@ -10573,8 +11601,10 @@ func (p *PricingList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PricingProperties. func (p PricingProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "deprecated", p.Deprecated) + populateTimeRFC3339(objectMap, "enablementTime", p.EnablementTime) + populate(objectMap, "extensions", p.Extensions) populate(objectMap, "freeTrialRemainingTime", p.FreeTrialRemainingTime) populate(objectMap, "pricingTier", p.PricingTier) populate(objectMap, "replacedBy", p.ReplacedBy) @@ -10594,6 +11624,12 @@ func (p *PricingProperties) UnmarshalJSON(data []byte) error { case "deprecated": err = unpopulate(val, "Deprecated", &p.Deprecated) delete(rawMsg, key) + case "enablementTime": + err = unpopulateTimeRFC3339(val, "EnablementTime", &p.EnablementTime) + delete(rawMsg, key) + case "extensions": + err = unpopulate(val, "Extensions", &p.Extensions) + delete(rawMsg, key) case "freeTrialRemainingTime": err = unpopulate(val, "FreeTrialRemainingTime", &p.FreeTrialRemainingTime) delete(rawMsg, key) @@ -10616,7 +11652,7 @@ func (p *PricingProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ProcessNotAllowed. func (p ProcessNotAllowed) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "allowlistValues", p.AllowlistValues) populate(objectMap, "description", p.Description) populate(objectMap, "displayName", p.DisplayName) @@ -10663,7 +11699,7 @@ func (p *ProcessNotAllowed) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ProtectionMode. func (p ProtectionMode) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "exe", p.Exe) populate(objectMap, "executable", p.Executable) populate(objectMap, "msi", p.Msi) @@ -10702,7 +11738,7 @@ func (p *ProtectionMode) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ProxyServerProperties. func (p ProxyServerProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "ip", p.IP) populate(objectMap, "port", p.Port) return json.Marshal(objectMap) @@ -10733,7 +11769,7 @@ func (p *ProxyServerProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PublisherInfo. func (p PublisherInfo) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "binaryName", p.BinaryName) populate(objectMap, "productName", p.ProductName) populate(objectMap, "publisherName", p.PublisherName) @@ -10772,7 +11808,7 @@ func (p *PublisherInfo) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type QueryCheck. func (q QueryCheck) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "columnNames", q.ColumnNames) populate(objectMap, "expectedResult", q.ExpectedResult) populate(objectMap, "query", q.Query) @@ -10807,7 +11843,7 @@ func (q *QueryCheck) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type QueuePurgesNotInAllowedRange. func (q QueuePurgesNotInAllowedRange) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "description", q.Description) populate(objectMap, "displayName", q.DisplayName) populate(objectMap, "isEnabled", q.IsEnabled) @@ -10858,7 +11894,7 @@ func (q *QueuePurgesNotInAllowedRange) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type RecommendationConfigurationProperties. func (r RecommendationConfigurationProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "name", r.Name) populate(objectMap, "recommendationType", r.RecommendationType) populate(objectMap, "status", r.Status) @@ -10893,7 +11929,7 @@ func (r *RecommendationConfigurationProperties) UnmarshalJSON(data []byte) error // MarshalJSON implements the json.Marshaller interface for type RegulatoryComplianceAssessment. func (r RegulatoryComplianceAssessment) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", r.ID) populate(objectMap, "name", r.Name) populate(objectMap, "properties", r.Properties) @@ -10932,7 +11968,7 @@ func (r *RegulatoryComplianceAssessment) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type RegulatoryComplianceAssessmentList. func (r RegulatoryComplianceAssessmentList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", r.NextLink) populate(objectMap, "value", r.Value) return json.Marshal(objectMap) @@ -10963,7 +11999,7 @@ func (r *RegulatoryComplianceAssessmentList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type RegulatoryComplianceAssessmentProperties. func (r RegulatoryComplianceAssessmentProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "assessmentDetailsLink", r.AssessmentDetailsLink) populate(objectMap, "assessmentType", r.AssessmentType) populate(objectMap, "description", r.Description) @@ -11018,7 +12054,7 @@ func (r *RegulatoryComplianceAssessmentProperties) UnmarshalJSON(data []byte) er // MarshalJSON implements the json.Marshaller interface for type RegulatoryComplianceControl. func (r RegulatoryComplianceControl) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", r.ID) populate(objectMap, "name", r.Name) populate(objectMap, "properties", r.Properties) @@ -11057,7 +12093,7 @@ func (r *RegulatoryComplianceControl) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type RegulatoryComplianceControlList. func (r RegulatoryComplianceControlList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", r.NextLink) populate(objectMap, "value", r.Value) return json.Marshal(objectMap) @@ -11088,7 +12124,7 @@ func (r *RegulatoryComplianceControlList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type RegulatoryComplianceControlProperties. func (r RegulatoryComplianceControlProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "description", r.Description) populate(objectMap, "failedAssessments", r.FailedAssessments) populate(objectMap, "passedAssessments", r.PassedAssessments) @@ -11131,7 +12167,7 @@ func (r *RegulatoryComplianceControlProperties) UnmarshalJSON(data []byte) error // MarshalJSON implements the json.Marshaller interface for type RegulatoryComplianceStandard. func (r RegulatoryComplianceStandard) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", r.ID) populate(objectMap, "name", r.Name) populate(objectMap, "properties", r.Properties) @@ -11170,7 +12206,7 @@ func (r *RegulatoryComplianceStandard) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type RegulatoryComplianceStandardList. func (r RegulatoryComplianceStandardList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", r.NextLink) populate(objectMap, "value", r.Value) return json.Marshal(objectMap) @@ -11201,7 +12237,7 @@ func (r *RegulatoryComplianceStandardList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type RegulatoryComplianceStandardProperties. func (r RegulatoryComplianceStandardProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "failedControls", r.FailedControls) populate(objectMap, "passedControls", r.PassedControls) populate(objectMap, "skippedControls", r.SkippedControls) @@ -11244,7 +12280,7 @@ func (r *RegulatoryComplianceStandardProperties) UnmarshalJSON(data []byte) erro // MarshalJSON implements the json.Marshaller interface for type Remediation. func (r Remediation) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "automated", r.Automated) populate(objectMap, "description", r.Description) populate(objectMap, "portalLink", r.PortalLink) @@ -11283,7 +12319,7 @@ func (r *Remediation) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type RemediationEta. func (r RemediationEta) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populateTimeRFC3339(objectMap, "eta", r.Eta) populate(objectMap, "justification", r.Justification) return json.Marshal(objectMap) @@ -11314,7 +12350,7 @@ func (r *RemediationEta) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Resource. func (r Resource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", r.ID) populate(objectMap, "name", r.Name) populate(objectMap, "type", r.Type) @@ -11349,7 +12385,7 @@ func (r *Resource) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ResourceDetails. func (r ResourceDetails) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["source"] = r.Source return json.Marshal(objectMap) } @@ -11374,9 +12410,44 @@ func (r *ResourceDetails) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type ResourceDetailsAutoGenerated. +func (r ResourceDetailsAutoGenerated) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "connectorId", r.ConnectorID) + populate(objectMap, "id", r.ID) + populate(objectMap, "source", r.Source) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceDetailsAutoGenerated. +func (r *ResourceDetailsAutoGenerated) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "connectorId": + err = unpopulate(val, "ConnectorID", &r.ConnectorID) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &r.ID) + delete(rawMsg, key) + case "source": + err = unpopulate(val, "Source", &r.Source) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type ResourceIdentifier. func (r ResourceIdentifier) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["type"] = r.Type return json.Marshal(objectMap) } @@ -11403,7 +12474,7 @@ func (r *ResourceIdentifier) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Rule. func (r Rule) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "destinationPort", r.DestinationPort) populate(objectMap, "direction", r.Direction) populate(objectMap, "ipAddresses", r.IPAddresses) @@ -11446,7 +12517,7 @@ func (r *Rule) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type RuleResults. func (r RuleResults) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", r.ID) populate(objectMap, "name", r.Name) populate(objectMap, "properties", r.Properties) @@ -11485,7 +12556,7 @@ func (r *RuleResults) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type RuleResultsInput. func (r RuleResultsInput) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "latestScan", r.LatestScan) populate(objectMap, "results", r.Results) return json.Marshal(objectMap) @@ -11516,7 +12587,7 @@ func (r *RuleResultsInput) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type RuleResultsProperties. func (r RuleResultsProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "results", r.Results) return json.Marshal(objectMap) } @@ -11543,7 +12614,7 @@ func (r *RuleResultsProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type RulesResults. func (r RulesResults) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "value", r.Value) return json.Marshal(objectMap) } @@ -11570,7 +12641,7 @@ func (r *RulesResults) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type RulesResultsInput. func (r RulesResultsInput) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "latestScan", r.LatestScan) populate(objectMap, "results", r.Results) return json.Marshal(objectMap) @@ -11601,7 +12672,7 @@ func (r *RulesResultsInput) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SQLServerVulnerabilityProperties. func (s SQLServerVulnerabilityProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["assessedResourceType"] = AssessedResourceTypeSQLServerVulnerability populate(objectMap, "query", s.Query) populate(objectMap, "type", s.Type) @@ -11636,7 +12707,7 @@ func (s *SQLServerVulnerabilityProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Scan. func (s Scan) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", s.ID) populate(objectMap, "name", s.Name) populate(objectMap, "properties", s.Properties) @@ -11675,11 +12746,12 @@ func (s *Scan) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ScanProperties. func (s ScanProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "database", s.Database) populateTimeRFC3339(objectMap, "endTime", s.EndTime) populate(objectMap, "highSeverityFailedRulesCount", s.HighSeverityFailedRulesCount) populate(objectMap, "isBaselineApplied", s.IsBaselineApplied) + populateTimeRFC3339(objectMap, "lastScanTime", s.LastScanTime) populate(objectMap, "lowSeverityFailedRulesCount", s.LowSeverityFailedRulesCount) populate(objectMap, "mediumSeverityFailedRulesCount", s.MediumSeverityFailedRulesCount) populate(objectMap, "sqlVersion", s.SQLVersion) @@ -11714,6 +12786,9 @@ func (s *ScanProperties) UnmarshalJSON(data []byte) error { case "isBaselineApplied": err = unpopulate(val, "IsBaselineApplied", &s.IsBaselineApplied) delete(rawMsg, key) + case "lastScanTime": + err = unpopulateTimeRFC3339(val, "LastScanTime", &s.LastScanTime) + delete(rawMsg, key) case "lowSeverityFailedRulesCount": err = unpopulate(val, "LowSeverityFailedRulesCount", &s.LowSeverityFailedRulesCount) delete(rawMsg, key) @@ -11754,7 +12829,7 @@ func (s *ScanProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ScanResult. func (s ScanResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", s.ID) populate(objectMap, "name", s.Name) populate(objectMap, "properties", s.Properties) @@ -11793,7 +12868,7 @@ func (s *ScanResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ScanResultProperties. func (s ScanResultProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "baselineAdjustedResult", s.BaselineAdjustedResult) populate(objectMap, "isTrimmed", s.IsTrimmed) populate(objectMap, "queryResults", s.QueryResults) @@ -11844,7 +12919,7 @@ func (s *ScanResultProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ScanResults. func (s ScanResults) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "value", s.Value) return json.Marshal(objectMap) } @@ -11871,7 +12946,7 @@ func (s *ScanResults) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Scans. func (s Scans) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "value", s.Value) return json.Marshal(objectMap) } @@ -11898,7 +12973,7 @@ func (s *Scans) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ScopeElement. func (s ScopeElement) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "field", s.Field) if s.AdditionalProperties != nil { for key, val := range s.AdditionalProperties { @@ -11922,10 +12997,10 @@ func (s *ScopeElement) UnmarshalJSON(data []byte) error { delete(rawMsg, key) default: if s.AdditionalProperties == nil { - s.AdditionalProperties = map[string]interface{}{} + s.AdditionalProperties = map[string]any{} } if val != nil { - var aux interface{} + var aux any err = json.Unmarshal(val, &aux) s.AdditionalProperties[key] = aux } @@ -11940,7 +13015,7 @@ func (s *ScopeElement) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ScoreDetails. func (s ScoreDetails) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "current", s.Current) populate(objectMap, "max", s.Max) populate(objectMap, "percentage", s.Percentage) @@ -11975,7 +13050,7 @@ func (s *ScoreDetails) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SecureScoreControlDefinitionItem. func (s SecureScoreControlDefinitionItem) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", s.ID) populate(objectMap, "name", s.Name) populate(objectMap, "properties", s.Properties) @@ -12014,7 +13089,7 @@ func (s *SecureScoreControlDefinitionItem) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SecureScoreControlDefinitionItemProperties. func (s SecureScoreControlDefinitionItemProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "assessmentDefinitions", s.AssessmentDefinitions) populate(objectMap, "description", s.Description) populate(objectMap, "displayName", s.DisplayName) @@ -12057,7 +13132,7 @@ func (s *SecureScoreControlDefinitionItemProperties) UnmarshalJSON(data []byte) // MarshalJSON implements the json.Marshaller interface for type SecureScoreControlDefinitionList. func (s SecureScoreControlDefinitionList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", s.NextLink) populate(objectMap, "value", s.Value) return json.Marshal(objectMap) @@ -12088,7 +13163,7 @@ func (s *SecureScoreControlDefinitionList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SecureScoreControlDefinitionSource. func (s SecureScoreControlDefinitionSource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "sourceType", s.SourceType) return json.Marshal(objectMap) } @@ -12115,7 +13190,7 @@ func (s *SecureScoreControlDefinitionSource) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SecureScoreControlDetails. func (s SecureScoreControlDetails) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", s.ID) populate(objectMap, "name", s.Name) populate(objectMap, "properties", s.Properties) @@ -12154,7 +13229,7 @@ func (s *SecureScoreControlDetails) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SecureScoreControlList. func (s SecureScoreControlList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", s.NextLink) populate(objectMap, "value", s.Value) return json.Marshal(objectMap) @@ -12185,7 +13260,7 @@ func (s *SecureScoreControlList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SecureScoreControlScore. func (s SecureScoreControlScore) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "current", s.Current) populate(objectMap, "max", s.Max) populate(objectMap, "percentage", s.Percentage) @@ -12220,7 +13295,7 @@ func (s *SecureScoreControlScore) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SecureScoreControlScoreDetails. func (s SecureScoreControlScoreDetails) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "definition", s.Definition) populate(objectMap, "displayName", s.DisplayName) populate(objectMap, "healthyResourceCount", s.HealthyResourceCount) @@ -12271,7 +13346,7 @@ func (s *SecureScoreControlScoreDetails) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SecureScoreItem. func (s SecureScoreItem) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", s.ID) populate(objectMap, "name", s.Name) populate(objectMap, "properties", s.Properties) @@ -12310,7 +13385,7 @@ func (s *SecureScoreItem) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SecureScoreItemProperties. func (s SecureScoreItemProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "displayName", s.DisplayName) populate(objectMap, "score", s.Score) populate(objectMap, "weight", s.Weight) @@ -12345,7 +13420,7 @@ func (s *SecureScoreItemProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SecureScoresList. func (s SecureScoresList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", s.NextLink) populate(objectMap, "value", s.Value) return json.Marshal(objectMap) @@ -12376,7 +13451,7 @@ func (s *SecureScoresList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SensitivityLabel. func (s SensitivityLabel) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "description", s.Description) populate(objectMap, "displayName", s.DisplayName) populate(objectMap, "enabled", s.Enabled) @@ -12419,7 +13494,7 @@ func (s *SensitivityLabel) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ServerVulnerabilityAssessment. func (s ServerVulnerabilityAssessment) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", s.ID) populate(objectMap, "name", s.Name) populate(objectMap, "properties", s.Properties) @@ -12458,7 +13533,7 @@ func (s *ServerVulnerabilityAssessment) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ServerVulnerabilityAssessmentProperties. func (s ServerVulnerabilityAssessmentProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "provisioningState", s.ProvisioningState) return json.Marshal(objectMap) } @@ -12485,7 +13560,7 @@ func (s *ServerVulnerabilityAssessmentProperties) UnmarshalJSON(data []byte) err // MarshalJSON implements the json.Marshaller interface for type ServerVulnerabilityAssessmentsList. func (s ServerVulnerabilityAssessmentsList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "value", s.Value) return json.Marshal(objectMap) } @@ -12512,7 +13587,7 @@ func (s *ServerVulnerabilityAssessmentsList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ServerVulnerabilityProperties. func (s ServerVulnerabilityProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["assessedResourceType"] = "ServerVulnerabilityAssessment" populate(objectMap, "cve", s.Cve) populate(objectMap, "cvss", s.Cvss) @@ -12567,7 +13642,7 @@ func (s *ServerVulnerabilityProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ServicePrincipalProperties. func (s ServicePrincipalProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "applicationId", s.ApplicationID) populate(objectMap, "secret", s.Secret) return json.Marshal(objectMap) @@ -12598,7 +13673,7 @@ func (s *ServicePrincipalProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Setting. func (s Setting) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", s.ID) objectMap["kind"] = s.Kind populate(objectMap, "name", s.Name) @@ -12637,7 +13712,7 @@ func (s *Setting) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SettingsList. func (s SettingsList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", s.NextLink) populate(objectMap, "value", s.Value) return json.Marshal(objectMap) @@ -12668,7 +13743,7 @@ func (s *SettingsList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Software. func (s Software) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", s.ID) populate(objectMap, "name", s.Name) populate(objectMap, "properties", s.Properties) @@ -12707,7 +13782,7 @@ func (s *Software) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SoftwareProperties. func (s SoftwareProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "deviceId", s.DeviceID) populate(objectMap, "endOfSupportDate", s.EndOfSupportDate) populate(objectMap, "endOfSupportStatus", s.EndOfSupportStatus) @@ -12766,7 +13841,7 @@ func (s *SoftwareProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SoftwaresList. func (s SoftwaresList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", s.NextLink) populate(objectMap, "value", s.Value) return json.Marshal(objectMap) @@ -12797,7 +13872,7 @@ func (s *SoftwaresList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Solution. func (s Solution) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", s.ID) populate(objectMap, "location", s.Location) populate(objectMap, "name", s.Name) @@ -12840,7 +13915,7 @@ func (s *Solution) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SolutionList. func (s SolutionList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", s.NextLink) populate(objectMap, "value", s.Value) return json.Marshal(objectMap) @@ -12871,7 +13946,7 @@ func (s *SolutionList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SolutionProperties. func (s SolutionProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "protectionStatus", s.ProtectionStatus) populate(objectMap, "provisioningState", s.ProvisioningState) populate(objectMap, "securityFamily", s.SecurityFamily) @@ -12910,7 +13985,7 @@ func (s *SolutionProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SolutionsReferenceData. func (s SolutionsReferenceData) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", s.ID) populate(objectMap, "location", s.Location) populate(objectMap, "name", s.Name) @@ -12953,7 +14028,7 @@ func (s *SolutionsReferenceData) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SolutionsReferenceDataList. func (s SolutionsReferenceDataList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "value", s.Value) return json.Marshal(objectMap) } @@ -12980,7 +14055,7 @@ func (s *SolutionsReferenceDataList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SolutionsReferenceDataProperties. func (s SolutionsReferenceDataProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "alertVendorName", s.AlertVendorName) populate(objectMap, "packageInfoUrl", s.PackageInfoURL) populate(objectMap, "productName", s.ProductName) @@ -13029,9 +14104,44 @@ func (s *SolutionsReferenceDataProperties) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type StatusAutoGenerated. +func (s StatusAutoGenerated) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "code", s.Code) + populateTimeRFC3339(objectMap, "firstEvaluationDate", s.FirstEvaluationDate) + populateTimeRFC3339(objectMap, "statusChangeDate", s.StatusChangeDate) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StatusAutoGenerated. +func (s *StatusAutoGenerated) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "code": + err = unpopulate(val, "Code", &s.Code) + delete(rawMsg, key) + case "firstEvaluationDate": + err = unpopulateTimeRFC3339(val, "FirstEvaluationDate", &s.FirstEvaluationDate) + delete(rawMsg, key) + case "statusChangeDate": + err = unpopulateTimeRFC3339(val, "StatusChangeDate", &s.StatusChangeDate) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type SubAssessment. func (s SubAssessment) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", s.ID) populate(objectMap, "name", s.Name) populate(objectMap, "properties", s.Properties) @@ -13070,7 +14180,7 @@ func (s *SubAssessment) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SubAssessmentList. func (s SubAssessmentList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", s.NextLink) populate(objectMap, "value", s.Value) return json.Marshal(objectMap) @@ -13101,7 +14211,7 @@ func (s *SubAssessmentList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SubAssessmentProperties. func (s SubAssessmentProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "additionalData", s.AdditionalData) populate(objectMap, "category", s.Category) populate(objectMap, "description", s.Description) @@ -13164,7 +14274,7 @@ func (s *SubAssessmentProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SubAssessmentStatus. func (s SubAssessmentStatus) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "cause", s.Cause) populate(objectMap, "code", s.Code) populate(objectMap, "description", s.Description) @@ -13203,7 +14313,7 @@ func (s *SubAssessmentStatus) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SuppressionAlertsScope. func (s SuppressionAlertsScope) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "allOf", s.AllOf) return json.Marshal(objectMap) } @@ -13230,7 +14340,7 @@ func (s *SuppressionAlertsScope) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SystemData. func (s SystemData) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) populate(objectMap, "createdBy", s.CreatedBy) populate(objectMap, "createdByType", s.CreatedByType) @@ -13277,7 +14387,7 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Tags. func (t Tags) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "tags", t.Tags) return json.Marshal(objectMap) } @@ -13304,7 +14414,7 @@ func (t *Tags) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type TagsResource. func (t TagsResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "tags", t.Tags) return json.Marshal(objectMap) } @@ -13331,7 +14441,7 @@ func (t *TagsResource) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Task. func (t Task) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", t.ID) populate(objectMap, "name", t.Name) populate(objectMap, "properties", t.Properties) @@ -13370,7 +14480,7 @@ func (t *Task) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type TaskList. func (t TaskList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", t.NextLink) populate(objectMap, "value", t.Value) return json.Marshal(objectMap) @@ -13401,7 +14511,7 @@ func (t *TaskList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type TaskParameters. func (t TaskParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "name", t.Name) if t.AdditionalProperties != nil { for key, val := range t.AdditionalProperties { @@ -13425,10 +14535,10 @@ func (t *TaskParameters) UnmarshalJSON(data []byte) error { delete(rawMsg, key) default: if t.AdditionalProperties == nil { - t.AdditionalProperties = map[string]interface{}{} + t.AdditionalProperties = map[string]any{} } if val != nil { - var aux interface{} + var aux any err = json.Unmarshal(val, &aux) t.AdditionalProperties[key] = aux } @@ -13443,7 +14553,7 @@ func (t *TaskParameters) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type TaskProperties. func (t TaskProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populateTimeRFC3339(objectMap, "creationTimeUtc", t.CreationTimeUTC) populateTimeRFC3339(objectMap, "lastStateChangeTimeUtc", t.LastStateChangeTimeUTC) populate(objectMap, "securityTaskParameters", t.SecurityTaskParameters) @@ -13486,7 +14596,7 @@ func (t *TaskProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ThresholdCustomAlertRule. func (t ThresholdCustomAlertRule) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "description", t.Description) populate(objectMap, "displayName", t.DisplayName) populate(objectMap, "isEnabled", t.IsEnabled) @@ -13533,7 +14643,7 @@ func (t *ThresholdCustomAlertRule) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type TimeWindowCustomAlertRule. func (t TimeWindowCustomAlertRule) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "description", t.Description) populate(objectMap, "displayName", t.DisplayName) populate(objectMap, "isEnabled", t.IsEnabled) @@ -13584,7 +14694,7 @@ func (t *TimeWindowCustomAlertRule) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type TopologyList. func (t TopologyList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", t.NextLink) populate(objectMap, "value", t.Value) return json.Marshal(objectMap) @@ -13615,7 +14725,7 @@ func (t *TopologyList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type TopologyResource. func (t TopologyResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", t.ID) populate(objectMap, "location", t.Location) populate(objectMap, "name", t.Name) @@ -13658,7 +14768,7 @@ func (t *TopologyResource) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type TopologyResourceProperties. func (t TopologyResourceProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populateTimeRFC3339(objectMap, "calculatedDateTime", t.CalculatedDateTime) populate(objectMap, "topologyResources", t.TopologyResources) return json.Marshal(objectMap) @@ -13689,7 +14799,7 @@ func (t *TopologyResourceProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type TopologySingleResource. func (t TopologySingleResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "children", t.Children) populate(objectMap, "location", t.Location) populate(objectMap, "networkZones", t.NetworkZones) @@ -13744,7 +14854,7 @@ func (t *TopologySingleResource) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type TopologySingleResourceChild. func (t TopologySingleResourceChild) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "resourceId", t.ResourceID) return json.Marshal(objectMap) } @@ -13771,7 +14881,7 @@ func (t *TopologySingleResourceChild) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type TopologySingleResourceParent. func (t TopologySingleResourceParent) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "resourceId", t.ResourceID) return json.Marshal(objectMap) } @@ -13798,7 +14908,7 @@ func (t *TopologySingleResourceParent) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type TrackedResource. func (t TrackedResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "etag", t.Etag) populate(objectMap, "id", t.ID) populate(objectMap, "kind", t.Kind) @@ -13849,7 +14959,7 @@ func (t *TrackedResource) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type TwinUpdatesNotInAllowedRange. func (t TwinUpdatesNotInAllowedRange) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "description", t.Description) populate(objectMap, "displayName", t.DisplayName) populate(objectMap, "isEnabled", t.IsEnabled) @@ -13900,7 +15010,7 @@ func (t *TwinUpdatesNotInAllowedRange) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type UnauthorizedOperationsNotInAllowedRange. func (u UnauthorizedOperationsNotInAllowedRange) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "description", u.Description) populate(objectMap, "displayName", u.DisplayName) populate(objectMap, "isEnabled", u.IsEnabled) @@ -13951,7 +15061,7 @@ func (u *UnauthorizedOperationsNotInAllowedRange) UnmarshalJSON(data []byte) err // MarshalJSON implements the json.Marshaller interface for type UpdateIoTSecuritySolutionProperties. func (u UpdateIoTSecuritySolutionProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "recommendationsConfiguration", u.RecommendationsConfiguration) populate(objectMap, "userDefinedResources", u.UserDefinedResources) return json.Marshal(objectMap) @@ -13982,7 +15092,7 @@ func (u *UpdateIoTSecuritySolutionProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type UpdateIotSecuritySolutionData. func (u UpdateIotSecuritySolutionData) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "properties", u.Properties) populate(objectMap, "tags", u.Tags) return json.Marshal(objectMap) @@ -14013,7 +15123,7 @@ func (u *UpdateIotSecuritySolutionData) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type UserDefinedResourcesProperties. func (u UserDefinedResourcesProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "query", u.Query) populate(objectMap, "querySubscriptions", u.QuerySubscriptions) return json.Marshal(objectMap) @@ -14044,7 +15154,7 @@ func (u *UserDefinedResourcesProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type UserRecommendation. func (u UserRecommendation) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "recommendationAction", u.RecommendationAction) populate(objectMap, "username", u.Username) return json.Marshal(objectMap) @@ -14075,7 +15185,7 @@ func (u *UserRecommendation) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type VMRecommendation. func (v VMRecommendation) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "configurationStatus", v.ConfigurationStatus) populate(objectMap, "enforcementSupport", v.EnforcementSupport) populate(objectMap, "recommendationAction", v.RecommendationAction) @@ -14114,7 +15224,7 @@ func (v *VMRecommendation) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type VaRule. func (v VaRule) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "benchmarkReferences", v.BenchmarkReferences) populate(objectMap, "category", v.Category) populate(objectMap, "description", v.Description) @@ -14173,7 +15283,7 @@ func (v *VaRule) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type VendorReference. func (v VendorReference) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "link", v.Link) populate(objectMap, "title", v.Title) return json.Marshal(objectMap) @@ -14204,7 +15314,7 @@ func (v *VendorReference) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type WorkspaceSetting. func (w WorkspaceSetting) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", w.ID) populate(objectMap, "name", w.Name) populate(objectMap, "properties", w.Properties) @@ -14243,7 +15353,7 @@ func (w *WorkspaceSetting) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type WorkspaceSettingList. func (w WorkspaceSettingList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", w.NextLink) populate(objectMap, "value", w.Value) return json.Marshal(objectMap) @@ -14274,7 +15384,7 @@ func (w *WorkspaceSettingList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type WorkspaceSettingProperties. func (w WorkspaceSettingProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "scope", w.Scope) populate(objectMap, "workspaceId", w.WorkspaceID) return json.Marshal(objectMap) @@ -14303,7 +15413,7 @@ func (w *WorkspaceSettingProperties) UnmarshalJSON(data []byte) error { return nil } -func populate(m map[string]interface{}, k string, v interface{}) { +func populate(m map[string]any, k string, v any) { if v == nil { return } else if azcore.IsNullValue(v) { @@ -14313,7 +15423,7 @@ func populate(m map[string]interface{}, k string, v interface{}) { } } -func populateByteArray(m map[string]interface{}, k string, b []byte, f runtime.Base64Encoding) { +func populateByteArray(m map[string]any, k string, b []byte, f runtime.Base64Encoding) { if azcore.IsNullValue(b) { m[k] = nil } else if len(b) == 0 { @@ -14323,7 +15433,7 @@ func populateByteArray(m map[string]interface{}, k string, b []byte, f runtime.B } } -func unpopulate(data json.RawMessage, fn string, v interface{}) error { +func unpopulate(data json.RawMessage, fn string, v any) error { if data == nil { return nil } diff --git a/sdk/resourcemanager/security/armsecurity/operations_client.go b/sdk/resourcemanager/security/armsecurity/operations_client.go index 08143882dd00..e1a589d2c1d5 100644 --- a/sdk/resourcemanager/security/armsecurity/operations_client.go +++ b/sdk/resourcemanager/security/armsecurity/operations_client.go @@ -13,8 +13,6 @@ import ( "context" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -23,35 +21,27 @@ import ( // OperationsClient contains the methods for the Operations group. // Don't use this type directly, use NewOperationsClient() instead. type OperationsClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewOperationsClient creates a new instance of OperationsClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".OperationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &OperationsClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListPager - Exposes all available operations for discovery purposes. +// // Generated from API version 2015-06-01-preview -// options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[OperationsClientListResponse]{ More: func(page OperationsClientListResponse) bool { @@ -68,7 +58,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption if err != nil { return OperationsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return OperationsClientListResponse{}, err } @@ -83,7 +73,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption // listCreateRequest creates the List request. func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Security/operations" - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/security/armsecurity/polymorphic_helpers.go b/sdk/resourcemanager/security/armsecurity/polymorphic_helpers.go index 705cbc0ecb57..fd445fd35bcd 100644 --- a/sdk/resourcemanager/security/armsecurity/polymorphic_helpers.go +++ b/sdk/resourcemanager/security/armsecurity/polymorphic_helpers.go @@ -15,7 +15,7 @@ func unmarshalAdditionalDataClassification(rawMsg json.RawMessage) (AdditionalDa if rawMsg == nil { return nil, nil } - var m map[string]interface{} + var m map[string]any if err := json.Unmarshal(rawMsg, &m); err != nil { return nil, err } @@ -37,7 +37,7 @@ func unmarshalAlertSimulatorRequestPropertiesClassification(rawMsg json.RawMessa if rawMsg == nil { return nil, nil } - var m map[string]interface{} + var m map[string]any if err := json.Unmarshal(rawMsg, &m); err != nil { return nil, err } @@ -55,7 +55,7 @@ func unmarshalAllowlistCustomAlertRuleClassification(rawMsg json.RawMessage) (Al if rawMsg == nil { return nil, nil } - var m map[string]interface{} + var m map[string]any if err := json.Unmarshal(rawMsg, &m); err != nil { return nil, err } @@ -98,7 +98,7 @@ func unmarshalAuthenticationDetailsPropertiesClassification(rawMsg json.RawMessa if rawMsg == nil { return nil, nil } - var m map[string]interface{} + var m map[string]any if err := json.Unmarshal(rawMsg, &m); err != nil { return nil, err } @@ -120,7 +120,7 @@ func unmarshalAutomationActionClassification(rawMsg json.RawMessage) (Automation if rawMsg == nil { return nil, nil } - var m map[string]interface{} + var m map[string]any if err := json.Unmarshal(rawMsg, &m); err != nil { return nil, err } @@ -161,7 +161,7 @@ func unmarshalAwsOrganizationalDataClassification(rawMsg json.RawMessage) (AwsOr if rawMsg == nil { return nil, nil } - var m map[string]interface{} + var m map[string]any if err := json.Unmarshal(rawMsg, &m); err != nil { return nil, err } @@ -181,7 +181,7 @@ func unmarshalCloudOfferingClassification(rawMsg json.RawMessage) (CloudOffering if rawMsg == nil { return nil, nil } - var m map[string]interface{} + var m map[string]any if err := json.Unmarshal(rawMsg, &m); err != nil { return nil, err } @@ -193,6 +193,8 @@ func unmarshalCloudOfferingClassification(rawMsg json.RawMessage) (CloudOffering b = &CspmMonitorAzureDevOpsOffering{} case string(OfferingTypeCspmMonitorGcp): b = &CspmMonitorGcpOffering{} + case string(OfferingTypeCspmMonitorGitLab): + b = &CspmMonitorGitLabOffering{} case string(OfferingTypeCspmMonitorGithub): b = &CspmMonitorGithubOffering{} case string(OfferingTypeDefenderCspmAws): @@ -209,6 +211,8 @@ func unmarshalCloudOfferingClassification(rawMsg json.RawMessage) (CloudOffering b = &DefenderForDatabasesGcpOffering{} case string(OfferingTypeDefenderForDevOpsAzureDevOps): b = &DefenderForDevOpsAzureDevOpsOffering{} + case string(OfferingTypeDefenderForDevOpsGitLab): + b = &DefenderForDevOpsGitLabOffering{} case string(OfferingTypeDefenderForDevOpsGithub): b = &DefenderForDevOpsGithubOffering{} case string(OfferingTypeDefenderForServersAws): @@ -246,7 +250,7 @@ func unmarshalEnvironmentDataClassification(rawMsg json.RawMessage) (Environment if rawMsg == nil { return nil, nil } - var m map[string]interface{} + var m map[string]any if err := json.Unmarshal(rawMsg, &m); err != nil { return nil, err } @@ -260,6 +264,8 @@ func unmarshalEnvironmentDataClassification(rawMsg json.RawMessage) (Environment b = &GcpProjectEnvironmentData{} case string(EnvironmentTypeGithubScope): b = &GithubScopeEnvironmentData{} + case string(EnvironmentTypeGitlabScope): + b = &GitlabScopeEnvironmentData{} default: b = &EnvironmentData{} } @@ -270,7 +276,7 @@ func unmarshalGcpOrganizationalDataClassification(rawMsg json.RawMessage) (GcpOr if rawMsg == nil { return nil, nil } - var m map[string]interface{} + var m map[string]any if err := json.Unmarshal(rawMsg, &m); err != nil { return nil, err } @@ -290,7 +296,7 @@ func unmarshalResourceDetailsClassification(rawMsg json.RawMessage) (ResourceDet if rawMsg == nil { return nil, nil } - var m map[string]interface{} + var m map[string]any if err := json.Unmarshal(rawMsg, &m); err != nil { return nil, err } @@ -312,7 +318,7 @@ func unmarshalResourceIdentifierClassification(rawMsg json.RawMessage) (Resource if rawMsg == nil { return nil, nil } - var m map[string]interface{} + var m map[string]any if err := json.Unmarshal(rawMsg, &m); err != nil { return nil, err } @@ -351,7 +357,7 @@ func unmarshalSettingClassification(rawMsg json.RawMessage) (SettingClassificati if rawMsg == nil { return nil, nil } - var m map[string]interface{} + var m map[string]any if err := json.Unmarshal(rawMsg, &m); err != nil { return nil, err } @@ -390,7 +396,7 @@ func unmarshalThresholdCustomAlertRuleClassification(rawMsg json.RawMessage) (Th if rawMsg == nil { return nil, nil } - var m map[string]interface{} + var m map[string]any if err := json.Unmarshal(rawMsg, &m); err != nil { return nil, err } @@ -459,7 +465,7 @@ func unmarshalTimeWindowCustomAlertRuleClassification(rawMsg json.RawMessage) (T if rawMsg == nil { return nil, nil } - var m map[string]interface{} + var m map[string]any if err := json.Unmarshal(rawMsg, &m); err != nil { return nil, err } diff --git a/sdk/resourcemanager/security/armsecurity/pricings_client.go b/sdk/resourcemanager/security/armsecurity/pricings_client.go index a0a17165cdbe..2c5bada66914 100644 --- a/sdk/resourcemanager/security/armsecurity/pricings_client.go +++ b/sdk/resourcemanager/security/armsecurity/pricings_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,46 +24,38 @@ import ( // PricingsClient contains the methods for the Pricings group. // Don't use this type directly, use NewPricingsClient() instead. type PricingsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewPricingsClient creates a new instance of PricingsClient with the specified values. -// subscriptionID - Azure subscription ID -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure subscription ID +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewPricingsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PricingsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".PricingsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &PricingsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Gets a provided Microsoft Defender for Cloud pricing configuration in the subscription. // If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-01 -// pricingName - name of the pricing configuration -// options - PricingsClientGetOptions contains the optional parameters for the PricingsClient.Get method. +// +// Generated from API version 2023-01-01 +// - pricingName - name of the pricing configuration +// - options - PricingsClientGetOptions contains the optional parameters for the PricingsClient.Get method. func (client *PricingsClient) Get(ctx context.Context, pricingName string, options *PricingsClientGetOptions) (PricingsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, pricingName, options) if err != nil { return PricingsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PricingsClientGetResponse{}, err } @@ -86,12 +76,12 @@ func (client *PricingsClient) getCreateRequest(ctx context.Context, pricingName return nil, errors.New("parameter pricingName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{pricingName}", url.PathEscape(pricingName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-01") + reqQP.Set("api-version", "2023-01-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -108,14 +98,15 @@ func (client *PricingsClient) getHandleResponse(resp *http.Response) (PricingsCl // List - Lists Microsoft Defender for Cloud pricing configurations in the subscription. // If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-01 -// options - PricingsClientListOptions contains the optional parameters for the PricingsClient.List method. +// +// Generated from API version 2023-01-01 +// - options - PricingsClientListOptions contains the optional parameters for the PricingsClient.List method. func (client *PricingsClient) List(ctx context.Context, options *PricingsClientListOptions) (PricingsClientListResponse, error) { req, err := client.listCreateRequest(ctx, options) if err != nil { return PricingsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PricingsClientListResponse{}, err } @@ -132,12 +123,12 @@ func (client *PricingsClient) listCreateRequest(ctx context.Context, options *Pr return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-01") + reqQP.Set("api-version", "2023-01-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -154,16 +145,17 @@ func (client *PricingsClient) listHandleResponse(resp *http.Response) (PricingsC // Update - Updates a provided Microsoft Defender for Cloud pricing configuration in the subscription. // If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-01 -// pricingName - name of the pricing configuration -// pricing - Pricing object -// options - PricingsClientUpdateOptions contains the optional parameters for the PricingsClient.Update method. +// +// Generated from API version 2023-01-01 +// - pricingName - name of the pricing configuration +// - pricing - Pricing object +// - options - PricingsClientUpdateOptions contains the optional parameters for the PricingsClient.Update method. func (client *PricingsClient) Update(ctx context.Context, pricingName string, pricing Pricing, options *PricingsClientUpdateOptions) (PricingsClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, pricingName, pricing, options) if err != nil { return PricingsClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PricingsClientUpdateResponse{}, err } @@ -184,12 +176,12 @@ func (client *PricingsClient) updateCreateRequest(ctx context.Context, pricingNa return nil, errors.New("parameter pricingName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{pricingName}", url.PathEscape(pricingName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-01") + reqQP.Set("api-version", "2023-01-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, runtime.MarshalAsJSON(req, pricing) diff --git a/sdk/resourcemanager/security/armsecurity/pricings_client_example_test.go b/sdk/resourcemanager/security/armsecurity/pricings_client_example_test.go deleted file mode 100644 index 48a67c84d2dc..000000000000 --- a/sdk/resourcemanager/security/armsecurity/pricings_client_example_test.go +++ /dev/null @@ -1,80 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. - -package armsecurity_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2022-03-01/examples/Pricings/ListPricings_example.json -func ExamplePricingsClient_List() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewPricingsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.List(ctx, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2022-03-01/examples/Pricings/GetPricingByName_example.json -func ExamplePricingsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewPricingsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "VirtualMachines", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2022-03-01/examples/Pricings/PutPricingByName_example.json -func ExamplePricingsClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewPricingsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Update(ctx, "VirtualMachines", armsecurity.Pricing{ - Properties: &armsecurity.PricingProperties{ - PricingTier: to.Ptr(armsecurity.PricingTierStandard), - SubPlan: to.Ptr("P2"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/security/armsecurity/regulatorycomplianceassessments_client.go b/sdk/resourcemanager/security/armsecurity/regulatorycomplianceassessments_client.go index c7f6c9831394..54ffaececc20 100644 --- a/sdk/resourcemanager/security/armsecurity/regulatorycomplianceassessments_client.go +++ b/sdk/resourcemanager/security/armsecurity/regulatorycomplianceassessments_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,49 +24,41 @@ import ( // RegulatoryComplianceAssessmentsClient contains the methods for the RegulatoryComplianceAssessments group. // Don't use this type directly, use NewRegulatoryComplianceAssessmentsClient() instead. type RegulatoryComplianceAssessmentsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewRegulatoryComplianceAssessmentsClient creates a new instance of RegulatoryComplianceAssessmentsClient with the specified values. -// subscriptionID - Azure subscription ID -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure subscription ID +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewRegulatoryComplianceAssessmentsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*RegulatoryComplianceAssessmentsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".RegulatoryComplianceAssessmentsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &RegulatoryComplianceAssessmentsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Supported regulatory compliance details and state for selected assessment // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-01-01-preview -// regulatoryComplianceStandardName - Name of the regulatory compliance standard object -// regulatoryComplianceControlName - Name of the regulatory compliance control object -// regulatoryComplianceAssessmentName - Name of the regulatory compliance assessment object -// options - RegulatoryComplianceAssessmentsClientGetOptions contains the optional parameters for the RegulatoryComplianceAssessmentsClient.Get -// method. +// - regulatoryComplianceStandardName - Name of the regulatory compliance standard object +// - regulatoryComplianceControlName - Name of the regulatory compliance control object +// - regulatoryComplianceAssessmentName - Name of the regulatory compliance assessment object +// - options - RegulatoryComplianceAssessmentsClientGetOptions contains the optional parameters for the RegulatoryComplianceAssessmentsClient.Get +// method. func (client *RegulatoryComplianceAssessmentsClient) Get(ctx context.Context, regulatoryComplianceStandardName string, regulatoryComplianceControlName string, regulatoryComplianceAssessmentName string, options *RegulatoryComplianceAssessmentsClientGetOptions) (RegulatoryComplianceAssessmentsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, regulatoryComplianceStandardName, regulatoryComplianceControlName, regulatoryComplianceAssessmentName, options) if err != nil { return RegulatoryComplianceAssessmentsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return RegulatoryComplianceAssessmentsClientGetResponse{}, err } @@ -97,7 +87,7 @@ func (client *RegulatoryComplianceAssessmentsClient) getCreateRequest(ctx contex return nil, errors.New("parameter regulatoryComplianceAssessmentName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{regulatoryComplianceAssessmentName}", url.PathEscape(regulatoryComplianceAssessmentName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -118,11 +108,12 @@ func (client *RegulatoryComplianceAssessmentsClient) getHandleResponse(resp *htt } // NewListPager - Details and state of assessments mapped to selected regulatory compliance control +// // Generated from API version 2019-01-01-preview -// regulatoryComplianceStandardName - Name of the regulatory compliance standard object -// regulatoryComplianceControlName - Name of the regulatory compliance control object -// options - RegulatoryComplianceAssessmentsClientListOptions contains the optional parameters for the RegulatoryComplianceAssessmentsClient.List -// method. +// - regulatoryComplianceStandardName - Name of the regulatory compliance standard object +// - regulatoryComplianceControlName - Name of the regulatory compliance control object +// - options - RegulatoryComplianceAssessmentsClientListOptions contains the optional parameters for the RegulatoryComplianceAssessmentsClient.NewListPager +// method. func (client *RegulatoryComplianceAssessmentsClient) NewListPager(regulatoryComplianceStandardName string, regulatoryComplianceControlName string, options *RegulatoryComplianceAssessmentsClientListOptions) *runtime.Pager[RegulatoryComplianceAssessmentsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[RegulatoryComplianceAssessmentsClientListResponse]{ More: func(page RegulatoryComplianceAssessmentsClientListResponse) bool { @@ -139,7 +130,7 @@ func (client *RegulatoryComplianceAssessmentsClient) NewListPager(regulatoryComp if err != nil { return RegulatoryComplianceAssessmentsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return RegulatoryComplianceAssessmentsClientListResponse{}, err } @@ -166,7 +157,7 @@ func (client *RegulatoryComplianceAssessmentsClient) listCreateRequest(ctx conte return nil, errors.New("parameter regulatoryComplianceControlName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{regulatoryComplianceControlName}", url.PathEscape(regulatoryComplianceControlName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/security/armsecurity/regulatorycomplianceassessments_client_example_test.go b/sdk/resourcemanager/security/armsecurity/regulatorycomplianceassessments_client_example_test.go deleted file mode 100644 index 287f3054f602..000000000000 --- a/sdk/resourcemanager/security/armsecurity/regulatorycomplianceassessments_client_example_test.go +++ /dev/null @@ -1,60 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. - -package armsecurity_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/RegulatoryCompliance/getRegulatoryComplianceAssessmentList_example.json -func ExampleRegulatoryComplianceAssessmentsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewRegulatoryComplianceAssessmentsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("PCI-DSS-3.2", "1.1", &armsecurity.RegulatoryComplianceAssessmentsClientListOptions{Filter: nil}) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/RegulatoryCompliance/getRegulatoryComplianceAssessment_example.json -func ExampleRegulatoryComplianceAssessmentsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewRegulatoryComplianceAssessmentsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "PCI-DSS-3.2", "1.1", "968548cb-02b3-8cd2-11f8-0cf64ab1a347", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/security/armsecurity/regulatorycompliancecontrols_client.go b/sdk/resourcemanager/security/armsecurity/regulatorycompliancecontrols_client.go index 87ae599a8b87..3dd419d23a7f 100644 --- a/sdk/resourcemanager/security/armsecurity/regulatorycompliancecontrols_client.go +++ b/sdk/resourcemanager/security/armsecurity/regulatorycompliancecontrols_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,48 +24,40 @@ import ( // RegulatoryComplianceControlsClient contains the methods for the RegulatoryComplianceControls group. // Don't use this type directly, use NewRegulatoryComplianceControlsClient() instead. type RegulatoryComplianceControlsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewRegulatoryComplianceControlsClient creates a new instance of RegulatoryComplianceControlsClient with the specified values. -// subscriptionID - Azure subscription ID -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure subscription ID +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewRegulatoryComplianceControlsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*RegulatoryComplianceControlsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".RegulatoryComplianceControlsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &RegulatoryComplianceControlsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Selected regulatory compliance control details and state // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-01-01-preview -// regulatoryComplianceStandardName - Name of the regulatory compliance standard object -// regulatoryComplianceControlName - Name of the regulatory compliance control object -// options - RegulatoryComplianceControlsClientGetOptions contains the optional parameters for the RegulatoryComplianceControlsClient.Get -// method. +// - regulatoryComplianceStandardName - Name of the regulatory compliance standard object +// - regulatoryComplianceControlName - Name of the regulatory compliance control object +// - options - RegulatoryComplianceControlsClientGetOptions contains the optional parameters for the RegulatoryComplianceControlsClient.Get +// method. func (client *RegulatoryComplianceControlsClient) Get(ctx context.Context, regulatoryComplianceStandardName string, regulatoryComplianceControlName string, options *RegulatoryComplianceControlsClientGetOptions) (RegulatoryComplianceControlsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, regulatoryComplianceStandardName, regulatoryComplianceControlName, options) if err != nil { return RegulatoryComplianceControlsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return RegulatoryComplianceControlsClientGetResponse{}, err } @@ -92,7 +82,7 @@ func (client *RegulatoryComplianceControlsClient) getCreateRequest(ctx context.C return nil, errors.New("parameter regulatoryComplianceControlName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{regulatoryComplianceControlName}", url.PathEscape(regulatoryComplianceControlName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -113,10 +103,11 @@ func (client *RegulatoryComplianceControlsClient) getHandleResponse(resp *http.R } // NewListPager - All supported regulatory compliance controls details and state for selected standard +// // Generated from API version 2019-01-01-preview -// regulatoryComplianceStandardName - Name of the regulatory compliance standard object -// options - RegulatoryComplianceControlsClientListOptions contains the optional parameters for the RegulatoryComplianceControlsClient.List -// method. +// - regulatoryComplianceStandardName - Name of the regulatory compliance standard object +// - options - RegulatoryComplianceControlsClientListOptions contains the optional parameters for the RegulatoryComplianceControlsClient.NewListPager +// method. func (client *RegulatoryComplianceControlsClient) NewListPager(regulatoryComplianceStandardName string, options *RegulatoryComplianceControlsClientListOptions) *runtime.Pager[RegulatoryComplianceControlsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[RegulatoryComplianceControlsClientListResponse]{ More: func(page RegulatoryComplianceControlsClientListResponse) bool { @@ -133,7 +124,7 @@ func (client *RegulatoryComplianceControlsClient) NewListPager(regulatoryComplia if err != nil { return RegulatoryComplianceControlsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return RegulatoryComplianceControlsClientListResponse{}, err } @@ -156,7 +147,7 @@ func (client *RegulatoryComplianceControlsClient) listCreateRequest(ctx context. return nil, errors.New("parameter regulatoryComplianceStandardName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{regulatoryComplianceStandardName}", url.PathEscape(regulatoryComplianceStandardName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/security/armsecurity/regulatorycompliancecontrols_client_example_test.go b/sdk/resourcemanager/security/armsecurity/regulatorycompliancecontrols_client_example_test.go deleted file mode 100644 index 4143eaa4df38..000000000000 --- a/sdk/resourcemanager/security/armsecurity/regulatorycompliancecontrols_client_example_test.go +++ /dev/null @@ -1,60 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. - -package armsecurity_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/RegulatoryCompliance/getRegulatoryComplianceControlList_example.json -func ExampleRegulatoryComplianceControlsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewRegulatoryComplianceControlsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("PCI-DSS-3.2", &armsecurity.RegulatoryComplianceControlsClientListOptions{Filter: nil}) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/RegulatoryCompliance/getRegulatoryComplianceControl_example.json -func ExampleRegulatoryComplianceControlsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewRegulatoryComplianceControlsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "PCI-DSS-3.2", "1.1", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/security/armsecurity/regulatorycompliancestandards_client.go b/sdk/resourcemanager/security/armsecurity/regulatorycompliancestandards_client.go index a5a30a27489b..6e1ccfb68235 100644 --- a/sdk/resourcemanager/security/armsecurity/regulatorycompliancestandards_client.go +++ b/sdk/resourcemanager/security/armsecurity/regulatorycompliancestandards_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,47 +24,39 @@ import ( // RegulatoryComplianceStandardsClient contains the methods for the RegulatoryComplianceStandards group. // Don't use this type directly, use NewRegulatoryComplianceStandardsClient() instead. type RegulatoryComplianceStandardsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewRegulatoryComplianceStandardsClient creates a new instance of RegulatoryComplianceStandardsClient with the specified values. -// subscriptionID - Azure subscription ID -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure subscription ID +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewRegulatoryComplianceStandardsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*RegulatoryComplianceStandardsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".RegulatoryComplianceStandardsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &RegulatoryComplianceStandardsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Supported regulatory compliance details state for selected standard // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-01-01-preview -// regulatoryComplianceStandardName - Name of the regulatory compliance standard object -// options - RegulatoryComplianceStandardsClientGetOptions contains the optional parameters for the RegulatoryComplianceStandardsClient.Get -// method. +// - regulatoryComplianceStandardName - Name of the regulatory compliance standard object +// - options - RegulatoryComplianceStandardsClientGetOptions contains the optional parameters for the RegulatoryComplianceStandardsClient.Get +// method. func (client *RegulatoryComplianceStandardsClient) Get(ctx context.Context, regulatoryComplianceStandardName string, options *RegulatoryComplianceStandardsClientGetOptions) (RegulatoryComplianceStandardsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, regulatoryComplianceStandardName, options) if err != nil { return RegulatoryComplianceStandardsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return RegulatoryComplianceStandardsClientGetResponse{}, err } @@ -87,7 +77,7 @@ func (client *RegulatoryComplianceStandardsClient) getCreateRequest(ctx context. return nil, errors.New("parameter regulatoryComplianceStandardName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{regulatoryComplianceStandardName}", url.PathEscape(regulatoryComplianceStandardName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -108,9 +98,10 @@ func (client *RegulatoryComplianceStandardsClient) getHandleResponse(resp *http. } // NewListPager - Supported regulatory compliance standards details and state +// // Generated from API version 2019-01-01-preview -// options - RegulatoryComplianceStandardsClientListOptions contains the optional parameters for the RegulatoryComplianceStandardsClient.List -// method. +// - options - RegulatoryComplianceStandardsClientListOptions contains the optional parameters for the RegulatoryComplianceStandardsClient.NewListPager +// method. func (client *RegulatoryComplianceStandardsClient) NewListPager(options *RegulatoryComplianceStandardsClientListOptions) *runtime.Pager[RegulatoryComplianceStandardsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[RegulatoryComplianceStandardsClientListResponse]{ More: func(page RegulatoryComplianceStandardsClientListResponse) bool { @@ -127,7 +118,7 @@ func (client *RegulatoryComplianceStandardsClient) NewListPager(options *Regulat if err != nil { return RegulatoryComplianceStandardsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return RegulatoryComplianceStandardsClientListResponse{}, err } @@ -146,7 +137,7 @@ func (client *RegulatoryComplianceStandardsClient) listCreateRequest(ctx context return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/security/armsecurity/regulatorycompliancestandards_client_example_test.go b/sdk/resourcemanager/security/armsecurity/regulatorycompliancestandards_client_example_test.go deleted file mode 100644 index 1836d96f28aa..000000000000 --- a/sdk/resourcemanager/security/armsecurity/regulatorycompliancestandards_client_example_test.go +++ /dev/null @@ -1,60 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. - -package armsecurity_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/RegulatoryCompliance/getRegulatoryComplianceStandardList_example.json -func ExampleRegulatoryComplianceStandardsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewRegulatoryComplianceStandardsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(&armsecurity.RegulatoryComplianceStandardsClientListOptions{Filter: nil}) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/RegulatoryCompliance/getRegulatoryComplianceStandard_example.json -func ExampleRegulatoryComplianceStandardsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewRegulatoryComplianceStandardsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "PCI-DSS-3.2", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/security/armsecurity/response_types.go b/sdk/resourcemanager/security/armsecurity/response_types.go index 963f079a26de..d5c6fece04ef 100644 --- a/sdk/resourcemanager/security/armsecurity/response_types.go +++ b/sdk/resourcemanager/security/armsecurity/response_types.go @@ -9,6 +9,26 @@ package armsecurity +// APICollectionClientGetResponse contains the response from method APICollectionClient.Get. +type APICollectionClientGetResponse struct { + APICollectionResponse +} + +// APICollectionClientListResponse contains the response from method APICollectionClient.NewListPager. +type APICollectionClientListResponse struct { + APICollectionResponseList +} + +// APICollectionOffboardingClientDeleteResponse contains the response from method APICollectionOffboardingClient.Delete. +type APICollectionOffboardingClientDeleteResponse struct { + // placeholder for future response values +} + +// APICollectionOnboardingClientCreateResponse contains the response from method APICollectionOnboardingClient.Create. +type APICollectionOnboardingClientCreateResponse struct { + APICollectionResponse +} + // AccountConnectorsClientCreateOrUpdateResponse contains the response from method AccountConnectorsClient.CreateOrUpdate. type AccountConnectorsClientCreateOrUpdateResponse struct { ConnectorSetting @@ -24,7 +44,7 @@ type AccountConnectorsClientGetResponse struct { ConnectorSetting } -// AccountConnectorsClientListResponse contains the response from method AccountConnectorsClient.List. +// AccountConnectorsClientListResponse contains the response from method AccountConnectorsClient.NewListPager. type AccountConnectorsClientListResponse struct { ConnectorSettingList } @@ -49,7 +69,7 @@ type AdaptiveApplicationControlsClientPutResponse struct { AdaptiveApplicationControlGroup } -// AdaptiveNetworkHardeningsClientEnforceResponse contains the response from method AdaptiveNetworkHardeningsClient.Enforce. +// AdaptiveNetworkHardeningsClientEnforceResponse contains the response from method AdaptiveNetworkHardeningsClient.BeginEnforce. type AdaptiveNetworkHardeningsClientEnforceResponse struct { // placeholder for future response values } @@ -59,7 +79,7 @@ type AdaptiveNetworkHardeningsClientGetResponse struct { AdaptiveNetworkHardening } -// AdaptiveNetworkHardeningsClientListByExtendedResourceResponse contains the response from method AdaptiveNetworkHardeningsClient.ListByExtendedResource. +// AdaptiveNetworkHardeningsClientListByExtendedResourceResponse contains the response from method AdaptiveNetworkHardeningsClient.NewListByExtendedResourcePager. type AdaptiveNetworkHardeningsClientListByExtendedResourceResponse struct { AdaptiveNetworkHardeningsList } @@ -84,27 +104,27 @@ type AlertsClientGetSubscriptionLevelResponse struct { Alert } -// AlertsClientListByResourceGroupResponse contains the response from method AlertsClient.ListByResourceGroup. +// AlertsClientListByResourceGroupResponse contains the response from method AlertsClient.NewListByResourceGroupPager. type AlertsClientListByResourceGroupResponse struct { AlertList } -// AlertsClientListResourceGroupLevelByRegionResponse contains the response from method AlertsClient.ListResourceGroupLevelByRegion. +// AlertsClientListResourceGroupLevelByRegionResponse contains the response from method AlertsClient.NewListResourceGroupLevelByRegionPager. type AlertsClientListResourceGroupLevelByRegionResponse struct { AlertList } -// AlertsClientListResponse contains the response from method AlertsClient.List. +// AlertsClientListResponse contains the response from method AlertsClient.NewListPager. type AlertsClientListResponse struct { AlertList } -// AlertsClientListSubscriptionLevelByRegionResponse contains the response from method AlertsClient.ListSubscriptionLevelByRegion. +// AlertsClientListSubscriptionLevelByRegionResponse contains the response from method AlertsClient.NewListSubscriptionLevelByRegionPager. type AlertsClientListSubscriptionLevelByRegionResponse struct { AlertList } -// AlertsClientSimulateResponse contains the response from method AlertsClient.Simulate. +// AlertsClientSimulateResponse contains the response from method AlertsClient.BeginSimulate. type AlertsClientSimulateResponse struct { // placeholder for future response values } @@ -159,7 +179,7 @@ type AlertsSuppressionRulesClientGetResponse struct { AlertsSuppressionRule } -// AlertsSuppressionRulesClientListResponse contains the response from method AlertsSuppressionRulesClient.List. +// AlertsSuppressionRulesClientListResponse contains the response from method AlertsSuppressionRulesClient.NewListPager. type AlertsSuppressionRulesClientListResponse struct { AlertsSuppressionRulesList } @@ -174,12 +194,12 @@ type AllowedConnectionsClientGetResponse struct { AllowedConnectionsResource } -// AllowedConnectionsClientListByHomeRegionResponse contains the response from method AllowedConnectionsClient.ListByHomeRegion. +// AllowedConnectionsClientListByHomeRegionResponse contains the response from method AllowedConnectionsClient.NewListByHomeRegionPager. type AllowedConnectionsClientListByHomeRegionResponse struct { AllowedConnectionsList } -// AllowedConnectionsClientListResponse contains the response from method AllowedConnectionsClient.List. +// AllowedConnectionsClientListResponse contains the response from method AllowedConnectionsClient.NewListPager. type AllowedConnectionsClientListResponse struct { AllowedConnectionsList } @@ -199,7 +219,7 @@ type ApplicationClientGetResponse struct { Application } -// ApplicationsClientListResponse contains the response from method ApplicationsClient.List. +// ApplicationsClientListResponse contains the response from method ApplicationsClient.NewListPager. type ApplicationsClientListResponse struct { ApplicationsList } @@ -219,7 +239,7 @@ type AssessmentsClientGetResponse struct { AssessmentResponse } -// AssessmentsClientListResponse contains the response from method AssessmentsClient.List. +// AssessmentsClientListResponse contains the response from method AssessmentsClient.NewListPager. type AssessmentsClientListResponse struct { AssessmentList } @@ -244,12 +264,12 @@ type AssessmentsMetadataClientGetResponse struct { AssessmentMetadataResponse } -// AssessmentsMetadataClientListBySubscriptionResponse contains the response from method AssessmentsMetadataClient.ListBySubscription. +// AssessmentsMetadataClientListBySubscriptionResponse contains the response from method AssessmentsMetadataClient.NewListBySubscriptionPager. type AssessmentsMetadataClientListBySubscriptionResponse struct { AssessmentMetadataResponseList } -// AssessmentsMetadataClientListResponse contains the response from method AssessmentsMetadataClient.List. +// AssessmentsMetadataClientListResponse contains the response from method AssessmentsMetadataClient.NewListPager. type AssessmentsMetadataClientListResponse struct { AssessmentMetadataResponseList } @@ -264,7 +284,7 @@ type AutoProvisioningSettingsClientGetResponse struct { AutoProvisioningSetting } -// AutoProvisioningSettingsClientListResponse contains the response from method AutoProvisioningSettingsClient.List. +// AutoProvisioningSettingsClientListResponse contains the response from method AutoProvisioningSettingsClient.NewListPager. type AutoProvisioningSettingsClientListResponse struct { AutoProvisioningSettingList } @@ -284,12 +304,12 @@ type AutomationsClientGetResponse struct { Automation } -// AutomationsClientListByResourceGroupResponse contains the response from method AutomationsClient.ListByResourceGroup. +// AutomationsClientListByResourceGroupResponse contains the response from method AutomationsClient.NewListByResourceGroupPager. type AutomationsClientListByResourceGroupResponse struct { AutomationList } -// AutomationsClientListResponse contains the response from method AutomationsClient.List. +// AutomationsClientListResponse contains the response from method AutomationsClient.NewListPager. type AutomationsClientListResponse struct { AutomationList } @@ -304,7 +324,7 @@ type ComplianceResultsClientGetResponse struct { ComplianceResult } -// ComplianceResultsClientListResponse contains the response from method ComplianceResultsClient.List. +// ComplianceResultsClientListResponse contains the response from method ComplianceResultsClient.NewListPager. type ComplianceResultsClientListResponse struct { ComplianceResultList } @@ -314,7 +334,7 @@ type CompliancesClientGetResponse struct { Compliance } -// CompliancesClientListResponse contains the response from method CompliancesClient.List. +// CompliancesClientListResponse contains the response from method CompliancesClient.NewListPager. type CompliancesClientListResponse struct { ComplianceList } @@ -334,36 +354,11 @@ type ConnectorApplicationClientGetResponse struct { Application } -// ConnectorApplicationsClientListResponse contains the response from method ConnectorApplicationsClient.List. +// ConnectorApplicationsClientListResponse contains the response from method ConnectorApplicationsClient.NewListPager. type ConnectorApplicationsClientListResponse struct { ApplicationsList } -// ConnectorGovernanceRuleClientListResponse contains the response from method ConnectorGovernanceRuleClient.List. -type ConnectorGovernanceRuleClientListResponse struct { - GovernanceRuleList -} - -// ConnectorGovernanceRulesClientCreateOrUpdateResponse contains the response from method ConnectorGovernanceRulesClient.CreateOrUpdate. -type ConnectorGovernanceRulesClientCreateOrUpdateResponse struct { - GovernanceRule -} - -// ConnectorGovernanceRulesClientDeleteResponse contains the response from method ConnectorGovernanceRulesClient.Delete. -type ConnectorGovernanceRulesClientDeleteResponse struct { - // placeholder for future response values -} - -// ConnectorGovernanceRulesClientGetResponse contains the response from method ConnectorGovernanceRulesClient.Get. -type ConnectorGovernanceRulesClientGetResponse struct { - GovernanceRule -} - -// ConnectorGovernanceRulesExecuteStatusClientGetResponse contains the response from method ConnectorGovernanceRulesExecuteStatusClient.Get. -type ConnectorGovernanceRulesExecuteStatusClientGetResponse struct { - ExecuteRuleStatus -} - // ConnectorsClientCreateOrUpdateResponse contains the response from method ConnectorsClient.CreateOrUpdate. type ConnectorsClientCreateOrUpdateResponse struct { Connector @@ -379,12 +374,12 @@ type ConnectorsClientGetResponse struct { Connector } -// ConnectorsClientListByResourceGroupResponse contains the response from method ConnectorsClient.ListByResourceGroup. +// ConnectorsClientListByResourceGroupResponse contains the response from method ConnectorsClient.NewListByResourceGroupPager. type ConnectorsClientListByResourceGroupResponse struct { ConnectorsList } -// ConnectorsClientListResponse contains the response from method ConnectorsClient.List. +// ConnectorsClientListResponse contains the response from method ConnectorsClient.NewListPager. type ConnectorsClientListResponse struct { ConnectorsList } @@ -409,7 +404,7 @@ type ContactsClientGetResponse struct { Contact } -// ContactsClientListResponse contains the response from method ContactsClient.List. +// ContactsClientListResponse contains the response from method ContactsClient.NewListPager. type ContactsClientListResponse struct { ContactList } @@ -429,12 +424,12 @@ type CustomAssessmentAutomationsClientGetResponse struct { CustomAssessmentAutomation } -// CustomAssessmentAutomationsClientListByResourceGroupResponse contains the response from method CustomAssessmentAutomationsClient.ListByResourceGroup. +// CustomAssessmentAutomationsClientListByResourceGroupResponse contains the response from method CustomAssessmentAutomationsClient.NewListByResourceGroupPager. type CustomAssessmentAutomationsClientListByResourceGroupResponse struct { CustomAssessmentAutomationsListResult } -// CustomAssessmentAutomationsClientListBySubscriptionResponse contains the response from method CustomAssessmentAutomationsClient.ListBySubscription. +// CustomAssessmentAutomationsClientListBySubscriptionResponse contains the response from method CustomAssessmentAutomationsClient.NewListBySubscriptionPager. type CustomAssessmentAutomationsClientListBySubscriptionResponse struct { CustomAssessmentAutomationsListResult } @@ -454,12 +449,12 @@ type CustomEntityStoreAssignmentsClientGetResponse struct { CustomEntityStoreAssignment } -// CustomEntityStoreAssignmentsClientListByResourceGroupResponse contains the response from method CustomEntityStoreAssignmentsClient.ListByResourceGroup. +// CustomEntityStoreAssignmentsClientListByResourceGroupResponse contains the response from method CustomEntityStoreAssignmentsClient.NewListByResourceGroupPager. type CustomEntityStoreAssignmentsClientListByResourceGroupResponse struct { CustomEntityStoreAssignmentsListResult } -// CustomEntityStoreAssignmentsClientListBySubscriptionResponse contains the response from method CustomEntityStoreAssignmentsClient.ListBySubscription. +// CustomEntityStoreAssignmentsClientListBySubscriptionResponse contains the response from method CustomEntityStoreAssignmentsClient.NewListBySubscriptionPager. type CustomEntityStoreAssignmentsClientListBySubscriptionResponse struct { CustomEntityStoreAssignmentsListResult } @@ -479,7 +474,7 @@ type DeviceSecurityGroupsClientGetResponse struct { DeviceSecurityGroup } -// DeviceSecurityGroupsClientListResponse contains the response from method DeviceSecurityGroupsClient.List. +// DeviceSecurityGroupsClientListResponse contains the response from method DeviceSecurityGroupsClient.NewListPager. type DeviceSecurityGroupsClientListResponse struct { DeviceSecurityGroupList } @@ -489,12 +484,12 @@ type DiscoveredSecuritySolutionsClientGetResponse struct { DiscoveredSecuritySolution } -// DiscoveredSecuritySolutionsClientListByHomeRegionResponse contains the response from method DiscoveredSecuritySolutionsClient.ListByHomeRegion. +// DiscoveredSecuritySolutionsClientListByHomeRegionResponse contains the response from method DiscoveredSecuritySolutionsClient.NewListByHomeRegionPager. type DiscoveredSecuritySolutionsClientListByHomeRegionResponse struct { DiscoveredSecuritySolutionList } -// DiscoveredSecuritySolutionsClientListResponse contains the response from method DiscoveredSecuritySolutionsClient.List. +// DiscoveredSecuritySolutionsClientListResponse contains the response from method DiscoveredSecuritySolutionsClient.NewListPager. type DiscoveredSecuritySolutionsClientListResponse struct { DiscoveredSecuritySolutionList } @@ -504,12 +499,12 @@ type ExternalSecuritySolutionsClientGetResponse struct { ExternalSecuritySolution } -// ExternalSecuritySolutionsClientListByHomeRegionResponse contains the response from method ExternalSecuritySolutionsClient.ListByHomeRegion. +// ExternalSecuritySolutionsClientListByHomeRegionResponse contains the response from method ExternalSecuritySolutionsClient.NewListByHomeRegionPager. type ExternalSecuritySolutionsClientListByHomeRegionResponse struct { ExternalSecuritySolutionList } -// ExternalSecuritySolutionsClientListResponse contains the response from method ExternalSecuritySolutionsClient.List. +// ExternalSecuritySolutionsClientListResponse contains the response from method ExternalSecuritySolutionsClient.NewListPager. type ExternalSecuritySolutionsClientListResponse struct { ExternalSecuritySolutionList } @@ -529,39 +524,51 @@ type GovernanceAssignmentsClientGetResponse struct { GovernanceAssignment } -// GovernanceAssignmentsClientListResponse contains the response from method GovernanceAssignmentsClient.List. +// GovernanceAssignmentsClientListResponse contains the response from method GovernanceAssignmentsClient.NewListPager. type GovernanceAssignmentsClientListResponse struct { GovernanceAssignmentsList } -// GovernanceRuleClientListResponse contains the response from method GovernanceRuleClient.List. -type GovernanceRuleClientListResponse struct { - GovernanceRuleList -} - // GovernanceRulesClientCreateOrUpdateResponse contains the response from method GovernanceRulesClient.CreateOrUpdate. type GovernanceRulesClientCreateOrUpdateResponse struct { GovernanceRule } -// GovernanceRulesClientDeleteResponse contains the response from method GovernanceRulesClient.Delete. +// GovernanceRulesClientDeleteResponse contains the response from method GovernanceRulesClient.BeginDelete. type GovernanceRulesClientDeleteResponse struct { // placeholder for future response values } +// GovernanceRulesClientExecuteResponse contains the response from method GovernanceRulesClient.BeginExecute. +type GovernanceRulesClientExecuteResponse struct { + // placeholder for future response values +} + // GovernanceRulesClientGetResponse contains the response from method GovernanceRulesClient.Get. type GovernanceRulesClientGetResponse struct { GovernanceRule } -// GovernanceRulesClientRuleIDExecuteSingleSecurityConnectorResponse contains the response from method GovernanceRulesClient.RuleIDExecuteSingleSecurityConnector. -type GovernanceRulesClientRuleIDExecuteSingleSecurityConnectorResponse struct { - // placeholder for future response values +// GovernanceRulesClientListResponse contains the response from method GovernanceRulesClient.NewListPager. +type GovernanceRulesClientListResponse struct { + GovernanceRuleList } -// GovernanceRulesClientRuleIDExecuteSingleSubscriptionResponse contains the response from method GovernanceRulesClient.RuleIDExecuteSingleSubscription. -type GovernanceRulesClientRuleIDExecuteSingleSubscriptionResponse struct { - // placeholder for future response values +// GovernanceRulesClientOperationResultsResponse contains the response from method GovernanceRulesClient.OperationResults. +type GovernanceRulesClientOperationResultsResponse struct { + OperationResultAutoGenerated + // Location contains the information returned from the location header response. + Location *string +} + +// HealthReportClientGetResponse contains the response from method HealthReportClient.Get. +type HealthReportClientGetResponse struct { + HealthReport +} + +// HealthReportsClientListResponse contains the response from method HealthReportsClient.NewListPager. +type HealthReportsClientListResponse struct { + HealthReportsList } // InformationProtectionPoliciesClientCreateOrUpdateResponse contains the response from method InformationProtectionPoliciesClient.CreateOrUpdate. @@ -574,7 +581,7 @@ type InformationProtectionPoliciesClientGetResponse struct { InformationProtectionPolicy } -// InformationProtectionPoliciesClientListResponse contains the response from method InformationProtectionPoliciesClient.List. +// InformationProtectionPoliciesClientListResponse contains the response from method InformationProtectionPoliciesClient.NewListPager. type InformationProtectionPoliciesClientListResponse struct { InformationProtectionPolicyList } @@ -599,7 +606,7 @@ type IngestionSettingsClientListConnectionStringsResponse struct { ConnectionStrings } -// IngestionSettingsClientListResponse contains the response from method IngestionSettingsClient.List. +// IngestionSettingsClientListResponse contains the response from method IngestionSettingsClient.NewListPager. type IngestionSettingsClientListResponse struct { IngestionSettingList } @@ -634,12 +641,12 @@ type IotSecuritySolutionClientGetResponse struct { IoTSecuritySolutionModel } -// IotSecuritySolutionClientListByResourceGroupResponse contains the response from method IotSecuritySolutionClient.ListByResourceGroup. +// IotSecuritySolutionClientListByResourceGroupResponse contains the response from method IotSecuritySolutionClient.NewListByResourceGroupPager. type IotSecuritySolutionClientListByResourceGroupResponse struct { IoTSecuritySolutionsList } -// IotSecuritySolutionClientListBySubscriptionResponse contains the response from method IotSecuritySolutionClient.ListBySubscription. +// IotSecuritySolutionClientListBySubscriptionResponse contains the response from method IotSecuritySolutionClient.NewListBySubscriptionPager. type IotSecuritySolutionClientListBySubscriptionResponse struct { IoTSecuritySolutionsList } @@ -659,7 +666,7 @@ type IotSecuritySolutionsAnalyticsAggregatedAlertClientGetResponse struct { IoTSecurityAggregatedAlert } -// IotSecuritySolutionsAnalyticsAggregatedAlertClientListResponse contains the response from method IotSecuritySolutionsAnalyticsAggregatedAlertClient.List. +// IotSecuritySolutionsAnalyticsAggregatedAlertClientListResponse contains the response from method IotSecuritySolutionsAnalyticsAggregatedAlertClient.NewListPager. type IotSecuritySolutionsAnalyticsAggregatedAlertClientListResponse struct { IoTSecurityAggregatedAlertList } @@ -669,7 +676,7 @@ type IotSecuritySolutionsAnalyticsRecommendationClientGetResponse struct { IoTSecurityAggregatedRecommendation } -// IotSecuritySolutionsAnalyticsRecommendationClientListResponse contains the response from method IotSecuritySolutionsAnalyticsRecommendationClient.List. +// IotSecuritySolutionsAnalyticsRecommendationClientListResponse contains the response from method IotSecuritySolutionsAnalyticsRecommendationClient.NewListPager. type IotSecuritySolutionsAnalyticsRecommendationClientListResponse struct { IoTSecurityAggregatedRecommendationList } @@ -694,22 +701,22 @@ type JitNetworkAccessPoliciesClientInitiateResponse struct { JitNetworkAccessRequest } -// JitNetworkAccessPoliciesClientListByRegionResponse contains the response from method JitNetworkAccessPoliciesClient.ListByRegion. +// JitNetworkAccessPoliciesClientListByRegionResponse contains the response from method JitNetworkAccessPoliciesClient.NewListByRegionPager. type JitNetworkAccessPoliciesClientListByRegionResponse struct { JitNetworkAccessPoliciesList } -// JitNetworkAccessPoliciesClientListByResourceGroupAndRegionResponse contains the response from method JitNetworkAccessPoliciesClient.ListByResourceGroupAndRegion. +// JitNetworkAccessPoliciesClientListByResourceGroupAndRegionResponse contains the response from method JitNetworkAccessPoliciesClient.NewListByResourceGroupAndRegionPager. type JitNetworkAccessPoliciesClientListByResourceGroupAndRegionResponse struct { JitNetworkAccessPoliciesList } -// JitNetworkAccessPoliciesClientListByResourceGroupResponse contains the response from method JitNetworkAccessPoliciesClient.ListByResourceGroup. +// JitNetworkAccessPoliciesClientListByResourceGroupResponse contains the response from method JitNetworkAccessPoliciesClient.NewListByResourceGroupPager. type JitNetworkAccessPoliciesClientListByResourceGroupResponse struct { JitNetworkAccessPoliciesList } -// JitNetworkAccessPoliciesClientListResponse contains the response from method JitNetworkAccessPoliciesClient.List. +// JitNetworkAccessPoliciesClientListResponse contains the response from method JitNetworkAccessPoliciesClient.NewListPager. type JitNetworkAccessPoliciesClientListResponse struct { JitNetworkAccessPoliciesList } @@ -719,7 +726,7 @@ type LocationsClientGetResponse struct { AscLocation } -// LocationsClientListResponse contains the response from method LocationsClient.List. +// LocationsClientListResponse contains the response from method LocationsClient.NewListPager. type LocationsClientListResponse struct { AscLocationList } @@ -734,7 +741,7 @@ type MdeOnboardingsClientListResponse struct { MdeOnboardingDataList } -// OperationsClientListResponse contains the response from method OperationsClient.List. +// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. type OperationsClientListResponse struct { OperationList } @@ -759,7 +766,7 @@ type RegulatoryComplianceAssessmentsClientGetResponse struct { RegulatoryComplianceAssessment } -// RegulatoryComplianceAssessmentsClientListResponse contains the response from method RegulatoryComplianceAssessmentsClient.List. +// RegulatoryComplianceAssessmentsClientListResponse contains the response from method RegulatoryComplianceAssessmentsClient.NewListPager. type RegulatoryComplianceAssessmentsClientListResponse struct { RegulatoryComplianceAssessmentList } @@ -769,7 +776,7 @@ type RegulatoryComplianceControlsClientGetResponse struct { RegulatoryComplianceControl } -// RegulatoryComplianceControlsClientListResponse contains the response from method RegulatoryComplianceControlsClient.List. +// RegulatoryComplianceControlsClientListResponse contains the response from method RegulatoryComplianceControlsClient.NewListPager. type RegulatoryComplianceControlsClientListResponse struct { RegulatoryComplianceControlList } @@ -779,7 +786,7 @@ type RegulatoryComplianceStandardsClientGetResponse struct { RegulatoryComplianceStandard } -// RegulatoryComplianceStandardsClientListResponse contains the response from method RegulatoryComplianceStandardsClient.List. +// RegulatoryComplianceStandardsClientListResponse contains the response from method RegulatoryComplianceStandardsClient.NewListPager. type RegulatoryComplianceStandardsClientListResponse struct { RegulatoryComplianceStandardList } @@ -829,22 +836,22 @@ type SQLVulnerabilityAssessmentScansClientListResponse struct { Scans } -// SecureScoreControlDefinitionsClientListBySubscriptionResponse contains the response from method SecureScoreControlDefinitionsClient.ListBySubscription. +// SecureScoreControlDefinitionsClientListBySubscriptionResponse contains the response from method SecureScoreControlDefinitionsClient.NewListBySubscriptionPager. type SecureScoreControlDefinitionsClientListBySubscriptionResponse struct { SecureScoreControlDefinitionList } -// SecureScoreControlDefinitionsClientListResponse contains the response from method SecureScoreControlDefinitionsClient.List. +// SecureScoreControlDefinitionsClientListResponse contains the response from method SecureScoreControlDefinitionsClient.NewListPager. type SecureScoreControlDefinitionsClientListResponse struct { SecureScoreControlDefinitionList } -// SecureScoreControlsClientListBySecureScoreResponse contains the response from method SecureScoreControlsClient.ListBySecureScore. +// SecureScoreControlsClientListBySecureScoreResponse contains the response from method SecureScoreControlsClient.NewListBySecureScorePager. type SecureScoreControlsClientListBySecureScoreResponse struct { SecureScoreControlList } -// SecureScoreControlsClientListResponse contains the response from method SecureScoreControlsClient.List. +// SecureScoreControlsClientListResponse contains the response from method SecureScoreControlsClient.NewListPager. type SecureScoreControlsClientListResponse struct { SecureScoreControlList } @@ -854,7 +861,7 @@ type SecureScoresClientGetResponse struct { SecureScoreItem } -// SecureScoresClientListResponse contains the response from method SecureScoresClient.List. +// SecureScoresClientListResponse contains the response from method SecureScoresClient.NewListPager. type SecureScoresClientListResponse struct { SecureScoresList } @@ -864,7 +871,7 @@ type ServerVulnerabilityAssessmentClientCreateOrUpdateResponse struct { ServerVulnerabilityAssessment } -// ServerVulnerabilityAssessmentClientDeleteResponse contains the response from method ServerVulnerabilityAssessmentClient.Delete. +// ServerVulnerabilityAssessmentClientDeleteResponse contains the response from method ServerVulnerabilityAssessmentClient.BeginDelete. type ServerVulnerabilityAssessmentClientDeleteResponse struct { // placeholder for future response values } @@ -894,7 +901,7 @@ func (s *SettingsClientGetResponse) UnmarshalJSON(data []byte) error { return nil } -// SettingsClientListResponse contains the response from method SettingsClient.List. +// SettingsClientListResponse contains the response from method SettingsClient.NewListPager. type SettingsClientListResponse struct { SettingsList } @@ -919,12 +926,12 @@ type SoftwareInventoriesClientGetResponse struct { Software } -// SoftwareInventoriesClientListByExtendedResourceResponse contains the response from method SoftwareInventoriesClient.ListByExtendedResource. +// SoftwareInventoriesClientListByExtendedResourceResponse contains the response from method SoftwareInventoriesClient.NewListByExtendedResourcePager. type SoftwareInventoriesClientListByExtendedResourceResponse struct { SoftwaresList } -// SoftwareInventoriesClientListBySubscriptionResponse contains the response from method SoftwareInventoriesClient.ListBySubscription. +// SoftwareInventoriesClientListBySubscriptionResponse contains the response from method SoftwareInventoriesClient.NewListBySubscriptionPager. type SoftwareInventoriesClientListBySubscriptionResponse struct { SoftwaresList } @@ -934,7 +941,7 @@ type SolutionsClientGetResponse struct { Solution } -// SolutionsClientListResponse contains the response from method SolutionsClient.List. +// SolutionsClientListResponse contains the response from method SolutionsClient.NewListPager. type SolutionsClientListResponse struct { SolutionList } @@ -954,21 +961,16 @@ type SubAssessmentsClientGetResponse struct { SubAssessment } -// SubAssessmentsClientListAllResponse contains the response from method SubAssessmentsClient.ListAll. +// SubAssessmentsClientListAllResponse contains the response from method SubAssessmentsClient.NewListAllPager. type SubAssessmentsClientListAllResponse struct { SubAssessmentList } -// SubAssessmentsClientListResponse contains the response from method SubAssessmentsClient.List. +// SubAssessmentsClientListResponse contains the response from method SubAssessmentsClient.NewListPager. type SubAssessmentsClientListResponse struct { SubAssessmentList } -// SubscriptionGovernanceRulesExecuteStatusClientGetResponse contains the response from method SubscriptionGovernanceRulesExecuteStatusClient.Get. -type SubscriptionGovernanceRulesExecuteStatusClientGetResponse struct { - ExecuteRuleStatus -} - // TasksClientGetResourceGroupLevelTaskResponse contains the response from method TasksClient.GetResourceGroupLevelTask. type TasksClientGetResourceGroupLevelTaskResponse struct { Task @@ -979,17 +981,17 @@ type TasksClientGetSubscriptionLevelTaskResponse struct { Task } -// TasksClientListByHomeRegionResponse contains the response from method TasksClient.ListByHomeRegion. +// TasksClientListByHomeRegionResponse contains the response from method TasksClient.NewListByHomeRegionPager. type TasksClientListByHomeRegionResponse struct { TaskList } -// TasksClientListByResourceGroupResponse contains the response from method TasksClient.ListByResourceGroup. +// TasksClientListByResourceGroupResponse contains the response from method TasksClient.NewListByResourceGroupPager. type TasksClientListByResourceGroupResponse struct { TaskList } -// TasksClientListResponse contains the response from method TasksClient.List. +// TasksClientListResponse contains the response from method TasksClient.NewListPager. type TasksClientListResponse struct { TaskList } @@ -1009,12 +1011,12 @@ type TopologyClientGetResponse struct { TopologyResource } -// TopologyClientListByHomeRegionResponse contains the response from method TopologyClient.ListByHomeRegion. +// TopologyClientListByHomeRegionResponse contains the response from method TopologyClient.NewListByHomeRegionPager. type TopologyClientListByHomeRegionResponse struct { TopologyList } -// TopologyClientListResponse contains the response from method TopologyClient.List. +// TopologyClientListResponse contains the response from method TopologyClient.NewListPager. type TopologyClientListResponse struct { TopologyList } @@ -1034,7 +1036,7 @@ type WorkspaceSettingsClientGetResponse struct { WorkspaceSetting } -// WorkspaceSettingsClientListResponse contains the response from method WorkspaceSettingsClient.List. +// WorkspaceSettingsClientListResponse contains the response from method WorkspaceSettingsClient.NewListPager. type WorkspaceSettingsClientListResponse struct { WorkspaceSettingList } diff --git a/sdk/resourcemanager/security/armsecurity/securescorecontroldefinitions_client.go b/sdk/resourcemanager/security/armsecurity/securescorecontroldefinitions_client.go index a7fbfbc1bd78..7e7bd0cce743 100644 --- a/sdk/resourcemanager/security/armsecurity/securescorecontroldefinitions_client.go +++ b/sdk/resourcemanager/security/armsecurity/securescorecontroldefinitions_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,39 +24,31 @@ import ( // SecureScoreControlDefinitionsClient contains the methods for the SecureScoreControlDefinitions group. // Don't use this type directly, use NewSecureScoreControlDefinitionsClient() instead. type SecureScoreControlDefinitionsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewSecureScoreControlDefinitionsClient creates a new instance of SecureScoreControlDefinitionsClient with the specified values. -// subscriptionID - Azure subscription ID -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure subscription ID +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewSecureScoreControlDefinitionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SecureScoreControlDefinitionsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".SecureScoreControlDefinitionsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &SecureScoreControlDefinitionsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListPager - List the available security controls, their assessments, and the max score +// // Generated from API version 2020-01-01 -// options - SecureScoreControlDefinitionsClientListOptions contains the optional parameters for the SecureScoreControlDefinitionsClient.List -// method. +// - options - SecureScoreControlDefinitionsClientListOptions contains the optional parameters for the SecureScoreControlDefinitionsClient.NewListPager +// method. func (client *SecureScoreControlDefinitionsClient) NewListPager(options *SecureScoreControlDefinitionsClientListOptions) *runtime.Pager[SecureScoreControlDefinitionsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[SecureScoreControlDefinitionsClientListResponse]{ More: func(page SecureScoreControlDefinitionsClientListResponse) bool { @@ -75,7 +65,7 @@ func (client *SecureScoreControlDefinitionsClient) NewListPager(options *SecureS if err != nil { return SecureScoreControlDefinitionsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SecureScoreControlDefinitionsClientListResponse{}, err } @@ -90,7 +80,7 @@ func (client *SecureScoreControlDefinitionsClient) NewListPager(options *SecureS // listCreateRequest creates the List request. func (client *SecureScoreControlDefinitionsClient) listCreateRequest(ctx context.Context, options *SecureScoreControlDefinitionsClientListOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Security/secureScoreControlDefinitions" - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -112,9 +102,10 @@ func (client *SecureScoreControlDefinitionsClient) listHandleResponse(resp *http // NewListBySubscriptionPager - For a specified subscription, list the available security controls, their assessments, and // the max score +// // Generated from API version 2020-01-01 -// options - SecureScoreControlDefinitionsClientListBySubscriptionOptions contains the optional parameters for the SecureScoreControlDefinitionsClient.ListBySubscription -// method. +// - options - SecureScoreControlDefinitionsClientListBySubscriptionOptions contains the optional parameters for the SecureScoreControlDefinitionsClient.NewListBySubscriptionPager +// method. func (client *SecureScoreControlDefinitionsClient) NewListBySubscriptionPager(options *SecureScoreControlDefinitionsClientListBySubscriptionOptions) *runtime.Pager[SecureScoreControlDefinitionsClientListBySubscriptionResponse] { return runtime.NewPager(runtime.PagingHandler[SecureScoreControlDefinitionsClientListBySubscriptionResponse]{ More: func(page SecureScoreControlDefinitionsClientListBySubscriptionResponse) bool { @@ -131,7 +122,7 @@ func (client *SecureScoreControlDefinitionsClient) NewListBySubscriptionPager(op if err != nil { return SecureScoreControlDefinitionsClientListBySubscriptionResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SecureScoreControlDefinitionsClientListBySubscriptionResponse{}, err } @@ -150,7 +141,7 @@ func (client *SecureScoreControlDefinitionsClient) listBySubscriptionCreateReque return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/security/armsecurity/securescorecontroldefinitions_client_example_test.go b/sdk/resourcemanager/security/armsecurity/securescorecontroldefinitions_client_example_test.go deleted file mode 100644 index 3e0d0f8a5be8..000000000000 --- a/sdk/resourcemanager/security/armsecurity/securescorecontroldefinitions_client_example_test.go +++ /dev/null @@ -1,65 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. - -package armsecurity_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/secureScoreControlDefinitions/ListSecureScoreControlDefinitions_example.json -func ExampleSecureScoreControlDefinitionsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewSecureScoreControlDefinitionsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/secureScoreControlDefinitions/ListSecureScoreControlDefinitions_subscription_example.json -func ExampleSecureScoreControlDefinitionsClient_NewListBySubscriptionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewSecureScoreControlDefinitionsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListBySubscriptionPager(nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/security/armsecurity/securescorecontrols_client.go b/sdk/resourcemanager/security/armsecurity/securescorecontrols_client.go index 10a012481b94..a0410c68e37c 100644 --- a/sdk/resourcemanager/security/armsecurity/securescorecontrols_client.go +++ b/sdk/resourcemanager/security/armsecurity/securescorecontrols_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,39 +24,31 @@ import ( // SecureScoreControlsClient contains the methods for the SecureScoreControls group. // Don't use this type directly, use NewSecureScoreControlsClient() instead. type SecureScoreControlsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewSecureScoreControlsClient creates a new instance of SecureScoreControlsClient with the specified values. -// subscriptionID - Azure subscription ID -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure subscription ID +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewSecureScoreControlsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SecureScoreControlsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".SecureScoreControlsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &SecureScoreControlsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListPager - Get all security controls within a scope +// // Generated from API version 2020-01-01 -// options - SecureScoreControlsClientListOptions contains the optional parameters for the SecureScoreControlsClient.List -// method. +// - options - SecureScoreControlsClientListOptions contains the optional parameters for the SecureScoreControlsClient.NewListPager +// method. func (client *SecureScoreControlsClient) NewListPager(options *SecureScoreControlsClientListOptions) *runtime.Pager[SecureScoreControlsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[SecureScoreControlsClientListResponse]{ More: func(page SecureScoreControlsClientListResponse) bool { @@ -75,7 +65,7 @@ func (client *SecureScoreControlsClient) NewListPager(options *SecureScoreContro if err != nil { return SecureScoreControlsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SecureScoreControlsClientListResponse{}, err } @@ -94,7 +84,7 @@ func (client *SecureScoreControlsClient) listCreateRequest(ctx context.Context, return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -118,10 +108,11 @@ func (client *SecureScoreControlsClient) listHandleResponse(resp *http.Response) } // NewListBySecureScorePager - Get all security controls for a specific initiative within a scope +// // Generated from API version 2020-01-01 -// secureScoreName - The initiative name. For the ASC Default initiative, use 'ascScore' as in the sample request below. -// options - SecureScoreControlsClientListBySecureScoreOptions contains the optional parameters for the SecureScoreControlsClient.ListBySecureScore -// method. +// - secureScoreName - The initiative name. For the ASC Default initiative, use 'ascScore' as in the sample request below. +// - options - SecureScoreControlsClientListBySecureScoreOptions contains the optional parameters for the SecureScoreControlsClient.NewListBySecureScorePager +// method. func (client *SecureScoreControlsClient) NewListBySecureScorePager(secureScoreName string, options *SecureScoreControlsClientListBySecureScoreOptions) *runtime.Pager[SecureScoreControlsClientListBySecureScoreResponse] { return runtime.NewPager(runtime.PagingHandler[SecureScoreControlsClientListBySecureScoreResponse]{ More: func(page SecureScoreControlsClientListBySecureScoreResponse) bool { @@ -138,7 +129,7 @@ func (client *SecureScoreControlsClient) NewListBySecureScorePager(secureScoreNa if err != nil { return SecureScoreControlsClientListBySecureScoreResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SecureScoreControlsClientListBySecureScoreResponse{}, err } @@ -161,7 +152,7 @@ func (client *SecureScoreControlsClient) listBySecureScoreCreateRequest(ctx cont return nil, errors.New("parameter secureScoreName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{secureScoreName}", url.PathEscape(secureScoreName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/security/armsecurity/securescorecontrols_client_example_test.go b/sdk/resourcemanager/security/armsecurity/securescorecontrols_client_example_test.go deleted file mode 100644 index dc9e31d12808..000000000000 --- a/sdk/resourcemanager/security/armsecurity/securescorecontrols_client_example_test.go +++ /dev/null @@ -1,90 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. - -package armsecurity_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/secureScores/ListSecureScoreControlsForName_builtin_example.json -func ExampleSecureScoreControlsClient_NewListBySecureScorePager_getSecurityControlsAndTheirCurrentScoreForTheSpecifiedInitiative() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewSecureScoreControlsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListBySecureScorePager("ascScore", &armsecurity.SecureScoreControlsClientListBySecureScoreOptions{Expand: nil}) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/secureScores/ListSecureScoreControlsForNameWithExpand_builtin_example.json -func ExampleSecureScoreControlsClient_NewListBySecureScorePager_getSecurityControlsAndTheirCurrentScoreForTheSpecifiedInitiativeWithTheExpandParameter() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewSecureScoreControlsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListBySecureScorePager("ascScore", &armsecurity.SecureScoreControlsClientListBySecureScoreOptions{Expand: to.Ptr(armsecurity.ExpandControlsEnumDefinition)}) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/secureScores/ListSecureScoreControls_example.json -func ExampleSecureScoreControlsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewSecureScoreControlsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(&armsecurity.SecureScoreControlsClientListOptions{Expand: nil}) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/security/armsecurity/securescores_client.go b/sdk/resourcemanager/security/armsecurity/securescores_client.go index ea9cc67328a8..e2bad3ca5e7e 100644 --- a/sdk/resourcemanager/security/armsecurity/securescores_client.go +++ b/sdk/resourcemanager/security/armsecurity/securescores_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,31 +24,22 @@ import ( // SecureScoresClient contains the methods for the SecureScores group. // Don't use this type directly, use NewSecureScoresClient() instead. type SecureScoresClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewSecureScoresClient creates a new instance of SecureScoresClient with the specified values. -// subscriptionID - Azure subscription ID -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure subscription ID +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewSecureScoresClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SecureScoresClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".SecureScoresClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &SecureScoresClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -58,15 +47,16 @@ func NewSecureScoresClient(subscriptionID string, credential azcore.TokenCredent // Get - Get secure score for a specific Microsoft Defender for Cloud initiative within your current scope. For the ASC Default // initiative, use 'ascScore'. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-01-01 -// secureScoreName - The initiative name. For the ASC Default initiative, use 'ascScore' as in the sample request below. -// options - SecureScoresClientGetOptions contains the optional parameters for the SecureScoresClient.Get method. +// - secureScoreName - The initiative name. For the ASC Default initiative, use 'ascScore' as in the sample request below. +// - options - SecureScoresClientGetOptions contains the optional parameters for the SecureScoresClient.Get method. func (client *SecureScoresClient) Get(ctx context.Context, secureScoreName string, options *SecureScoresClientGetOptions) (SecureScoresClientGetResponse, error) { req, err := client.getCreateRequest(ctx, secureScoreName, options) if err != nil { return SecureScoresClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SecureScoresClientGetResponse{}, err } @@ -87,7 +77,7 @@ func (client *SecureScoresClient) getCreateRequest(ctx context.Context, secureSc return nil, errors.New("parameter secureScoreName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{secureScoreName}", url.PathEscape(secureScoreName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -108,8 +98,9 @@ func (client *SecureScoresClient) getHandleResponse(resp *http.Response) (Secure } // NewListPager - List secure scores for all your Microsoft Defender for Cloud initiatives within your current scope. +// // Generated from API version 2020-01-01 -// options - SecureScoresClientListOptions contains the optional parameters for the SecureScoresClient.List method. +// - options - SecureScoresClientListOptions contains the optional parameters for the SecureScoresClient.NewListPager method. func (client *SecureScoresClient) NewListPager(options *SecureScoresClientListOptions) *runtime.Pager[SecureScoresClientListResponse] { return runtime.NewPager(runtime.PagingHandler[SecureScoresClientListResponse]{ More: func(page SecureScoresClientListResponse) bool { @@ -126,7 +117,7 @@ func (client *SecureScoresClient) NewListPager(options *SecureScoresClientListOp if err != nil { return SecureScoresClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SecureScoresClientListResponse{}, err } @@ -145,7 +136,7 @@ func (client *SecureScoresClient) listCreateRequest(ctx context.Context, options return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/security/armsecurity/securescores_client_example_test.go b/sdk/resourcemanager/security/armsecurity/securescores_client_example_test.go deleted file mode 100644 index 506ee95f68e9..000000000000 --- a/sdk/resourcemanager/security/armsecurity/securescores_client_example_test.go +++ /dev/null @@ -1,60 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. - -package armsecurity_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/secureScores/ListSecureScores_example.json -func ExampleSecureScoresClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewSecureScoresClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/secureScores/GetSecureScoresSingle_example.json -func ExampleSecureScoresClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewSecureScoresClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "ascScore", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/security/armsecurity/servervulnerabilityassessment_client.go b/sdk/resourcemanager/security/armsecurity/servervulnerabilityassessment_client.go index 6552c0d8711c..d6a3372858b7 100644 --- a/sdk/resourcemanager/security/armsecurity/servervulnerabilityassessment_client.go +++ b/sdk/resourcemanager/security/armsecurity/servervulnerabilityassessment_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,31 +24,22 @@ import ( // ServerVulnerabilityAssessmentClient contains the methods for the ServerVulnerabilityAssessment group. // Don't use this type directly, use NewServerVulnerabilityAssessmentClient() instead. type ServerVulnerabilityAssessmentClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewServerVulnerabilityAssessmentClient creates a new instance of ServerVulnerabilityAssessmentClient with the specified values. -// subscriptionID - Azure subscription ID -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure subscription ID +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewServerVulnerabilityAssessmentClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ServerVulnerabilityAssessmentClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".ServerVulnerabilityAssessmentClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ServerVulnerabilityAssessmentClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -58,19 +47,20 @@ func NewServerVulnerabilityAssessmentClient(subscriptionID string, credential az // CreateOrUpdate - Creating a server vulnerability assessment on a resource, which will onboard a resource for having a vulnerability // assessment on it // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-01-01 -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// resourceNamespace - The Namespace of the resource. -// resourceType - The type of the resource. -// resourceName - Name of the resource. -// options - ServerVulnerabilityAssessmentClientCreateOrUpdateOptions contains the optional parameters for the ServerVulnerabilityAssessmentClient.CreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - resourceNamespace - The Namespace of the resource. +// - resourceType - The type of the resource. +// - resourceName - Name of the resource. +// - options - ServerVulnerabilityAssessmentClientCreateOrUpdateOptions contains the optional parameters for the ServerVulnerabilityAssessmentClient.CreateOrUpdate +// method. func (client *ServerVulnerabilityAssessmentClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string, options *ServerVulnerabilityAssessmentClientCreateOrUpdateOptions) (ServerVulnerabilityAssessmentClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, resourceNamespace, resourceType, resourceName, options) if err != nil { return ServerVulnerabilityAssessmentClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ServerVulnerabilityAssessmentClientCreateOrUpdateResponse{}, err } @@ -104,7 +94,7 @@ func (client *ServerVulnerabilityAssessmentClient) createOrUpdateCreateRequest(c } urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) urlPath = strings.ReplaceAll(urlPath, "{serverVulnerabilityAssessment}", url.PathEscape("default")) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -126,36 +116,38 @@ func (client *ServerVulnerabilityAssessmentClient) createOrUpdateHandleResponse( // BeginDelete - Removing server vulnerability assessment from a resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-01-01 -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// resourceNamespace - The Namespace of the resource. -// resourceType - The type of the resource. -// resourceName - Name of the resource. -// options - ServerVulnerabilityAssessmentClientBeginDeleteOptions contains the optional parameters for the ServerVulnerabilityAssessmentClient.BeginDelete -// method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - resourceNamespace - The Namespace of the resource. +// - resourceType - The type of the resource. +// - resourceName - Name of the resource. +// - options - ServerVulnerabilityAssessmentClientBeginDeleteOptions contains the optional parameters for the ServerVulnerabilityAssessmentClient.BeginDelete +// method. func (client *ServerVulnerabilityAssessmentClient) BeginDelete(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string, options *ServerVulnerabilityAssessmentClientBeginDeleteOptions) (*runtime.Poller[ServerVulnerabilityAssessmentClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, resourceNamespace, resourceType, resourceName, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[ServerVulnerabilityAssessmentClientDeleteResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ServerVulnerabilityAssessmentClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[ServerVulnerabilityAssessmentClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ServerVulnerabilityAssessmentClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Removing server vulnerability assessment from a resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-01-01 func (client *ServerVulnerabilityAssessmentClient) deleteOperation(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string, options *ServerVulnerabilityAssessmentClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, resourceNamespace, resourceType, resourceName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -189,7 +181,7 @@ func (client *ServerVulnerabilityAssessmentClient) deleteCreateRequest(ctx conte } urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) urlPath = strings.ReplaceAll(urlPath, "{serverVulnerabilityAssessment}", url.PathEscape("default")) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -202,19 +194,20 @@ func (client *ServerVulnerabilityAssessmentClient) deleteCreateRequest(ctx conte // Get - Gets a server vulnerability assessment onboarding statuses on a given resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-01-01 -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// resourceNamespace - The Namespace of the resource. -// resourceType - The type of the resource. -// resourceName - Name of the resource. -// options - ServerVulnerabilityAssessmentClientGetOptions contains the optional parameters for the ServerVulnerabilityAssessmentClient.Get -// method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - resourceNamespace - The Namespace of the resource. +// - resourceType - The type of the resource. +// - resourceName - Name of the resource. +// - options - ServerVulnerabilityAssessmentClientGetOptions contains the optional parameters for the ServerVulnerabilityAssessmentClient.Get +// method. func (client *ServerVulnerabilityAssessmentClient) Get(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string, options *ServerVulnerabilityAssessmentClientGetOptions) (ServerVulnerabilityAssessmentClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, resourceNamespace, resourceType, resourceName, options) if err != nil { return ServerVulnerabilityAssessmentClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ServerVulnerabilityAssessmentClientGetResponse{}, err } @@ -248,7 +241,7 @@ func (client *ServerVulnerabilityAssessmentClient) getCreateRequest(ctx context. } urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) urlPath = strings.ReplaceAll(urlPath, "{serverVulnerabilityAssessment}", url.PathEscape("default")) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -270,19 +263,20 @@ func (client *ServerVulnerabilityAssessmentClient) getHandleResponse(resp *http. // ListByExtendedResource - Gets a list of server vulnerability assessment onboarding statuses on a given resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-01-01 -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// resourceNamespace - The Namespace of the resource. -// resourceType - The type of the resource. -// resourceName - Name of the resource. -// options - ServerVulnerabilityAssessmentClientListByExtendedResourceOptions contains the optional parameters for the ServerVulnerabilityAssessmentClient.ListByExtendedResource -// method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - resourceNamespace - The Namespace of the resource. +// - resourceType - The type of the resource. +// - resourceName - Name of the resource. +// - options - ServerVulnerabilityAssessmentClientListByExtendedResourceOptions contains the optional parameters for the ServerVulnerabilityAssessmentClient.ListByExtendedResource +// method. func (client *ServerVulnerabilityAssessmentClient) ListByExtendedResource(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string, options *ServerVulnerabilityAssessmentClientListByExtendedResourceOptions) (ServerVulnerabilityAssessmentClientListByExtendedResourceResponse, error) { req, err := client.listByExtendedResourceCreateRequest(ctx, resourceGroupName, resourceNamespace, resourceType, resourceName, options) if err != nil { return ServerVulnerabilityAssessmentClientListByExtendedResourceResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ServerVulnerabilityAssessmentClientListByExtendedResourceResponse{}, err } @@ -315,7 +309,7 @@ func (client *ServerVulnerabilityAssessmentClient) listByExtendedResourceCreateR return nil, errors.New("parameter resourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/security/armsecurity/servervulnerabilityassessment_client_example_test.go b/sdk/resourcemanager/security/armsecurity/servervulnerabilityassessment_client_example_test.go deleted file mode 100644 index 7c6c55f75211..000000000000 --- a/sdk/resourcemanager/security/armsecurity/servervulnerabilityassessment_client_example_test.go +++ /dev/null @@ -1,93 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. - -package armsecurity_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/ServerVulnerabilityAssessments/ListByExtendedResourceServerVulnerabilityAssessments_example.json -func ExampleServerVulnerabilityAssessmentClient_ListByExtendedResource() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewServerVulnerabilityAssessmentClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.ListByExtendedResource(ctx, "rg1", "Microsoft.Compute", "virtualMachines", "vm1", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/ServerVulnerabilityAssessments/GetServerVulnerabilityAssessments_example.json -func ExampleServerVulnerabilityAssessmentClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewServerVulnerabilityAssessmentClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "rg1", "Microsoft.Compute", "virtualMachines", "vm1", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/ServerVulnerabilityAssessments/CreateServerVulnerabilityAssessments_example.json -func ExampleServerVulnerabilityAssessmentClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewServerVulnerabilityAssessmentClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.CreateOrUpdate(ctx, "rg1", "Microsoft.Compute", "virtualMachines", "vm1", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/ServerVulnerabilityAssessments/DeleteServerVulnerabilityAssessments_example.json -func ExampleServerVulnerabilityAssessmentClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewServerVulnerabilityAssessmentClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginDelete(ctx, "rg1", "Microsoft.Compute", "virtualMachines", "vm1", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} diff --git a/sdk/resourcemanager/security/armsecurity/settings_client.go b/sdk/resourcemanager/security/armsecurity/settings_client.go index 8642ee568ed1..860e77207af2 100644 --- a/sdk/resourcemanager/security/armsecurity/settings_client.go +++ b/sdk/resourcemanager/security/armsecurity/settings_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,46 +24,38 @@ import ( // SettingsClient contains the methods for the Settings group. // Don't use this type directly, use NewSettingsClient() instead. type SettingsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewSettingsClient creates a new instance of SettingsClient with the specified values. -// subscriptionID - Azure subscription ID -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure subscription ID +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewSettingsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SettingsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".SettingsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &SettingsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Settings of different configurations in Microsoft Defender for Cloud // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-05-01 -// settingName - The name of the setting -// options - SettingsClientGetOptions contains the optional parameters for the SettingsClient.Get method. +// - settingName - The name of the setting +// - options - SettingsClientGetOptions contains the optional parameters for the SettingsClient.Get method. func (client *SettingsClient) Get(ctx context.Context, settingName SettingName, options *SettingsClientGetOptions) (SettingsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, settingName, options) if err != nil { return SettingsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SettingsClientGetResponse{}, err } @@ -86,7 +76,7 @@ func (client *SettingsClient) getCreateRequest(ctx context.Context, settingName return nil, errors.New("parameter settingName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{settingName}", url.PathEscape(string(settingName))) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -107,8 +97,9 @@ func (client *SettingsClient) getHandleResponse(resp *http.Response) (SettingsCl } // NewListPager - Settings about different configurations in Microsoft Defender for Cloud +// // Generated from API version 2022-05-01 -// options - SettingsClientListOptions contains the optional parameters for the SettingsClient.List method. +// - options - SettingsClientListOptions contains the optional parameters for the SettingsClient.NewListPager method. func (client *SettingsClient) NewListPager(options *SettingsClientListOptions) *runtime.Pager[SettingsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[SettingsClientListResponse]{ More: func(page SettingsClientListResponse) bool { @@ -125,7 +116,7 @@ func (client *SettingsClient) NewListPager(options *SettingsClientListOptions) * if err != nil { return SettingsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SettingsClientListResponse{}, err } @@ -144,7 +135,7 @@ func (client *SettingsClient) listCreateRequest(ctx context.Context, options *Se return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -166,16 +157,17 @@ func (client *SettingsClient) listHandleResponse(resp *http.Response) (SettingsC // Update - updating settings about different configurations in Microsoft Defender for Cloud // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-05-01 -// settingName - The name of the setting -// setting - Setting object -// options - SettingsClientUpdateOptions contains the optional parameters for the SettingsClient.Update method. +// - settingName - The name of the setting +// - setting - Setting object +// - options - SettingsClientUpdateOptions contains the optional parameters for the SettingsClient.Update method. func (client *SettingsClient) Update(ctx context.Context, settingName SettingName, setting SettingClassification, options *SettingsClientUpdateOptions) (SettingsClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, settingName, setting, options) if err != nil { return SettingsClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SettingsClientUpdateResponse{}, err } @@ -196,7 +188,7 @@ func (client *SettingsClient) updateCreateRequest(ctx context.Context, settingNa return nil, errors.New("parameter settingName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{settingName}", url.PathEscape(string(settingName))) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/security/armsecurity/settings_client_example_test.go b/sdk/resourcemanager/security/armsecurity/settings_client_example_test.go deleted file mode 100644 index eec48c963490..000000000000 --- a/sdk/resourcemanager/security/armsecurity/settings_client_example_test.go +++ /dev/null @@ -1,85 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. - -package armsecurity_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2022-05-01/examples/Settings/GetSettings_example.json -func ExampleSettingsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewSettingsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2022-05-01/examples/Settings/GetSetting_example.json -func ExampleSettingsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewSettingsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, armsecurity.SettingNameMCAS, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2022-05-01/examples/Settings/UpdateSetting_example.json -func ExampleSettingsClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewSettingsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Update(ctx, armsecurity.SettingNameMCAS, &armsecurity.DataExportSettings{ - Kind: to.Ptr(armsecurity.SettingKindDataExportSettings), - Properties: &armsecurity.DataExportSettingProperties{ - Enabled: to.Ptr(true), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/security/armsecurity/softwareinventories_client.go b/sdk/resourcemanager/security/armsecurity/softwareinventories_client.go index f485c28ea71e..a7211b312239 100644 --- a/sdk/resourcemanager/security/armsecurity/softwareinventories_client.go +++ b/sdk/resourcemanager/security/armsecurity/softwareinventories_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,50 +24,42 @@ import ( // SoftwareInventoriesClient contains the methods for the SoftwareInventories group. // Don't use this type directly, use NewSoftwareInventoriesClient() instead. type SoftwareInventoriesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewSoftwareInventoriesClient creates a new instance of SoftwareInventoriesClient with the specified values. -// subscriptionID - Azure subscription ID -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure subscription ID +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewSoftwareInventoriesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SoftwareInventoriesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".SoftwareInventoriesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &SoftwareInventoriesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Gets a single software data of the virtual machine. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-05-01-preview -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// resourceNamespace - The namespace of the resource. -// resourceType - The type of the resource. -// resourceName - Name of the resource. -// softwareName - Name of the installed software. -// options - SoftwareInventoriesClientGetOptions contains the optional parameters for the SoftwareInventoriesClient.Get method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - resourceNamespace - The namespace of the resource. +// - resourceType - The type of the resource. +// - resourceName - Name of the resource. +// - softwareName - Name of the installed software. +// - options - SoftwareInventoriesClientGetOptions contains the optional parameters for the SoftwareInventoriesClient.Get method. func (client *SoftwareInventoriesClient) Get(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string, softwareName string, options *SoftwareInventoriesClientGetOptions) (SoftwareInventoriesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, resourceNamespace, resourceType, resourceName, softwareName, options) if err != nil { return SoftwareInventoriesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SoftwareInventoriesClientGetResponse{}, err } @@ -106,7 +96,7 @@ func (client *SoftwareInventoriesClient) getCreateRequest(ctx context.Context, r return nil, errors.New("parameter softwareName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{softwareName}", url.PathEscape(softwareName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -127,13 +117,14 @@ func (client *SoftwareInventoriesClient) getHandleResponse(resp *http.Response) } // NewListByExtendedResourcePager - Gets the software inventory of the virtual machine. +// // Generated from API version 2021-05-01-preview -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// resourceNamespace - The namespace of the resource. -// resourceType - The type of the resource. -// resourceName - Name of the resource. -// options - SoftwareInventoriesClientListByExtendedResourceOptions contains the optional parameters for the SoftwareInventoriesClient.ListByExtendedResource -// method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - resourceNamespace - The namespace of the resource. +// - resourceType - The type of the resource. +// - resourceName - Name of the resource. +// - options - SoftwareInventoriesClientListByExtendedResourceOptions contains the optional parameters for the SoftwareInventoriesClient.NewListByExtendedResourcePager +// method. func (client *SoftwareInventoriesClient) NewListByExtendedResourcePager(resourceGroupName string, resourceNamespace string, resourceType string, resourceName string, options *SoftwareInventoriesClientListByExtendedResourceOptions) *runtime.Pager[SoftwareInventoriesClientListByExtendedResourceResponse] { return runtime.NewPager(runtime.PagingHandler[SoftwareInventoriesClientListByExtendedResourceResponse]{ More: func(page SoftwareInventoriesClientListByExtendedResourceResponse) bool { @@ -150,7 +141,7 @@ func (client *SoftwareInventoriesClient) NewListByExtendedResourcePager(resource if err != nil { return SoftwareInventoriesClientListByExtendedResourceResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SoftwareInventoriesClientListByExtendedResourceResponse{}, err } @@ -185,7 +176,7 @@ func (client *SoftwareInventoriesClient) listByExtendedResourceCreateRequest(ctx return nil, errors.New("parameter resourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -206,9 +197,10 @@ func (client *SoftwareInventoriesClient) listByExtendedResourceHandleResponse(re } // NewListBySubscriptionPager - Gets the software inventory of all virtual machines in the subscriptions. +// // Generated from API version 2021-05-01-preview -// options - SoftwareInventoriesClientListBySubscriptionOptions contains the optional parameters for the SoftwareInventoriesClient.ListBySubscription -// method. +// - options - SoftwareInventoriesClientListBySubscriptionOptions contains the optional parameters for the SoftwareInventoriesClient.NewListBySubscriptionPager +// method. func (client *SoftwareInventoriesClient) NewListBySubscriptionPager(options *SoftwareInventoriesClientListBySubscriptionOptions) *runtime.Pager[SoftwareInventoriesClientListBySubscriptionResponse] { return runtime.NewPager(runtime.PagingHandler[SoftwareInventoriesClientListBySubscriptionResponse]{ More: func(page SoftwareInventoriesClientListBySubscriptionResponse) bool { @@ -225,7 +217,7 @@ func (client *SoftwareInventoriesClient) NewListBySubscriptionPager(options *Sof if err != nil { return SoftwareInventoriesClientListBySubscriptionResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SoftwareInventoriesClientListBySubscriptionResponse{}, err } @@ -244,7 +236,7 @@ func (client *SoftwareInventoriesClient) listBySubscriptionCreateRequest(ctx con return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/security/armsecurity/softwareinventories_client_example_test.go b/sdk/resourcemanager/security/armsecurity/softwareinventories_client_example_test.go deleted file mode 100644 index 25c35cd53566..000000000000 --- a/sdk/resourcemanager/security/armsecurity/softwareinventories_client_example_test.go +++ /dev/null @@ -1,84 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. - -package armsecurity_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2021-05-01-preview/examples/SoftwareInventories/ListByExtendedResourceSoftwareInventories_example.json -func ExampleSoftwareInventoriesClient_NewListByExtendedResourcePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewSoftwareInventoriesClient("e5d1b86c-3051-44d5-8802-aa65d45a279b", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByExtendedResourcePager("EITAN-TESTS", "Microsoft.Compute", "virtualMachines", "Eitan-Test1", nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2021-05-01-preview/examples/SoftwareInventories/ListBySubscriptionSoftwareInventories_example.json -func ExampleSoftwareInventoriesClient_NewListBySubscriptionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewSoftwareInventoriesClient("e5d1b86c-3051-44d5-8802-aa65d45a279b", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListBySubscriptionPager(nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2021-05-01-preview/examples/SoftwareInventories/GetSoftware_example.json -func ExampleSoftwareInventoriesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewSoftwareInventoriesClient("e5d1b86c-3051-44d5-8802-aa65d45a279b", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "EITAN-TESTS", "Microsoft.Compute", "virtualMachines", "Eitan-Test1", "outlook_16.0.10371.20060", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/security/armsecurity/solutions_client.go b/sdk/resourcemanager/security/armsecurity/solutions_client.go index 590829c14c93..acda20886458 100644 --- a/sdk/resourcemanager/security/armsecurity/solutions_client.go +++ b/sdk/resourcemanager/security/armsecurity/solutions_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,48 +24,40 @@ import ( // SolutionsClient contains the methods for the SecuritySolutions group. // Don't use this type directly, use NewSolutionsClient() instead. type SolutionsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewSolutionsClient creates a new instance of SolutionsClient with the specified values. -// subscriptionID - Azure subscription ID -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure subscription ID +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewSolutionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SolutionsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".SolutionsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &SolutionsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Gets a specific Security Solution. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-01-01 -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations -// securitySolutionName - Name of security solution. -// options - SolutionsClientGetOptions contains the optional parameters for the SolutionsClient.Get method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations +// - securitySolutionName - Name of security solution. +// - options - SolutionsClientGetOptions contains the optional parameters for the SolutionsClient.Get method. func (client *SolutionsClient) Get(ctx context.Context, resourceGroupName string, ascLocation string, securitySolutionName string, options *SolutionsClientGetOptions) (SolutionsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, ascLocation, securitySolutionName, options) if err != nil { return SolutionsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SolutionsClientGetResponse{}, err } @@ -96,7 +86,7 @@ func (client *SolutionsClient) getCreateRequest(ctx context.Context, resourceGro return nil, errors.New("parameter securitySolutionName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{securitySolutionName}", url.PathEscape(securitySolutionName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -117,8 +107,9 @@ func (client *SolutionsClient) getHandleResponse(resp *http.Response) (Solutions } // NewListPager - Gets a list of Security Solutions for the subscription. +// // Generated from API version 2020-01-01 -// options - SolutionsClientListOptions contains the optional parameters for the SolutionsClient.List method. +// - options - SolutionsClientListOptions contains the optional parameters for the SolutionsClient.NewListPager method. func (client *SolutionsClient) NewListPager(options *SolutionsClientListOptions) *runtime.Pager[SolutionsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[SolutionsClientListResponse]{ More: func(page SolutionsClientListResponse) bool { @@ -135,7 +126,7 @@ func (client *SolutionsClient) NewListPager(options *SolutionsClientListOptions) if err != nil { return SolutionsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SolutionsClientListResponse{}, err } @@ -154,7 +145,7 @@ func (client *SolutionsClient) listCreateRequest(ctx context.Context, options *S return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/security/armsecurity/solutions_client_example_test.go b/sdk/resourcemanager/security/armsecurity/solutions_client_example_test.go deleted file mode 100644 index f80710a69410..000000000000 --- a/sdk/resourcemanager/security/armsecurity/solutions_client_example_test.go +++ /dev/null @@ -1,60 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. - -package armsecurity_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/SecuritySolutions/GetSecuritySolutionsSubscription_example.json -func ExampleSolutionsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewSolutionsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/SecuritySolutions/GetSecuritySolutionsResourceGroupLocation_example.json -func ExampleSolutionsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewSolutionsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "myRg2", "centralus", "paloalto7", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/security/armsecurity/solutionsreferencedata_client.go b/sdk/resourcemanager/security/armsecurity/solutionsreferencedata_client.go index 6b87b007d8fb..751a959fa8eb 100644 --- a/sdk/resourcemanager/security/armsecurity/solutionsreferencedata_client.go +++ b/sdk/resourcemanager/security/armsecurity/solutionsreferencedata_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,46 +24,38 @@ import ( // SolutionsReferenceDataClient contains the methods for the SecuritySolutionsReferenceData group. // Don't use this type directly, use NewSolutionsReferenceDataClient() instead. type SolutionsReferenceDataClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewSolutionsReferenceDataClient creates a new instance of SolutionsReferenceDataClient with the specified values. -// subscriptionID - Azure subscription ID -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure subscription ID +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewSolutionsReferenceDataClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SolutionsReferenceDataClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".SolutionsReferenceDataClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &SolutionsReferenceDataClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // List - Gets a list of all supported Security Solutions for the subscription. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-01-01 -// options - SolutionsReferenceDataClientListOptions contains the optional parameters for the SolutionsReferenceDataClient.List -// method. +// - options - SolutionsReferenceDataClientListOptions contains the optional parameters for the SolutionsReferenceDataClient.List +// method. func (client *SolutionsReferenceDataClient) List(ctx context.Context, options *SolutionsReferenceDataClientListOptions) (SolutionsReferenceDataClientListResponse, error) { req, err := client.listCreateRequest(ctx, options) if err != nil { return SolutionsReferenceDataClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SolutionsReferenceDataClientListResponse{}, err } @@ -82,7 +72,7 @@ func (client *SolutionsReferenceDataClient) listCreateRequest(ctx context.Contex return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -104,16 +94,17 @@ func (client *SolutionsReferenceDataClient) listHandleResponse(resp *http.Respon // ListByHomeRegion - Gets list of all supported Security Solutions for subscription and location. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-01-01 -// ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations -// options - SolutionsReferenceDataClientListByHomeRegionOptions contains the optional parameters for the SolutionsReferenceDataClient.ListByHomeRegion -// method. +// - ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations +// - options - SolutionsReferenceDataClientListByHomeRegionOptions contains the optional parameters for the SolutionsReferenceDataClient.ListByHomeRegion +// method. func (client *SolutionsReferenceDataClient) ListByHomeRegion(ctx context.Context, ascLocation string, options *SolutionsReferenceDataClientListByHomeRegionOptions) (SolutionsReferenceDataClientListByHomeRegionResponse, error) { req, err := client.listByHomeRegionCreateRequest(ctx, ascLocation, options) if err != nil { return SolutionsReferenceDataClientListByHomeRegionResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SolutionsReferenceDataClientListByHomeRegionResponse{}, err } @@ -134,7 +125,7 @@ func (client *SolutionsReferenceDataClient) listByHomeRegionCreateRequest(ctx co return nil, errors.New("parameter ascLocation cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{ascLocation}", url.PathEscape(ascLocation)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/security/armsecurity/solutionsreferencedata_client_example_test.go b/sdk/resourcemanager/security/armsecurity/solutionsreferencedata_client_example_test.go deleted file mode 100644 index 6549edb6a3cc..000000000000 --- a/sdk/resourcemanager/security/armsecurity/solutionsreferencedata_client_example_test.go +++ /dev/null @@ -1,55 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. - -package armsecurity_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/SecuritySolutionsReferenceData/GetSecuritySolutionsReferenceDataSubscription_example.json -func ExampleSolutionsReferenceDataClient_List() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewSolutionsReferenceDataClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.List(ctx, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/SecuritySolutionsReferenceData/GetSecuritySolutionsReferenceDataSubscriptionLocation_example.json -func ExampleSolutionsReferenceDataClient_ListByHomeRegion() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewSolutionsReferenceDataClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.ListByHomeRegion(ctx, "westcentralus", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/security/armsecurity/sqlvulnerabilityassessmentbaselinerules_client.go b/sdk/resourcemanager/security/armsecurity/sqlvulnerabilityassessmentbaselinerules_client.go index a1763526a948..a2e6df1c9587 100644 --- a/sdk/resourcemanager/security/armsecurity/sqlvulnerabilityassessmentbaselinerules_client.go +++ b/sdk/resourcemanager/security/armsecurity/sqlvulnerabilityassessmentbaselinerules_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,45 +24,37 @@ import ( // SQLVulnerabilityAssessmentBaselineRulesClient contains the methods for the SQLVulnerabilityAssessmentBaselineRules group. // Don't use this type directly, use NewSQLVulnerabilityAssessmentBaselineRulesClient() instead. type SQLVulnerabilityAssessmentBaselineRulesClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewSQLVulnerabilityAssessmentBaselineRulesClient creates a new instance of SQLVulnerabilityAssessmentBaselineRulesClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewSQLVulnerabilityAssessmentBaselineRulesClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*SQLVulnerabilityAssessmentBaselineRulesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".SQLVulnerabilityAssessmentBaselineRulesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &SQLVulnerabilityAssessmentBaselineRulesClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } // Add - Add a list of baseline rules. Will overwrite any previously existing results (for all rules). // If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2020-07-01-preview -// workspaceID - The workspace Id. -// resourceID - The identifier of the resource. -// options - SQLVulnerabilityAssessmentBaselineRulesClientAddOptions contains the optional parameters for the SQLVulnerabilityAssessmentBaselineRulesClient.Add -// method. +// +// Generated from API version 2023-02-01-preview +// - workspaceID - The workspace Id. +// - resourceID - The identifier of the resource. +// - options - SQLVulnerabilityAssessmentBaselineRulesClientAddOptions contains the optional parameters for the SQLVulnerabilityAssessmentBaselineRulesClient.Add +// method. func (client *SQLVulnerabilityAssessmentBaselineRulesClient) Add(ctx context.Context, workspaceID string, resourceID string, options *SQLVulnerabilityAssessmentBaselineRulesClientAddOptions) (SQLVulnerabilityAssessmentBaselineRulesClientAddResponse, error) { req, err := client.addCreateRequest(ctx, workspaceID, resourceID, options) if err != nil { return SQLVulnerabilityAssessmentBaselineRulesClientAddResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLVulnerabilityAssessmentBaselineRulesClientAddResponse{}, err } @@ -78,13 +68,13 @@ func (client *SQLVulnerabilityAssessmentBaselineRulesClient) Add(ctx context.Con func (client *SQLVulnerabilityAssessmentBaselineRulesClient) addCreateRequest(ctx context.Context, workspaceID string, resourceID string, options *SQLVulnerabilityAssessmentBaselineRulesClientAddOptions) (*policy.Request, error) { urlPath := "/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/baselineRules" urlPath = strings.ReplaceAll(urlPath, "{resourceId}", resourceID) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() reqQP.Set("workspaceId", workspaceID) - reqQP.Set("api-version", "2020-07-01-preview") + reqQP.Set("api-version", "2023-02-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.Body != nil { @@ -104,18 +94,19 @@ func (client *SQLVulnerabilityAssessmentBaselineRulesClient) addHandleResponse(r // CreateOrUpdate - Creates a Baseline for a rule in a database. Will overwrite any previously existing results. // If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2020-07-01-preview -// ruleID - The rule Id. -// workspaceID - The workspace Id. -// resourceID - The identifier of the resource. -// options - SQLVulnerabilityAssessmentBaselineRulesClientCreateOrUpdateOptions contains the optional parameters for the SQLVulnerabilityAssessmentBaselineRulesClient.CreateOrUpdate -// method. +// +// Generated from API version 2023-02-01-preview +// - ruleID - The rule Id. +// - workspaceID - The workspace Id. +// - resourceID - The identifier of the resource. +// - options - SQLVulnerabilityAssessmentBaselineRulesClientCreateOrUpdateOptions contains the optional parameters for the SQLVulnerabilityAssessmentBaselineRulesClient.CreateOrUpdate +// method. func (client *SQLVulnerabilityAssessmentBaselineRulesClient) CreateOrUpdate(ctx context.Context, ruleID string, workspaceID string, resourceID string, options *SQLVulnerabilityAssessmentBaselineRulesClientCreateOrUpdateOptions) (SQLVulnerabilityAssessmentBaselineRulesClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, ruleID, workspaceID, resourceID, options) if err != nil { return SQLVulnerabilityAssessmentBaselineRulesClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLVulnerabilityAssessmentBaselineRulesClientCreateOrUpdateResponse{}, err } @@ -133,13 +124,13 @@ func (client *SQLVulnerabilityAssessmentBaselineRulesClient) createOrUpdateCreat } urlPath = strings.ReplaceAll(urlPath, "{ruleId}", url.PathEscape(ruleID)) urlPath = strings.ReplaceAll(urlPath, "{resourceId}", resourceID) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() reqQP.Set("workspaceId", workspaceID) - reqQP.Set("api-version", "2020-07-01-preview") + reqQP.Set("api-version", "2023-02-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.Body != nil { @@ -159,18 +150,19 @@ func (client *SQLVulnerabilityAssessmentBaselineRulesClient) createOrUpdateHandl // Delete - Deletes a rule from the Baseline of a given database. // If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2020-07-01-preview -// ruleID - The rule Id. -// workspaceID - The workspace Id. -// resourceID - The identifier of the resource. -// options - SQLVulnerabilityAssessmentBaselineRulesClientDeleteOptions contains the optional parameters for the SQLVulnerabilityAssessmentBaselineRulesClient.Delete -// method. +// +// Generated from API version 2023-02-01-preview +// - ruleID - The rule Id. +// - workspaceID - The workspace Id. +// - resourceID - The identifier of the resource. +// - options - SQLVulnerabilityAssessmentBaselineRulesClientDeleteOptions contains the optional parameters for the SQLVulnerabilityAssessmentBaselineRulesClient.Delete +// method. func (client *SQLVulnerabilityAssessmentBaselineRulesClient) Delete(ctx context.Context, ruleID string, workspaceID string, resourceID string, options *SQLVulnerabilityAssessmentBaselineRulesClientDeleteOptions) (SQLVulnerabilityAssessmentBaselineRulesClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, ruleID, workspaceID, resourceID, options) if err != nil { return SQLVulnerabilityAssessmentBaselineRulesClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLVulnerabilityAssessmentBaselineRulesClientDeleteResponse{}, err } @@ -188,13 +180,13 @@ func (client *SQLVulnerabilityAssessmentBaselineRulesClient) deleteCreateRequest } urlPath = strings.ReplaceAll(urlPath, "{ruleId}", url.PathEscape(ruleID)) urlPath = strings.ReplaceAll(urlPath, "{resourceId}", resourceID) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() reqQP.Set("workspaceId", workspaceID) - reqQP.Set("api-version", "2020-07-01-preview") + reqQP.Set("api-version", "2023-02-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -202,18 +194,19 @@ func (client *SQLVulnerabilityAssessmentBaselineRulesClient) deleteCreateRequest // Get - Gets the results for a given rule in the Baseline. // If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2020-07-01-preview -// ruleID - The rule Id. -// workspaceID - The workspace Id. -// resourceID - The identifier of the resource. -// options - SQLVulnerabilityAssessmentBaselineRulesClientGetOptions contains the optional parameters for the SQLVulnerabilityAssessmentBaselineRulesClient.Get -// method. +// +// Generated from API version 2023-02-01-preview +// - ruleID - The rule Id. +// - workspaceID - The workspace Id. +// - resourceID - The identifier of the resource. +// - options - SQLVulnerabilityAssessmentBaselineRulesClientGetOptions contains the optional parameters for the SQLVulnerabilityAssessmentBaselineRulesClient.Get +// method. func (client *SQLVulnerabilityAssessmentBaselineRulesClient) Get(ctx context.Context, ruleID string, workspaceID string, resourceID string, options *SQLVulnerabilityAssessmentBaselineRulesClientGetOptions) (SQLVulnerabilityAssessmentBaselineRulesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, ruleID, workspaceID, resourceID, options) if err != nil { return SQLVulnerabilityAssessmentBaselineRulesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLVulnerabilityAssessmentBaselineRulesClientGetResponse{}, err } @@ -231,13 +224,13 @@ func (client *SQLVulnerabilityAssessmentBaselineRulesClient) getCreateRequest(ct } urlPath = strings.ReplaceAll(urlPath, "{ruleId}", url.PathEscape(ruleID)) urlPath = strings.ReplaceAll(urlPath, "{resourceId}", resourceID) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() reqQP.Set("workspaceId", workspaceID) - reqQP.Set("api-version", "2020-07-01-preview") + reqQP.Set("api-version", "2023-02-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -254,17 +247,18 @@ func (client *SQLVulnerabilityAssessmentBaselineRulesClient) getHandleResponse(r // List - Gets the results for all rules in the Baseline. // If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2020-07-01-preview -// workspaceID - The workspace Id. -// resourceID - The identifier of the resource. -// options - SQLVulnerabilityAssessmentBaselineRulesClientListOptions contains the optional parameters for the SQLVulnerabilityAssessmentBaselineRulesClient.List -// method. +// +// Generated from API version 2023-02-01-preview +// - workspaceID - The workspace Id. +// - resourceID - The identifier of the resource. +// - options - SQLVulnerabilityAssessmentBaselineRulesClientListOptions contains the optional parameters for the SQLVulnerabilityAssessmentBaselineRulesClient.List +// method. func (client *SQLVulnerabilityAssessmentBaselineRulesClient) List(ctx context.Context, workspaceID string, resourceID string, options *SQLVulnerabilityAssessmentBaselineRulesClientListOptions) (SQLVulnerabilityAssessmentBaselineRulesClientListResponse, error) { req, err := client.listCreateRequest(ctx, workspaceID, resourceID, options) if err != nil { return SQLVulnerabilityAssessmentBaselineRulesClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLVulnerabilityAssessmentBaselineRulesClientListResponse{}, err } @@ -278,13 +272,13 @@ func (client *SQLVulnerabilityAssessmentBaselineRulesClient) List(ctx context.Co func (client *SQLVulnerabilityAssessmentBaselineRulesClient) listCreateRequest(ctx context.Context, workspaceID string, resourceID string, options *SQLVulnerabilityAssessmentBaselineRulesClientListOptions) (*policy.Request, error) { urlPath := "/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/baselineRules" urlPath = strings.ReplaceAll(urlPath, "{resourceId}", resourceID) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() reqQP.Set("workspaceId", workspaceID) - reqQP.Set("api-version", "2020-07-01-preview") + reqQP.Set("api-version", "2023-02-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/security/armsecurity/sqlvulnerabilityassessmentbaselinerules_client_example_test.go b/sdk/resourcemanager/security/armsecurity/sqlvulnerabilityassessmentbaselinerules_client_example_test.go deleted file mode 100644 index 2a22b9400044..000000000000 --- a/sdk/resourcemanager/security/armsecurity/sqlvulnerabilityassessmentbaselinerules_client_example_test.go +++ /dev/null @@ -1,184 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. - -package armsecurity_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2020-07-01-preview/examples/sqlVulnerabilityAssessmentsBaselineRuleOperations/ArcMachineBaselineRules_Put.json -func ExampleSQLVulnerabilityAssessmentBaselineRulesClient_CreateOrUpdate_createABaseline() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewSQLVulnerabilityAssessmentBaselineRulesClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdate(ctx, "VA1234", "55555555-6666-7777-8888-999999999999", "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Rg/providers/Microsoft.HybridCompute/machines/MyMachine/sqlServers/server1/databases/master", &armsecurity.SQLVulnerabilityAssessmentBaselineRulesClientCreateOrUpdateOptions{Body: &armsecurity.RuleResultsInput{ - LatestScan: to.Ptr(false), - Results: [][]*string{ - { - to.Ptr("userA"), - to.Ptr("SELECT")}, - { - to.Ptr("userB"), - to.Ptr("SELECT")}}, - }, - }) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2020-07-01-preview/examples/sqlVulnerabilityAssessmentsBaselineRuleOperations/ArcMachineBaselineRules_PutLatest.json -func ExampleSQLVulnerabilityAssessmentBaselineRulesClient_CreateOrUpdate_createABaselineUsingTheLatestScanResults() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewSQLVulnerabilityAssessmentBaselineRulesClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdate(ctx, "VA1234", "55555555-6666-7777-8888-999999999999", "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Rg/providers/Microsoft.HybridCompute/machines/MyMachine/sqlServers/server1/databases/master", &armsecurity.SQLVulnerabilityAssessmentBaselineRulesClientCreateOrUpdateOptions{Body: &armsecurity.RuleResultsInput{ - LatestScan: to.Ptr(true), - Results: [][]*string{}, - }, - }) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2020-07-01-preview/examples/sqlVulnerabilityAssessmentsBaselineRuleOperations/ArcMachineBaselineRules_Get.json -func ExampleSQLVulnerabilityAssessmentBaselineRulesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewSQLVulnerabilityAssessmentBaselineRulesClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "VA1234", "55555555-6666-7777-8888-999999999999", "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Rg/providers/Microsoft.HybridCompute/machines/MyMachine/sqlServers/server1/databases/master", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2020-07-01-preview/examples/sqlVulnerabilityAssessmentsBaselineRuleOperations/ArcMachineBaselineRules_Delete.json -func ExampleSQLVulnerabilityAssessmentBaselineRulesClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewSQLVulnerabilityAssessmentBaselineRulesClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, "VA1234", "55555555-6666-7777-8888-999999999999", "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Rg/providers/Microsoft.HybridCompute/machines/MyMachine/sqlServers/server1/databases/master", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2020-07-01-preview/examples/sqlVulnerabilityAssessmentsBaselineRuleOperations/ArcMachineBaselineRules_List.json -func ExampleSQLVulnerabilityAssessmentBaselineRulesClient_List() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewSQLVulnerabilityAssessmentBaselineRulesClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.List(ctx, "55555555-6666-7777-8888-999999999999", "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Rg/providers/Microsoft.HybridCompute/machines/MyMachine/sqlServers/server1/databases/master", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2020-07-01-preview/examples/sqlVulnerabilityAssessmentsBaselineRuleOperations/ArcMachineBaselineRules_Add.json -func ExampleSQLVulnerabilityAssessmentBaselineRulesClient_Add_createABaselineForAllRules() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewSQLVulnerabilityAssessmentBaselineRulesClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Add(ctx, "55555555-6666-7777-8888-999999999999", "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Rg/providers/Microsoft.HybridCompute/machines/MyMachine/sqlServers/server1/databases/master", &armsecurity.SQLVulnerabilityAssessmentBaselineRulesClientAddOptions{Body: &armsecurity.RulesResultsInput{ - LatestScan: to.Ptr(false), - Results: map[string][][]*string{ - "VA1234": { - { - to.Ptr("userA"), - to.Ptr("SELECT")}, - { - to.Ptr("userB"), - to.Ptr("SELECT")}}, - "VA5678": { - { - to.Ptr("Test"), - to.Ptr("0.0.0.0"), - to.Ptr("125.125.125.125")}}, - }, - }, - }) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2020-07-01-preview/examples/sqlVulnerabilityAssessmentsBaselineRuleOperations/ArcMachineBaselineRules_AddLatest.json -func ExampleSQLVulnerabilityAssessmentBaselineRulesClient_Add_createABaselineForAllRulesUsingTheLatestScanResults() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewSQLVulnerabilityAssessmentBaselineRulesClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Add(ctx, "55555555-6666-7777-8888-999999999999", "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Rg/providers/Microsoft.HybridCompute/machines/MyMachine/sqlServers/server1/databases/master", &armsecurity.SQLVulnerabilityAssessmentBaselineRulesClientAddOptions{Body: &armsecurity.RulesResultsInput{ - LatestScan: to.Ptr(true), - Results: map[string][][]*string{}, - }, - }) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/security/armsecurity/sqlvulnerabilityassessmentscanresults_client.go b/sdk/resourcemanager/security/armsecurity/sqlvulnerabilityassessmentscanresults_client.go index cfe79a9f6c49..22855d050c2f 100644 --- a/sdk/resourcemanager/security/armsecurity/sqlvulnerabilityassessmentscanresults_client.go +++ b/sdk/resourcemanager/security/armsecurity/sqlvulnerabilityassessmentscanresults_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,47 +24,39 @@ import ( // SQLVulnerabilityAssessmentScanResultsClient contains the methods for the SQLVulnerabilityAssessmentScanResults group. // Don't use this type directly, use NewSQLVulnerabilityAssessmentScanResultsClient() instead. type SQLVulnerabilityAssessmentScanResultsClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewSQLVulnerabilityAssessmentScanResultsClient creates a new instance of SQLVulnerabilityAssessmentScanResultsClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewSQLVulnerabilityAssessmentScanResultsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*SQLVulnerabilityAssessmentScanResultsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".SQLVulnerabilityAssessmentScanResultsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &SQLVulnerabilityAssessmentScanResultsClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Gets the scan results of a single rule in a scan record. // If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2020-07-01-preview -// scanID - The scan Id. Type 'latest' to get the scan results for the latest scan. -// scanResultID - The rule Id of the results. -// workspaceID - The workspace Id. -// resourceID - The identifier of the resource. -// options - SQLVulnerabilityAssessmentScanResultsClientGetOptions contains the optional parameters for the SQLVulnerabilityAssessmentScanResultsClient.Get -// method. +// +// Generated from API version 2023-02-01-preview +// - scanID - The scan Id. Type 'latest' to get the scan results for the latest scan. +// - scanResultID - The rule Id of the results. +// - workspaceID - The workspace Id. +// - resourceID - The identifier of the resource. +// - options - SQLVulnerabilityAssessmentScanResultsClientGetOptions contains the optional parameters for the SQLVulnerabilityAssessmentScanResultsClient.Get +// method. func (client *SQLVulnerabilityAssessmentScanResultsClient) Get(ctx context.Context, scanID string, scanResultID string, workspaceID string, resourceID string, options *SQLVulnerabilityAssessmentScanResultsClientGetOptions) (SQLVulnerabilityAssessmentScanResultsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, scanID, scanResultID, workspaceID, resourceID, options) if err != nil { return SQLVulnerabilityAssessmentScanResultsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLVulnerabilityAssessmentScanResultsClientGetResponse{}, err } @@ -88,13 +78,13 @@ func (client *SQLVulnerabilityAssessmentScanResultsClient) getCreateRequest(ctx } urlPath = strings.ReplaceAll(urlPath, "{scanResultId}", url.PathEscape(scanResultID)) urlPath = strings.ReplaceAll(urlPath, "{resourceId}", resourceID) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() reqQP.Set("workspaceId", workspaceID) - reqQP.Set("api-version", "2020-07-01-preview") + reqQP.Set("api-version", "2023-02-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -111,18 +101,19 @@ func (client *SQLVulnerabilityAssessmentScanResultsClient) getHandleResponse(res // List - Gets a list of scan results for a single scan record. // If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2020-07-01-preview -// scanID - The scan Id. Type 'latest' to get the scan results for the latest scan. -// workspaceID - The workspace Id. -// resourceID - The identifier of the resource. -// options - SQLVulnerabilityAssessmentScanResultsClientListOptions contains the optional parameters for the SQLVulnerabilityAssessmentScanResultsClient.List -// method. +// +// Generated from API version 2023-02-01-preview +// - scanID - The scan Id. Type 'latest' to get the scan results for the latest scan. +// - workspaceID - The workspace Id. +// - resourceID - The identifier of the resource. +// - options - SQLVulnerabilityAssessmentScanResultsClientListOptions contains the optional parameters for the SQLVulnerabilityAssessmentScanResultsClient.List +// method. func (client *SQLVulnerabilityAssessmentScanResultsClient) List(ctx context.Context, scanID string, workspaceID string, resourceID string, options *SQLVulnerabilityAssessmentScanResultsClientListOptions) (SQLVulnerabilityAssessmentScanResultsClientListResponse, error) { req, err := client.listCreateRequest(ctx, scanID, workspaceID, resourceID, options) if err != nil { return SQLVulnerabilityAssessmentScanResultsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLVulnerabilityAssessmentScanResultsClientListResponse{}, err } @@ -140,13 +131,13 @@ func (client *SQLVulnerabilityAssessmentScanResultsClient) listCreateRequest(ctx } urlPath = strings.ReplaceAll(urlPath, "{scanId}", url.PathEscape(scanID)) urlPath = strings.ReplaceAll(urlPath, "{resourceId}", resourceID) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() reqQP.Set("workspaceId", workspaceID) - reqQP.Set("api-version", "2020-07-01-preview") + reqQP.Set("api-version", "2023-02-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/security/armsecurity/sqlvulnerabilityassessmentscanresults_client_example_test.go b/sdk/resourcemanager/security/armsecurity/sqlvulnerabilityassessmentscanresults_client_example_test.go deleted file mode 100644 index 4dd6cf8aa996..000000000000 --- a/sdk/resourcemanager/security/armsecurity/sqlvulnerabilityassessmentscanresults_client_example_test.go +++ /dev/null @@ -1,93 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. - -package armsecurity_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2020-07-01-preview/examples/sqlVulnerabilityAssessmentsScanResultsOperations/ArcMachineScanResults_Get.json -func ExampleSQLVulnerabilityAssessmentScanResultsClient_Get_getScanDetailsOfAScanRecord() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewSQLVulnerabilityAssessmentScanResultsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "Scheduled-20200623", "VA2063", "55555555-6666-7777-8888-999999999999", "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Rg/providers/Microsoft.HybridCompute/machines/MyMachine/sqlServers/server1/databases/master", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2020-07-01-preview/examples/sqlVulnerabilityAssessmentsScanResultsOperations/ArcMachineScanResults_GetLatest.json -func ExampleSQLVulnerabilityAssessmentScanResultsClient_Get_getScanDetailsOfTheLatestScanRecord() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewSQLVulnerabilityAssessmentScanResultsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "latest", "VA2063", "55555555-6666-7777-8888-999999999999", "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Rg/providers/Microsoft.HybridCompute/machines/MyMachine/sqlServers/server1/databases/master", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2020-07-01-preview/examples/sqlVulnerabilityAssessmentsScanResultsOperations/ArcMachineScanResults_List.json -func ExampleSQLVulnerabilityAssessmentScanResultsClient_List_listScanResults() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewSQLVulnerabilityAssessmentScanResultsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.List(ctx, "Scheduled-20200623", "55555555-6666-7777-8888-999999999999", "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Rg/providers/Microsoft.HybridCompute/machines/MyMachine/sqlServers/server1/databases/master", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2020-07-01-preview/examples/sqlVulnerabilityAssessmentsScanResultsOperations/ArcMachineScanResults_ListLatest.json -func ExampleSQLVulnerabilityAssessmentScanResultsClient_List_listScanResultsOfTheLatestScan() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewSQLVulnerabilityAssessmentScanResultsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.List(ctx, "latest", "55555555-6666-7777-8888-999999999999", "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Rg/providers/Microsoft.HybridCompute/machines/MyMachine/sqlServers/server1/databases/master", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/security/armsecurity/sqlvulnerabilityassessmentscans_client.go b/sdk/resourcemanager/security/armsecurity/sqlvulnerabilityassessmentscans_client.go index 901be98f3029..94d0329fa054 100644 --- a/sdk/resourcemanager/security/armsecurity/sqlvulnerabilityassessmentscans_client.go +++ b/sdk/resourcemanager/security/armsecurity/sqlvulnerabilityassessmentscans_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,46 +24,38 @@ import ( // SQLVulnerabilityAssessmentScansClient contains the methods for the SQLVulnerabilityAssessmentScans group. // Don't use this type directly, use NewSQLVulnerabilityAssessmentScansClient() instead. type SQLVulnerabilityAssessmentScansClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewSQLVulnerabilityAssessmentScansClient creates a new instance of SQLVulnerabilityAssessmentScansClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewSQLVulnerabilityAssessmentScansClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*SQLVulnerabilityAssessmentScansClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".SQLVulnerabilityAssessmentScansClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &SQLVulnerabilityAssessmentScansClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Gets the scan details of a single scan record. // If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2020-07-01-preview -// scanID - The scan Id. Type 'latest' to get the scan record for the latest scan. -// workspaceID - The workspace Id. -// resourceID - The identifier of the resource. -// options - SQLVulnerabilityAssessmentScansClientGetOptions contains the optional parameters for the SQLVulnerabilityAssessmentScansClient.Get -// method. +// +// Generated from API version 2023-02-01-preview +// - scanID - The scan Id. Type 'latest' to get the scan record for the latest scan. +// - workspaceID - The workspace Id. +// - resourceID - The identifier of the resource. +// - options - SQLVulnerabilityAssessmentScansClientGetOptions contains the optional parameters for the SQLVulnerabilityAssessmentScansClient.Get +// method. func (client *SQLVulnerabilityAssessmentScansClient) Get(ctx context.Context, scanID string, workspaceID string, resourceID string, options *SQLVulnerabilityAssessmentScansClientGetOptions) (SQLVulnerabilityAssessmentScansClientGetResponse, error) { req, err := client.getCreateRequest(ctx, scanID, workspaceID, resourceID, options) if err != nil { return SQLVulnerabilityAssessmentScansClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLVulnerabilityAssessmentScansClientGetResponse{}, err } @@ -83,13 +73,13 @@ func (client *SQLVulnerabilityAssessmentScansClient) getCreateRequest(ctx contex } urlPath = strings.ReplaceAll(urlPath, "{scanId}", url.PathEscape(scanID)) urlPath = strings.ReplaceAll(urlPath, "{resourceId}", resourceID) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() reqQP.Set("workspaceId", workspaceID) - reqQP.Set("api-version", "2020-07-01-preview") + reqQP.Set("api-version", "2023-02-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -106,17 +96,18 @@ func (client *SQLVulnerabilityAssessmentScansClient) getHandleResponse(resp *htt // List - Gets a list of scan records. // If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2020-07-01-preview -// workspaceID - The workspace Id. -// resourceID - The identifier of the resource. -// options - SQLVulnerabilityAssessmentScansClientListOptions contains the optional parameters for the SQLVulnerabilityAssessmentScansClient.List -// method. +// +// Generated from API version 2023-02-01-preview +// - workspaceID - The workspace Id. +// - resourceID - The identifier of the resource. +// - options - SQLVulnerabilityAssessmentScansClientListOptions contains the optional parameters for the SQLVulnerabilityAssessmentScansClient.List +// method. func (client *SQLVulnerabilityAssessmentScansClient) List(ctx context.Context, workspaceID string, resourceID string, options *SQLVulnerabilityAssessmentScansClientListOptions) (SQLVulnerabilityAssessmentScansClientListResponse, error) { req, err := client.listCreateRequest(ctx, workspaceID, resourceID, options) if err != nil { return SQLVulnerabilityAssessmentScansClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLVulnerabilityAssessmentScansClientListResponse{}, err } @@ -130,13 +121,13 @@ func (client *SQLVulnerabilityAssessmentScansClient) List(ctx context.Context, w func (client *SQLVulnerabilityAssessmentScansClient) listCreateRequest(ctx context.Context, workspaceID string, resourceID string, options *SQLVulnerabilityAssessmentScansClientListOptions) (*policy.Request, error) { urlPath := "/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/scans" urlPath = strings.ReplaceAll(urlPath, "{resourceId}", resourceID) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() reqQP.Set("workspaceId", workspaceID) - reqQP.Set("api-version", "2020-07-01-preview") + reqQP.Set("api-version", "2023-02-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/security/armsecurity/sqlvulnerabilityassessmentscans_client_example_test.go b/sdk/resourcemanager/security/armsecurity/sqlvulnerabilityassessmentscans_client_example_test.go deleted file mode 100644 index abfbbb717cf4..000000000000 --- a/sdk/resourcemanager/security/armsecurity/sqlvulnerabilityassessmentscans_client_example_test.go +++ /dev/null @@ -1,74 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. - -package armsecurity_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2020-07-01-preview/examples/sqlVulnerabilityAssessmentScanOperations/ArcMachineScans_Get.json -func ExampleSQLVulnerabilityAssessmentScansClient_Get_getScanDetailsOfAScanRecord() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewSQLVulnerabilityAssessmentScansClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "Scheduled-20200623", "55555555-6666-7777-8888-999999999999", "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Rg/providers/Microsoft.HybridCompute/machines/MyMachine/sqlServers/server1/databases/master", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2020-07-01-preview/examples/sqlVulnerabilityAssessmentScanOperations/ArcMachineScans_GetLatest.json -func ExampleSQLVulnerabilityAssessmentScansClient_Get_getScanDetailsOfTheLatestScanRecord() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewSQLVulnerabilityAssessmentScansClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "latest", "55555555-6666-7777-8888-999999999999", "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Rg/providers/Microsoft.HybridCompute/machines/MyMachine/sqlServers/server1/databases/master", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2020-07-01-preview/examples/sqlVulnerabilityAssessmentScanOperations/ArcMachineScans_List.json -func ExampleSQLVulnerabilityAssessmentScansClient_List() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewSQLVulnerabilityAssessmentScansClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.List(ctx, "55555555-6666-7777-8888-999999999999", "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Rg/providers/Microsoft.HybridCompute/machines/MyMachine/sqlServers/server1/databases/master", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/security/armsecurity/subassessments_client.go b/sdk/resourcemanager/security/armsecurity/subassessments_client.go index d258b9b39e79..8a54db20fc4b 100644 --- a/sdk/resourcemanager/security/armsecurity/subassessments_client.go +++ b/sdk/resourcemanager/security/armsecurity/subassessments_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,46 +24,38 @@ import ( // SubAssessmentsClient contains the methods for the SubAssessments group. // Don't use this type directly, use NewSubAssessmentsClient() instead. type SubAssessmentsClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewSubAssessmentsClient creates a new instance of SubAssessmentsClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewSubAssessmentsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*SubAssessmentsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".SubAssessmentsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &SubAssessmentsClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Get a security sub-assessment on your scanned resource // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-01-01-preview -// scope - Scope of the query, can be subscription (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group -// (/providers/Microsoft.Management/managementGroups/mgName). -// assessmentName - The Assessment Key - Unique key for the assessment type -// subAssessmentName - The Sub-Assessment Key - Unique key for the sub-assessment type -// options - SubAssessmentsClientGetOptions contains the optional parameters for the SubAssessmentsClient.Get method. +// - scope - Scope of the query, can be subscription (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group +// (/providers/Microsoft.Management/managementGroups/mgName). +// - assessmentName - The Assessment Key - Unique key for the assessment type +// - subAssessmentName - The Sub-Assessment Key - Unique key for the sub-assessment type +// - options - SubAssessmentsClientGetOptions contains the optional parameters for the SubAssessmentsClient.Get method. func (client *SubAssessmentsClient) Get(ctx context.Context, scope string, assessmentName string, subAssessmentName string, options *SubAssessmentsClientGetOptions) (SubAssessmentsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, scope, assessmentName, subAssessmentName, options) if err != nil { return SubAssessmentsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SubAssessmentsClientGetResponse{}, err } @@ -87,7 +77,7 @@ func (client *SubAssessmentsClient) getCreateRequest(ctx context.Context, scope return nil, errors.New("parameter subAssessmentName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subAssessmentName}", url.PathEscape(subAssessmentName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -108,11 +98,12 @@ func (client *SubAssessmentsClient) getHandleResponse(resp *http.Response) (SubA } // NewListPager - Get security sub-assessments on all your scanned resources inside a scope +// // Generated from API version 2019-01-01-preview -// scope - Scope of the query, can be subscription (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group -// (/providers/Microsoft.Management/managementGroups/mgName). -// assessmentName - The Assessment Key - Unique key for the assessment type -// options - SubAssessmentsClientListOptions contains the optional parameters for the SubAssessmentsClient.List method. +// - scope - Scope of the query, can be subscription (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group +// (/providers/Microsoft.Management/managementGroups/mgName). +// - assessmentName - The Assessment Key - Unique key for the assessment type +// - options - SubAssessmentsClientListOptions contains the optional parameters for the SubAssessmentsClient.NewListPager method. func (client *SubAssessmentsClient) NewListPager(scope string, assessmentName string, options *SubAssessmentsClientListOptions) *runtime.Pager[SubAssessmentsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[SubAssessmentsClientListResponse]{ More: func(page SubAssessmentsClientListResponse) bool { @@ -129,7 +120,7 @@ func (client *SubAssessmentsClient) NewListPager(scope string, assessmentName st if err != nil { return SubAssessmentsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SubAssessmentsClientListResponse{}, err } @@ -149,7 +140,7 @@ func (client *SubAssessmentsClient) listCreateRequest(ctx context.Context, scope return nil, errors.New("parameter assessmentName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{assessmentName}", url.PathEscape(assessmentName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -170,10 +161,12 @@ func (client *SubAssessmentsClient) listHandleResponse(resp *http.Response) (Sub } // NewListAllPager - Get security sub-assessments on all your scanned resources inside a subscription scope +// // Generated from API version 2019-01-01-preview -// scope - Scope of the query, can be subscription (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group -// (/providers/Microsoft.Management/managementGroups/mgName). -// options - SubAssessmentsClientListAllOptions contains the optional parameters for the SubAssessmentsClient.ListAll method. +// - scope - Scope of the query, can be subscription (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group +// (/providers/Microsoft.Management/managementGroups/mgName). +// - options - SubAssessmentsClientListAllOptions contains the optional parameters for the SubAssessmentsClient.NewListAllPager +// method. func (client *SubAssessmentsClient) NewListAllPager(scope string, options *SubAssessmentsClientListAllOptions) *runtime.Pager[SubAssessmentsClientListAllResponse] { return runtime.NewPager(runtime.PagingHandler[SubAssessmentsClientListAllResponse]{ More: func(page SubAssessmentsClientListAllResponse) bool { @@ -190,7 +183,7 @@ func (client *SubAssessmentsClient) NewListAllPager(scope string, options *SubAs if err != nil { return SubAssessmentsClientListAllResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SubAssessmentsClientListAllResponse{}, err } @@ -206,7 +199,7 @@ func (client *SubAssessmentsClient) NewListAllPager(scope string, options *SubAs func (client *SubAssessmentsClient) listAllCreateRequest(ctx context.Context, scope string, options *SubAssessmentsClientListAllOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.Security/subAssessments" urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/security/armsecurity/subassessments_client_example_test.go b/sdk/resourcemanager/security/armsecurity/subassessments_client_example_test.go deleted file mode 100644 index eed818e3d0d0..000000000000 --- a/sdk/resourcemanager/security/armsecurity/subassessments_client_example_test.go +++ /dev/null @@ -1,84 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. - -package armsecurity_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/SubAssessments/ListSubscriptionSubAssessments_example.json -func ExampleSubAssessmentsClient_NewListAllPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewSubAssessmentsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListAllPager("subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23", nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/SubAssessments/ListSubAssessments_example.json -func ExampleSubAssessmentsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewSubAssessmentsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23", "82e20e14-edc5-4373-bfc4-f13121257c37", nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/SubAssessments/GetSubAssessment_example.json -func ExampleSubAssessmentsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewSubAssessmentsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "subscriptions/212f9889-769e-45ae-ab43-6da33674bd26/resourceGroups/DEMORG/providers/Microsoft.Compute/virtualMachines/vm2", "1195afff-c881-495e-9bc5-1486211ae03f", "95f7da9c-a2a4-1322-0758-fcd24ef09b85", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/security/armsecurity/subscriptiongovernancerulesexecutestatus_client.go b/sdk/resourcemanager/security/armsecurity/subscriptiongovernancerulesexecutestatus_client.go deleted file mode 100644 index c1910b6103fd..000000000000 --- a/sdk/resourcemanager/security/armsecurity/subscriptiongovernancerulesexecutestatus_client.go +++ /dev/null @@ -1,119 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. -// DO NOT EDIT. - -package armsecurity - -import ( - "context" - "errors" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" - "net/url" - "strings" -) - -// SubscriptionGovernanceRulesExecuteStatusClient contains the methods for the SubscriptionGovernanceRulesExecuteStatus group. -// Don't use this type directly, use NewSubscriptionGovernanceRulesExecuteStatusClient() instead. -type SubscriptionGovernanceRulesExecuteStatusClient struct { - host string - subscriptionID string - pl runtime.Pipeline -} - -// NewSubscriptionGovernanceRulesExecuteStatusClient creates a new instance of SubscriptionGovernanceRulesExecuteStatusClient with the specified values. -// subscriptionID - Azure subscription ID -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. -func NewSubscriptionGovernanceRulesExecuteStatusClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SubscriptionGovernanceRulesExecuteStatusClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) - if err != nil { - return nil, err - } - client := &SubscriptionGovernanceRulesExecuteStatusClient{ - subscriptionID: subscriptionID, - host: ep, - pl: pl, - } - return client, nil -} - -// BeginGet - Get a specific governanceRule execution status for the requested scope by ruleId and operationId -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-01-01-preview -// ruleID - The security GovernanceRule key - unique key for the standard GovernanceRule -// operationID - The security GovernanceRule execution key - unique key for the execution of GovernanceRule -// options - SubscriptionGovernanceRulesExecuteStatusClientBeginGetOptions contains the optional parameters for the SubscriptionGovernanceRulesExecuteStatusClient.BeginGet -// method. -func (client *SubscriptionGovernanceRulesExecuteStatusClient) BeginGet(ctx context.Context, ruleID string, operationID string, options *SubscriptionGovernanceRulesExecuteStatusClientBeginGetOptions) (*runtime.Poller[SubscriptionGovernanceRulesExecuteStatusClientGetResponse], error) { - if options == nil || options.ResumeToken == "" { - resp, err := client.get(ctx, ruleID, operationID, options) - if err != nil { - return nil, err - } - return runtime.NewPoller[SubscriptionGovernanceRulesExecuteStatusClientGetResponse](resp, client.pl, nil) - } else { - return runtime.NewPollerFromResumeToken[SubscriptionGovernanceRulesExecuteStatusClientGetResponse](options.ResumeToken, client.pl, nil) - } -} - -// Get - Get a specific governanceRule execution status for the requested scope by ruleId and operationId -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-01-01-preview -func (client *SubscriptionGovernanceRulesExecuteStatusClient) get(ctx context.Context, ruleID string, operationID string, options *SubscriptionGovernanceRulesExecuteStatusClientBeginGetOptions) (*http.Response, error) { - req, err := client.getCreateRequest(ctx, ruleID, operationID, options) - if err != nil { - return nil, err - } - resp, err := client.pl.Do(req) - if err != nil { - return nil, err - } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) - } - return resp, nil -} - -// getCreateRequest creates the Get request. -func (client *SubscriptionGovernanceRulesExecuteStatusClient) getCreateRequest(ctx context.Context, ruleID string, operationID string, options *SubscriptionGovernanceRulesExecuteStatusClientBeginGetOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Security/governanceRules/{ruleId}/operationResults/{operationId}" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if ruleID == "" { - return nil, errors.New("parameter ruleID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{ruleId}", url.PathEscape(ruleID)) - if operationID == "" { - return nil, errors.New("parameter operationID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} diff --git a/sdk/resourcemanager/security/armsecurity/subscriptiongovernancerulesexecutestatus_client_example_test.go b/sdk/resourcemanager/security/armsecurity/subscriptiongovernancerulesexecutestatus_client_example_test.go deleted file mode 100644 index a064c657c0dd..000000000000 --- a/sdk/resourcemanager/security/armsecurity/subscriptiongovernancerulesexecutestatus_client_example_test.go +++ /dev/null @@ -1,40 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. - -package armsecurity_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/GetGovernanceRuleExecuteStatus_example.json -func ExampleSubscriptionGovernanceRulesExecuteStatusClient_BeginGet() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewSubscriptionGovernanceRulesExecuteStatusClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginGet(ctx, "ad9a8e26-29d9-4829-bb30-e597a58cdbb8", "58b33f4f-c8c7-4b01-99cc-d437db4d40dd", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/security/armsecurity/tasks_client.go b/sdk/resourcemanager/security/armsecurity/tasks_client.go index a63c83694ac1..40fb2c1b087a 100644 --- a/sdk/resourcemanager/security/armsecurity/tasks_client.go +++ b/sdk/resourcemanager/security/armsecurity/tasks_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,49 +24,41 @@ import ( // TasksClient contains the methods for the Tasks group. // Don't use this type directly, use NewTasksClient() instead. type TasksClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewTasksClient creates a new instance of TasksClient with the specified values. -// subscriptionID - Azure subscription ID -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure subscription ID +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewTasksClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*TasksClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".TasksClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &TasksClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // GetResourceGroupLevelTask - Recommended tasks that will help improve the security of the subscription proactively // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2015-06-01-preview -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations -// taskName - Name of the task object, will be a GUID -// options - TasksClientGetResourceGroupLevelTaskOptions contains the optional parameters for the TasksClient.GetResourceGroupLevelTask -// method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations +// - taskName - Name of the task object, will be a GUID +// - options - TasksClientGetResourceGroupLevelTaskOptions contains the optional parameters for the TasksClient.GetResourceGroupLevelTask +// method. func (client *TasksClient) GetResourceGroupLevelTask(ctx context.Context, resourceGroupName string, ascLocation string, taskName string, options *TasksClientGetResourceGroupLevelTaskOptions) (TasksClientGetResourceGroupLevelTaskResponse, error) { req, err := client.getResourceGroupLevelTaskCreateRequest(ctx, resourceGroupName, ascLocation, taskName, options) if err != nil { return TasksClientGetResourceGroupLevelTaskResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return TasksClientGetResourceGroupLevelTaskResponse{}, err } @@ -97,7 +87,7 @@ func (client *TasksClient) getResourceGroupLevelTaskCreateRequest(ctx context.Co return nil, errors.New("parameter taskName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{taskName}", url.PathEscape(taskName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -119,17 +109,18 @@ func (client *TasksClient) getResourceGroupLevelTaskHandleResponse(resp *http.Re // GetSubscriptionLevelTask - Recommended tasks that will help improve the security of the subscription proactively // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2015-06-01-preview -// ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations -// taskName - Name of the task object, will be a GUID -// options - TasksClientGetSubscriptionLevelTaskOptions contains the optional parameters for the TasksClient.GetSubscriptionLevelTask -// method. +// - ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations +// - taskName - Name of the task object, will be a GUID +// - options - TasksClientGetSubscriptionLevelTaskOptions contains the optional parameters for the TasksClient.GetSubscriptionLevelTask +// method. func (client *TasksClient) GetSubscriptionLevelTask(ctx context.Context, ascLocation string, taskName string, options *TasksClientGetSubscriptionLevelTaskOptions) (TasksClientGetSubscriptionLevelTaskResponse, error) { req, err := client.getSubscriptionLevelTaskCreateRequest(ctx, ascLocation, taskName, options) if err != nil { return TasksClientGetSubscriptionLevelTaskResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return TasksClientGetSubscriptionLevelTaskResponse{}, err } @@ -154,7 +145,7 @@ func (client *TasksClient) getSubscriptionLevelTaskCreateRequest(ctx context.Con return nil, errors.New("parameter taskName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{taskName}", url.PathEscape(taskName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -175,8 +166,9 @@ func (client *TasksClient) getSubscriptionLevelTaskHandleResponse(resp *http.Res } // NewListPager - Recommended tasks that will help improve the security of the subscription proactively +// // Generated from API version 2015-06-01-preview -// options - TasksClientListOptions contains the optional parameters for the TasksClient.List method. +// - options - TasksClientListOptions contains the optional parameters for the TasksClient.NewListPager method. func (client *TasksClient) NewListPager(options *TasksClientListOptions) *runtime.Pager[TasksClientListResponse] { return runtime.NewPager(runtime.PagingHandler[TasksClientListResponse]{ More: func(page TasksClientListResponse) bool { @@ -193,7 +185,7 @@ func (client *TasksClient) NewListPager(options *TasksClientListOptions) *runtim if err != nil { return TasksClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return TasksClientListResponse{}, err } @@ -212,7 +204,7 @@ func (client *TasksClient) listCreateRequest(ctx context.Context, options *Tasks return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -236,9 +228,11 @@ func (client *TasksClient) listHandleResponse(resp *http.Response) (TasksClientL } // NewListByHomeRegionPager - Recommended tasks that will help improve the security of the subscription proactively +// // Generated from API version 2015-06-01-preview -// ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations -// options - TasksClientListByHomeRegionOptions contains the optional parameters for the TasksClient.ListByHomeRegion method. +// - ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations +// - options - TasksClientListByHomeRegionOptions contains the optional parameters for the TasksClient.NewListByHomeRegionPager +// method. func (client *TasksClient) NewListByHomeRegionPager(ascLocation string, options *TasksClientListByHomeRegionOptions) *runtime.Pager[TasksClientListByHomeRegionResponse] { return runtime.NewPager(runtime.PagingHandler[TasksClientListByHomeRegionResponse]{ More: func(page TasksClientListByHomeRegionResponse) bool { @@ -255,7 +249,7 @@ func (client *TasksClient) NewListByHomeRegionPager(ascLocation string, options if err != nil { return TasksClientListByHomeRegionResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return TasksClientListByHomeRegionResponse{}, err } @@ -278,7 +272,7 @@ func (client *TasksClient) listByHomeRegionCreateRequest(ctx context.Context, as return nil, errors.New("parameter ascLocation cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{ascLocation}", url.PathEscape(ascLocation)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -302,11 +296,12 @@ func (client *TasksClient) listByHomeRegionHandleResponse(resp *http.Response) ( } // NewListByResourceGroupPager - Recommended tasks that will help improve the security of the subscription proactively +// // Generated from API version 2015-06-01-preview -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations -// options - TasksClientListByResourceGroupOptions contains the optional parameters for the TasksClient.ListByResourceGroup -// method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations +// - options - TasksClientListByResourceGroupOptions contains the optional parameters for the TasksClient.NewListByResourceGroupPager +// method. func (client *TasksClient) NewListByResourceGroupPager(resourceGroupName string, ascLocation string, options *TasksClientListByResourceGroupOptions) *runtime.Pager[TasksClientListByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[TasksClientListByResourceGroupResponse]{ More: func(page TasksClientListByResourceGroupResponse) bool { @@ -323,7 +318,7 @@ func (client *TasksClient) NewListByResourceGroupPager(resourceGroupName string, if err != nil { return TasksClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return TasksClientListByResourceGroupResponse{}, err } @@ -350,7 +345,7 @@ func (client *TasksClient) listByResourceGroupCreateRequest(ctx context.Context, return nil, errors.New("parameter ascLocation cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{ascLocation}", url.PathEscape(ascLocation)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -375,19 +370,20 @@ func (client *TasksClient) listByResourceGroupHandleResponse(resp *http.Response // UpdateResourceGroupLevelTaskState - Recommended tasks that will help improve the security of the subscription proactively // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2015-06-01-preview -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations -// taskName - Name of the task object, will be a GUID -// taskUpdateActionType - Type of the action to do on the task -// options - TasksClientUpdateResourceGroupLevelTaskStateOptions contains the optional parameters for the TasksClient.UpdateResourceGroupLevelTaskState -// method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations +// - taskName - Name of the task object, will be a GUID +// - taskUpdateActionType - Type of the action to do on the task +// - options - TasksClientUpdateResourceGroupLevelTaskStateOptions contains the optional parameters for the TasksClient.UpdateResourceGroupLevelTaskState +// method. func (client *TasksClient) UpdateResourceGroupLevelTaskState(ctx context.Context, resourceGroupName string, ascLocation string, taskName string, taskUpdateActionType TaskUpdateActionType, options *TasksClientUpdateResourceGroupLevelTaskStateOptions) (TasksClientUpdateResourceGroupLevelTaskStateResponse, error) { req, err := client.updateResourceGroupLevelTaskStateCreateRequest(ctx, resourceGroupName, ascLocation, taskName, taskUpdateActionType, options) if err != nil { return TasksClientUpdateResourceGroupLevelTaskStateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return TasksClientUpdateResourceGroupLevelTaskStateResponse{}, err } @@ -420,7 +416,7 @@ func (client *TasksClient) updateResourceGroupLevelTaskStateCreateRequest(ctx co return nil, errors.New("parameter taskUpdateActionType cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{taskUpdateActionType}", url.PathEscape(string(taskUpdateActionType))) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -433,18 +429,19 @@ func (client *TasksClient) updateResourceGroupLevelTaskStateCreateRequest(ctx co // UpdateSubscriptionLevelTaskState - Recommended tasks that will help improve the security of the subscription proactively // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2015-06-01-preview -// ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations -// taskName - Name of the task object, will be a GUID -// taskUpdateActionType - Type of the action to do on the task -// options - TasksClientUpdateSubscriptionLevelTaskStateOptions contains the optional parameters for the TasksClient.UpdateSubscriptionLevelTaskState -// method. +// - ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations +// - taskName - Name of the task object, will be a GUID +// - taskUpdateActionType - Type of the action to do on the task +// - options - TasksClientUpdateSubscriptionLevelTaskStateOptions contains the optional parameters for the TasksClient.UpdateSubscriptionLevelTaskState +// method. func (client *TasksClient) UpdateSubscriptionLevelTaskState(ctx context.Context, ascLocation string, taskName string, taskUpdateActionType TaskUpdateActionType, options *TasksClientUpdateSubscriptionLevelTaskStateOptions) (TasksClientUpdateSubscriptionLevelTaskStateResponse, error) { req, err := client.updateSubscriptionLevelTaskStateCreateRequest(ctx, ascLocation, taskName, taskUpdateActionType, options) if err != nil { return TasksClientUpdateSubscriptionLevelTaskStateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return TasksClientUpdateSubscriptionLevelTaskStateResponse{}, err } @@ -473,7 +470,7 @@ func (client *TasksClient) updateSubscriptionLevelTaskStateCreateRequest(ctx con return nil, errors.New("parameter taskUpdateActionType cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{taskUpdateActionType}", url.PathEscape(string(taskUpdateActionType))) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/security/armsecurity/tasks_client_example_test.go b/sdk/resourcemanager/security/armsecurity/tasks_client_example_test.go deleted file mode 100644 index ac7b1ad7073a..000000000000 --- a/sdk/resourcemanager/security/armsecurity/tasks_client_example_test.go +++ /dev/null @@ -1,161 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. - -package armsecurity_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2015-06-01-preview/examples/Tasks/GetTasksSubscription_example.json -func ExampleTasksClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewTasksClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(&armsecurity.TasksClientListOptions{Filter: nil}) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2015-06-01-preview/examples/Tasks/GetTasksSubscriptionLocation_example.json -func ExampleTasksClient_NewListByHomeRegionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewTasksClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByHomeRegionPager("westeurope", &armsecurity.TasksClientListByHomeRegionOptions{Filter: nil}) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2015-06-01-preview/examples/Tasks/GetTaskSubscriptionLocation_example.json -func ExampleTasksClient_GetSubscriptionLevelTask() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewTasksClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.GetSubscriptionLevelTask(ctx, "westeurope", "62609ee7-d0a5-8616-9fe4-1df5cca7758d", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2015-06-01-preview/examples/Tasks/UpdateTaskSubscriptionLocation_example.json -func ExampleTasksClient_UpdateSubscriptionLevelTaskState() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewTasksClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.UpdateSubscriptionLevelTaskState(ctx, "westeurope", "62609ee7-d0a5-8616-9fe4-1df5cca7758d", armsecurity.TaskUpdateActionTypeDismiss, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2015-06-01-preview/examples/Tasks/GetTasksResourceGroupLocation_example.json -func ExampleTasksClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewTasksClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByResourceGroupPager("myRg", "westeurope", &armsecurity.TasksClientListByResourceGroupOptions{Filter: nil}) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2015-06-01-preview/examples/Tasks/GetTaskResourceGroupLocation_example.json -func ExampleTasksClient_GetResourceGroupLevelTask() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewTasksClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.GetResourceGroupLevelTask(ctx, "myRg", "westeurope", "d55b4dc0-779c-c66c-33e5-d7bce24c4222", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2015-06-01-preview/examples/Tasks/UpdateTaskResourceGroupLocation_example.json -func ExampleTasksClient_UpdateResourceGroupLevelTaskState() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewTasksClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.UpdateResourceGroupLevelTaskState(ctx, "myRg", "westeurope", "d55b4dc0-779c-c66c-33e5-d7bce24c4222", armsecurity.TaskUpdateActionTypeDismiss, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/security/armsecurity/time_rfc3339.go b/sdk/resourcemanager/security/armsecurity/time_rfc3339.go index b848c8724164..dca739e560f2 100644 --- a/sdk/resourcemanager/security/armsecurity/time_rfc3339.go +++ b/sdk/resourcemanager/security/armsecurity/time_rfc3339.go @@ -62,7 +62,7 @@ func (t *timeRFC3339) Parse(layout, value string) error { return err } -func populateTimeRFC3339(m map[string]interface{}, k string, t *time.Time) { +func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return } else if azcore.IsNullValue(t) { diff --git a/sdk/resourcemanager/security/armsecurity/topology_client.go b/sdk/resourcemanager/security/armsecurity/topology_client.go index 4a14bd0604d3..05b132831516 100644 --- a/sdk/resourcemanager/security/armsecurity/topology_client.go +++ b/sdk/resourcemanager/security/armsecurity/topology_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,48 +24,40 @@ import ( // TopologyClient contains the methods for the Topology group. // Don't use this type directly, use NewTopologyClient() instead. type TopologyClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewTopologyClient creates a new instance of TopologyClient with the specified values. -// subscriptionID - Azure subscription ID -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure subscription ID +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewTopologyClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*TopologyClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".TopologyClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &TopologyClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Gets a specific topology component. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-01-01 -// resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. -// ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations -// topologyResourceName - Name of a topology resources collection. -// options - TopologyClientGetOptions contains the optional parameters for the TopologyClient.Get method. +// - resourceGroupName - The name of the resource group within the user's subscription. The name is case insensitive. +// - ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations +// - topologyResourceName - Name of a topology resources collection. +// - options - TopologyClientGetOptions contains the optional parameters for the TopologyClient.Get method. func (client *TopologyClient) Get(ctx context.Context, resourceGroupName string, ascLocation string, topologyResourceName string, options *TopologyClientGetOptions) (TopologyClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, ascLocation, topologyResourceName, options) if err != nil { return TopologyClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return TopologyClientGetResponse{}, err } @@ -96,7 +86,7 @@ func (client *TopologyClient) getCreateRequest(ctx context.Context, resourceGrou return nil, errors.New("parameter topologyResourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{topologyResourceName}", url.PathEscape(topologyResourceName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -117,8 +107,9 @@ func (client *TopologyClient) getHandleResponse(resp *http.Response) (TopologyCl } // NewListPager - Gets a list that allows to build a topology view of a subscription. +// // Generated from API version 2020-01-01 -// options - TopologyClientListOptions contains the optional parameters for the TopologyClient.List method. +// - options - TopologyClientListOptions contains the optional parameters for the TopologyClient.NewListPager method. func (client *TopologyClient) NewListPager(options *TopologyClientListOptions) *runtime.Pager[TopologyClientListResponse] { return runtime.NewPager(runtime.PagingHandler[TopologyClientListResponse]{ More: func(page TopologyClientListResponse) bool { @@ -135,7 +126,7 @@ func (client *TopologyClient) NewListPager(options *TopologyClientListOptions) * if err != nil { return TopologyClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return TopologyClientListResponse{}, err } @@ -154,7 +145,7 @@ func (client *TopologyClient) listCreateRequest(ctx context.Context, options *To return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -175,10 +166,11 @@ func (client *TopologyClient) listHandleResponse(resp *http.Response) (TopologyC } // NewListByHomeRegionPager - Gets a list that allows to build a topology view of a subscription and location. +// // Generated from API version 2020-01-01 -// ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations -// options - TopologyClientListByHomeRegionOptions contains the optional parameters for the TopologyClient.ListByHomeRegion -// method. +// - ascLocation - The location where ASC stores the data of the subscription. can be retrieved from Get locations +// - options - TopologyClientListByHomeRegionOptions contains the optional parameters for the TopologyClient.NewListByHomeRegionPager +// method. func (client *TopologyClient) NewListByHomeRegionPager(ascLocation string, options *TopologyClientListByHomeRegionOptions) *runtime.Pager[TopologyClientListByHomeRegionResponse] { return runtime.NewPager(runtime.PagingHandler[TopologyClientListByHomeRegionResponse]{ More: func(page TopologyClientListByHomeRegionResponse) bool { @@ -195,7 +187,7 @@ func (client *TopologyClient) NewListByHomeRegionPager(ascLocation string, optio if err != nil { return TopologyClientListByHomeRegionResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return TopologyClientListByHomeRegionResponse{}, err } @@ -218,7 +210,7 @@ func (client *TopologyClient) listByHomeRegionCreateRequest(ctx context.Context, return nil, errors.New("parameter ascLocation cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{ascLocation}", url.PathEscape(ascLocation)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/security/armsecurity/topology_client_example_test.go b/sdk/resourcemanager/security/armsecurity/topology_client_example_test.go deleted file mode 100644 index 9403d4bcdcfa..000000000000 --- a/sdk/resourcemanager/security/armsecurity/topology_client_example_test.go +++ /dev/null @@ -1,84 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. - -package armsecurity_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/Topology/GetTopologySubscription_example.json -func ExampleTopologyClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewTopologyClient("3eeab341-f466-499c-a8be-85427e154bad", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/Topology/GetTopologySubscriptionLocation_example.json -func ExampleTopologyClient_NewListByHomeRegionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewTopologyClient("3eeab341-f466-499c-a8be-85427e154bad", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByHomeRegionPager("centralus", nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/Topology/GetTopology_example.json -func ExampleTopologyClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewTopologyClient("3eeab341-f466-499c-a8be-85427e154bad", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "myservers", "centralus", "vnets", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/security/armsecurity/workspacesettings_client.go b/sdk/resourcemanager/security/armsecurity/workspacesettings_client.go index b7308ef3042b..98a396e52dd8 100644 --- a/sdk/resourcemanager/security/armsecurity/workspacesettings_client.go +++ b/sdk/resourcemanager/security/armsecurity/workspacesettings_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,48 +24,40 @@ import ( // WorkspaceSettingsClient contains the methods for the WorkspaceSettings group. // Don't use this type directly, use NewWorkspaceSettingsClient() instead. type WorkspaceSettingsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewWorkspaceSettingsClient creates a new instance of WorkspaceSettingsClient with the specified values. -// subscriptionID - Azure subscription ID -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure subscription ID +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewWorkspaceSettingsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkspaceSettingsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".WorkspaceSettingsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &WorkspaceSettingsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Create - creating settings about where we should store your security data and logs // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-08-01-preview -// workspaceSettingName - Name of the security setting -// workspaceSetting - Security data setting object -// options - WorkspaceSettingsClientCreateOptions contains the optional parameters for the WorkspaceSettingsClient.Create -// method. +// - workspaceSettingName - Name of the security setting +// - workspaceSetting - Security data setting object +// - options - WorkspaceSettingsClientCreateOptions contains the optional parameters for the WorkspaceSettingsClient.Create +// method. func (client *WorkspaceSettingsClient) Create(ctx context.Context, workspaceSettingName string, workspaceSetting WorkspaceSetting, options *WorkspaceSettingsClientCreateOptions) (WorkspaceSettingsClientCreateResponse, error) { req, err := client.createCreateRequest(ctx, workspaceSettingName, workspaceSetting, options) if err != nil { return WorkspaceSettingsClientCreateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkspaceSettingsClientCreateResponse{}, err } @@ -88,7 +78,7 @@ func (client *WorkspaceSettingsClient) createCreateRequest(ctx context.Context, return nil, errors.New("parameter workspaceSettingName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{workspaceSettingName}", url.PathEscape(workspaceSettingName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -110,16 +100,17 @@ func (client *WorkspaceSettingsClient) createHandleResponse(resp *http.Response) // Delete - Deletes the custom workspace settings for this subscription. new VMs will report to the default workspace // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-08-01-preview -// workspaceSettingName - Name of the security setting -// options - WorkspaceSettingsClientDeleteOptions contains the optional parameters for the WorkspaceSettingsClient.Delete -// method. +// - workspaceSettingName - Name of the security setting +// - options - WorkspaceSettingsClientDeleteOptions contains the optional parameters for the WorkspaceSettingsClient.Delete +// method. func (client *WorkspaceSettingsClient) Delete(ctx context.Context, workspaceSettingName string, options *WorkspaceSettingsClientDeleteOptions) (WorkspaceSettingsClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, workspaceSettingName, options) if err != nil { return WorkspaceSettingsClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkspaceSettingsClientDeleteResponse{}, err } @@ -140,7 +131,7 @@ func (client *WorkspaceSettingsClient) deleteCreateRequest(ctx context.Context, return nil, errors.New("parameter workspaceSettingName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{workspaceSettingName}", url.PathEscape(workspaceSettingName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -154,15 +145,16 @@ func (client *WorkspaceSettingsClient) deleteCreateRequest(ctx context.Context, // Get - Settings about where we should store your security data and logs. If the result is empty, it means that no custom-workspace // configuration was set // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-08-01-preview -// workspaceSettingName - Name of the security setting -// options - WorkspaceSettingsClientGetOptions contains the optional parameters for the WorkspaceSettingsClient.Get method. +// - workspaceSettingName - Name of the security setting +// - options - WorkspaceSettingsClientGetOptions contains the optional parameters for the WorkspaceSettingsClient.Get method. func (client *WorkspaceSettingsClient) Get(ctx context.Context, workspaceSettingName string, options *WorkspaceSettingsClientGetOptions) (WorkspaceSettingsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, workspaceSettingName, options) if err != nil { return WorkspaceSettingsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkspaceSettingsClientGetResponse{}, err } @@ -183,7 +175,7 @@ func (client *WorkspaceSettingsClient) getCreateRequest(ctx context.Context, wor return nil, errors.New("parameter workspaceSettingName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{workspaceSettingName}", url.PathEscape(workspaceSettingName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -205,8 +197,10 @@ func (client *WorkspaceSettingsClient) getHandleResponse(resp *http.Response) (W // NewListPager - Settings about where we should store your security data and logs. If the result is empty, it means that // no custom-workspace configuration was set +// // Generated from API version 2017-08-01-preview -// options - WorkspaceSettingsClientListOptions contains the optional parameters for the WorkspaceSettingsClient.List method. +// - options - WorkspaceSettingsClientListOptions contains the optional parameters for the WorkspaceSettingsClient.NewListPager +// method. func (client *WorkspaceSettingsClient) NewListPager(options *WorkspaceSettingsClientListOptions) *runtime.Pager[WorkspaceSettingsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[WorkspaceSettingsClientListResponse]{ More: func(page WorkspaceSettingsClientListResponse) bool { @@ -223,7 +217,7 @@ func (client *WorkspaceSettingsClient) NewListPager(options *WorkspaceSettingsCl if err != nil { return WorkspaceSettingsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkspaceSettingsClientListResponse{}, err } @@ -242,7 +236,7 @@ func (client *WorkspaceSettingsClient) listCreateRequest(ctx context.Context, op return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -264,17 +258,18 @@ func (client *WorkspaceSettingsClient) listHandleResponse(resp *http.Response) ( // Update - Settings about where we should store your security data and logs // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2017-08-01-preview -// workspaceSettingName - Name of the security setting -// workspaceSetting - Security data setting object -// options - WorkspaceSettingsClientUpdateOptions contains the optional parameters for the WorkspaceSettingsClient.Update -// method. +// - workspaceSettingName - Name of the security setting +// - workspaceSetting - Security data setting object +// - options - WorkspaceSettingsClientUpdateOptions contains the optional parameters for the WorkspaceSettingsClient.Update +// method. func (client *WorkspaceSettingsClient) Update(ctx context.Context, workspaceSettingName string, workspaceSetting WorkspaceSetting, options *WorkspaceSettingsClientUpdateOptions) (WorkspaceSettingsClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, workspaceSettingName, workspaceSetting, options) if err != nil { return WorkspaceSettingsClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkspaceSettingsClientUpdateResponse{}, err } @@ -295,7 +290,7 @@ func (client *WorkspaceSettingsClient) updateCreateRequest(ctx context.Context, return nil, errors.New("parameter workspaceSettingName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{workspaceSettingName}", url.PathEscape(workspaceSettingName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/security/armsecurity/workspacesettings_client_example_test.go b/sdk/resourcemanager/security/armsecurity/workspacesettings_client_example_test.go deleted file mode 100644 index 8801d9cb6368..000000000000 --- a/sdk/resourcemanager/security/armsecurity/workspacesettings_client_example_test.go +++ /dev/null @@ -1,131 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. - -package armsecurity_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2017-08-01-preview/examples/WorkspaceSettings/GetWorkspaceSettings_example.json -func ExampleWorkspaceSettingsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewWorkspaceSettingsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2017-08-01-preview/examples/WorkspaceSettings/GetWorkspaceSetting_example.json -func ExampleWorkspaceSettingsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewWorkspaceSettingsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "default", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2017-08-01-preview/examples/WorkspaceSettings/CreateWorkspaceSetting_example.json -func ExampleWorkspaceSettingsClient_Create() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewWorkspaceSettingsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Create(ctx, "default", armsecurity.WorkspaceSetting{ - Name: to.Ptr("default"), - Type: to.Ptr("Microsoft.Security/workspaceSettings"), - ID: to.Ptr("/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/providers/Microsoft.Security/workspaceSettings/default"), - Properties: &armsecurity.WorkspaceSettingProperties{ - Scope: to.Ptr("/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23"), - WorkspaceID: to.Ptr("/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/myRg/providers/Microsoft.OperationalInsights/workspaces/myWorkspace"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2017-08-01-preview/examples/WorkspaceSettings/UpdateWorkspaceSetting_example.json -func ExampleWorkspaceSettingsClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewWorkspaceSettingsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Update(ctx, "default", armsecurity.WorkspaceSetting{ - Name: to.Ptr("default"), - Type: to.Ptr("Microsoft.Security/workspaceSettings"), - ID: to.Ptr("/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/providers/Microsoft.Security/workspaceSettings/default"), - Properties: &armsecurity.WorkspaceSettingProperties{ - WorkspaceID: to.Ptr("/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/myRg/providers/Microsoft.OperationalInsights/workspaces/myWorkspace"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/security/resource-manager/Microsoft.Security/preview/2017-08-01-preview/examples/WorkspaceSettings/DeleteWorkspaceSetting_example.json -func ExampleWorkspaceSettingsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsecurity.NewWorkspaceSettingsClient("20ff7fc3-e762-44dd-bd96-b71116dcdc23", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, "default", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -}