diff --git a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/CHANGELOG.md b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/CHANGELOG.md index b76a640a4001..4951efefefca 100644 --- a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/CHANGELOG.md +++ b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/CHANGELOG.md @@ -1,5 +1,166 @@ # Release History +## 1.0.0 (2024-05-24) +### Breaking Changes + +- Type of `ReportResourcePatch.Properties` has been changed from `*ReportProperties` to `*ReportPatchProperties` +- `CategoryStatusHealthy`, `CategoryStatusUnhealthy` from enum `CategoryStatus` has been removed +- `ControlFamilyStatusHealthy`, `ControlFamilyStatusUnhealthy` from enum `ControlFamilyStatus` has been removed +- `ResourceStatusNotApplicable` from enum `ResourceStatus` has been removed +- Enum `AssessmentSeverity` has been removed +- Enum `CategoryType` has been removed +- Enum `ComplianceState` has been removed +- Enum `ControlFamilyType` has been removed +- Enum `ControlType` has been removed +- Enum `IsPass` has been removed +- Function `*ClientFactory.NewSnapshotClient` has been removed +- Function `*ReportClient.BeginCreateOrUpdate` has been removed +- Function `*ReportClient.BeginDelete` has been removed +- Function `*ReportClient.Get` has been removed +- Function `*ReportClient.BeginUpdate` has been removed +- Function `NewSnapshotClient` has been removed +- Function `*SnapshotClient.BeginDownload` has been removed +- Function `*SnapshotClient.Get` has been removed +- Struct `Assessment` has been removed +- Struct `AssessmentResource` has been removed +- Struct `ReportResourceList` has been removed +- Struct `SnapshotResourceList` has been removed +- Field `CategoryType` of struct `Category` has been removed +- Field `ComplianceState`, `ControlType`, `PolicyDescription`, `PolicyDisplayName`, `PolicyID`, `ResourceGroup`, `StatusChangeDate`, `SubscriptionID` of struct `ComplianceReportItem` has been removed +- Field `Assessments`, `ControlShortName`, `ControlType` of struct `Control` has been removed +- Field `FamilyName`, `FamilyStatus`, `FamilyType` of struct `ControlFamily` has been removed +- Field `ID`, `ReportName` of struct `ReportProperties` has been removed +- Field `ReportResourceList` of struct `ReportsClientListResponse` has been removed +- Field `ResourceName`, `Tags` of struct `ResourceMetadata` has been removed +- Field `ID` of struct `SnapshotProperties` has been removed +- Field `SnapshotResourceList` of struct `SnapshotsClientListResponse` has been removed + +### Features Added + +- New value `CategoryStatusFailed`, `CategoryStatusNotApplicable`, `CategoryStatusPassed`, `CategoryStatusPendingApproval` added to enum type `CategoryStatus` +- New value `ControlFamilyStatusFailed`, `ControlFamilyStatusNotApplicable`, `ControlFamilyStatusPassed`, `ControlFamilyStatusPendingApproval` added to enum type `ControlFamilyStatus` +- New value `ControlStatusPendingApproval` added to enum type `ControlStatus` +- New value `ProvisioningStateFixing`, `ProvisioningStateVerifying` added to enum type `ProvisioningState` +- New value `ReportStatusReviewing` added to enum type `ReportStatus` +- New enum type `CheckNameAvailabilityReason` with values `CheckNameAvailabilityReasonAlreadyExists`, `CheckNameAvailabilityReasonInvalid` +- New enum type `ContentType` with values `ContentTypeApplicationJSON` +- New enum type `DeliveryStatus` with values `DeliveryStatusFailed`, `DeliveryStatusNotStarted`, `DeliveryStatusSucceeded` +- New enum type `EnableSSLVerification` with values `EnableSSLVerificationFalse`, `EnableSSLVerificationTrue` +- New enum type `EvidenceType` with values `EvidenceTypeAutoCollectedEvidence`, `EvidenceTypeData`, `EvidenceTypeFile` +- New enum type `InputType` with values `InputTypeBoolean`, `InputTypeDate`, `InputTypeEmail`, `InputTypeGroup`, `InputTypeMultiSelectCheckbox`, `InputTypeMultiSelectDropdown`, `InputTypeMultiSelectDropdownCustom`, `InputTypeMultilineText`, `InputTypeNone`, `InputTypeNumber`, `InputTypeSingleSelectDropdown`, `InputTypeSingleSelection`, `InputTypeTelephone`, `InputTypeText`, `InputTypeURL`, `InputTypeUpload`, `InputTypeYearPicker`, `InputTypeYesNoNa` +- New enum type `IsRecommendSolution` with values `IsRecommendSolutionFalse`, `IsRecommendSolutionTrue` +- New enum type `NotificationEvent` with values `NotificationEventAssessmentFailure`, `NotificationEventGenerateSnapshotFailed`, `NotificationEventGenerateSnapshotSuccess`, `NotificationEventReportConfigurationChanges`, `NotificationEventReportDeletion` +- New enum type `ResourceOrigin` with values `ResourceOriginAWS`, `ResourceOriginAzure`, `ResourceOriginGCP` +- New enum type `ResponsibilityEnvironment` with values `ResponsibilityEnvironmentAWS`, `ResponsibilityEnvironmentAzure`, `ResponsibilityEnvironmentGCP`, `ResponsibilityEnvironmentGeneral` +- New enum type `ResponsibilitySeverity` with values `ResponsibilitySeverityHigh`, `ResponsibilitySeverityLow`, `ResponsibilitySeverityMedium` +- New enum type `ResponsibilityStatus` with values `ResponsibilityStatusFailed`, `ResponsibilityStatusNotApplicable`, `ResponsibilityStatusPassed`, `ResponsibilityStatusPendingApproval` +- New enum type `ResponsibilityType` with values `ResponsibilityTypeAutomated`, `ResponsibilityTypeManual`, `ResponsibilityTypeScopedManual` +- New enum type `Result` with values `ResultFailed`, `ResultSucceeded` +- New enum type `Rule` with values `RuleAzureApplication`, `RuleCharLength`, `RuleCreditCardPCI`, `RuleDomains`, `RuleDynamicDropdown`, `RulePreventNonEnglishChar`, `RulePublicSOX`, `RulePublisherVerification`, `RuleRequired`, `RuleURL`, `RuleUSPrivacyShield`, `RuleUrls`, `RuleValidEmail`, `RuleValidGUID` +- New enum type `SendAllEvents` with values `SendAllEventsFalse`, `SendAllEventsTrue` +- New enum type `UpdateWebhookKey` with values `UpdateWebhookKeyFalse`, `UpdateWebhookKeyTrue` +- New enum type `WebhookKeyEnabled` with values `WebhookKeyEnabledFalse`, `WebhookKeyEnabledTrue` +- New enum type `WebhookStatus` with values `WebhookStatusDisabled`, `WebhookStatusEnabled` +- New function `*ClientFactory.NewEvidencesClient() *EvidencesClient` +- New function `*ClientFactory.NewProviderActionsClient() *ProviderActionsClient` +- New function `*ClientFactory.NewScopingConfigurationClient() *ScopingConfigurationClient` +- New function `*ClientFactory.NewScopingConfigurationsClient() *ScopingConfigurationsClient` +- New function `*ClientFactory.NewToolForMicrosoft365Client() *ToolForMicrosoft365Client` +- New function `*ClientFactory.NewWebhooksClient() *WebhooksClient` +- New function `NewEvidencesClient(azcore.TokenCredential, *arm.ClientOptions) (*EvidencesClient, error)` +- New function `*EvidencesClient.CreateOrUpdate(context.Context, string, string, EvidenceResource, *EvidencesClientCreateOrUpdateOptions) (EvidencesClientCreateOrUpdateResponse, error)` +- New function `*EvidencesClient.Delete(context.Context, string, string, *EvidencesClientDeleteOptions) (EvidencesClientDeleteResponse, error)` +- New function `*EvidencesClient.Download(context.Context, string, string, EvidenceFileDownloadRequest, *EvidencesClientDownloadOptions) (EvidencesClientDownloadResponse, error)` +- New function `*EvidencesClient.Get(context.Context, string, string, *EvidencesClientGetOptions) (EvidencesClientGetResponse, error)` +- New function `*EvidencesClient.NewListByReportPager(string, *EvidencesClientListByReportOptions) *runtime.Pager[EvidencesClientListByReportResponse]` +- New function `NewProviderActionsClient(azcore.TokenCredential, *arm.ClientOptions) (*ProviderActionsClient, error)` +- New function `*ProviderActionsClient.CheckNameAvailability(context.Context, CheckNameAvailabilityRequest, *ProviderActionsClientCheckNameAvailabilityOptions) (ProviderActionsClientCheckNameAvailabilityResponse, error)` +- New function `*ProviderActionsClient.GetCollectionCount(context.Context, GetCollectionCountRequest, *ProviderActionsClientGetCollectionCountOptions) (ProviderActionsClientGetCollectionCountResponse, error)` +- New function `*ProviderActionsClient.GetOverviewStatus(context.Context, GetOverviewStatusRequest, *ProviderActionsClientGetOverviewStatusOptions) (ProviderActionsClientGetOverviewStatusResponse, error)` +- New function `*ProviderActionsClient.ListInUseStorageAccounts(context.Context, ListInUseStorageAccountsRequest, *ProviderActionsClientListInUseStorageAccountsOptions) (ProviderActionsClientListInUseStorageAccountsResponse, error)` +- New function `*ProviderActionsClient.BeginOnboard(context.Context, OnboardRequest, *ProviderActionsClientBeginOnboardOptions) (*runtime.Poller[ProviderActionsClientOnboardResponse], error)` +- New function `*ProviderActionsClient.BeginTriggerEvaluation(context.Context, TriggerEvaluationRequest, *ProviderActionsClientBeginTriggerEvaluationOptions) (*runtime.Poller[ProviderActionsClientTriggerEvaluationResponse], error)` +- New function `*ReportClient.BeginVerify(context.Context, string, *ReportClientBeginVerifyOptions) (*runtime.Poller[ReportClientVerifyResponse], error)` +- New function `*ReportsClient.BeginCreateOrUpdate(context.Context, string, ReportResource, *ReportsClientBeginCreateOrUpdateOptions) (*runtime.Poller[ReportsClientCreateOrUpdateResponse], error)` +- New function `*ReportsClient.BeginDelete(context.Context, string, *ReportsClientBeginDeleteOptions) (*runtime.Poller[ReportsClientDeleteResponse], error)` +- New function `*ReportsClient.BeginFix(context.Context, string, *ReportsClientBeginFixOptions) (*runtime.Poller[ReportsClientFixResponse], error)` +- New function `*ReportsClient.Get(context.Context, string, *ReportsClientGetOptions) (ReportsClientGetResponse, error)` +- New function `*ReportsClient.NestedResourceCheckNameAvailability(context.Context, string, CheckNameAvailabilityRequest, *ReportsClientNestedResourceCheckNameAvailabilityOptions) (ReportsClientNestedResourceCheckNameAvailabilityResponse, error)` +- New function `*ReportsClient.BeginSyncCertRecord(context.Context, string, SyncCertRecordRequest, *ReportsClientBeginSyncCertRecordOptions) (*runtime.Poller[ReportsClientSyncCertRecordResponse], error)` +- New function `*ReportsClient.BeginUpdate(context.Context, string, ReportResourcePatch, *ReportsClientBeginUpdateOptions) (*runtime.Poller[ReportsClientUpdateResponse], error)` +- New function `NewScopingConfigurationClient(azcore.TokenCredential, *arm.ClientOptions) (*ScopingConfigurationClient, error)` +- New function `*ScopingConfigurationClient.CreateOrUpdate(context.Context, string, string, ScopingConfigurationResource, *ScopingConfigurationClientCreateOrUpdateOptions) (ScopingConfigurationClientCreateOrUpdateResponse, error)` +- New function `*ScopingConfigurationClient.Delete(context.Context, string, string, *ScopingConfigurationClientDeleteOptions) (ScopingConfigurationClientDeleteResponse, error)` +- New function `*ScopingConfigurationClient.Get(context.Context, string, string, *ScopingConfigurationClientGetOptions) (ScopingConfigurationClientGetResponse, error)` +- New function `NewScopingConfigurationsClient(azcore.TokenCredential, *arm.ClientOptions) (*ScopingConfigurationsClient, error)` +- New function `*ScopingConfigurationsClient.NewListPager(string, *ScopingConfigurationsClientListOptions) *runtime.Pager[ScopingConfigurationsClientListResponse]` +- New function `*SnapshotsClient.BeginDownload(context.Context, string, string, SnapshotDownloadRequest, *SnapshotsClientBeginDownloadOptions) (*runtime.Poller[SnapshotsClientDownloadResponse], error)` +- New function `*SnapshotsClient.Get(context.Context, string, string, *SnapshotsClientGetOptions) (SnapshotsClientGetResponse, error)` +- New function `NewToolForMicrosoft365Client(azcore.TokenCredential, *arm.ClientOptions) (*ToolForMicrosoft365Client, error)` +- New function `*ToolForMicrosoft365Client.GetScopingQuestions(context.Context, string, *ToolForMicrosoft365ClientGetScopingQuestionsOptions) (ToolForMicrosoft365ClientGetScopingQuestionsResponse, error)` +- New function `NewWebhooksClient(azcore.TokenCredential, *arm.ClientOptions) (*WebhooksClient, error)` +- New function `*WebhooksClient.CreateOrUpdate(context.Context, string, string, WebhookResource, *WebhooksClientCreateOrUpdateOptions) (WebhooksClientCreateOrUpdateResponse, error)` +- New function `*WebhooksClient.Delete(context.Context, string, string, *WebhooksClientDeleteOptions) (WebhooksClientDeleteResponse, error)` +- New function `*WebhooksClient.Get(context.Context, string, string, *WebhooksClientGetOptions) (WebhooksClientGetResponse, error)` +- New function `*WebhooksClient.NewListPager(string, *WebhooksClientListOptions) *runtime.Pager[WebhooksClientListResponse]` +- New function `*WebhooksClient.Update(context.Context, string, string, WebhookResourcePatch, *WebhooksClientUpdateOptions) (WebhooksClientUpdateResponse, error)` +- New struct `CertSyncRecord` +- New struct `CheckNameAvailabilityRequest` +- New struct `CheckNameAvailabilityResponse` +- New struct `ControlSyncRecord` +- New struct `EvidenceFileDownloadRequest` +- New struct `EvidenceFileDownloadResponse` +- New struct `EvidenceFileDownloadResponseEvidenceFile` +- New struct `EvidenceProperties` +- New struct `EvidenceResource` +- New struct `EvidenceResourceListResult` +- New struct `GetCollectionCountRequest` +- New struct `GetCollectionCountResponse` +- New struct `GetOverviewStatusRequest` +- New struct `GetOverviewStatusResponse` +- New struct `ListInUseStorageAccountsRequest` +- New struct `ListInUseStorageAccountsResponse` +- New struct `OnboardRequest` +- New struct `OnboardResponse` +- New struct `QuickAssessment` +- New struct `Recommendation` +- New struct `RecommendationSolution` +- New struct `ReportFixResult` +- New struct `ReportPatchProperties` +- New struct `ReportResourceListResult` +- New struct `ReportVerificationResult` +- New struct `Responsibility` +- New struct `ResponsibilityResource` +- New struct `ScopingAnswer` +- New struct `ScopingConfigurationProperties` +- New struct `ScopingConfigurationResource` +- New struct `ScopingConfigurationResourceListResult` +- New struct `ScopingQuestion` +- New struct `ScopingQuestions` +- New struct `SnapshotResourceListResult` +- New struct `StatusItem` +- New struct `StorageInfo` +- New struct `SyncCertRecordRequest` +- New struct `SyncCertRecordResponse` +- New struct `TriggerEvaluationProperty` +- New struct `TriggerEvaluationRequest` +- New struct `TriggerEvaluationResponse` +- New struct `WebhookProperties` +- New struct `WebhookResource` +- New struct `WebhookResourceListResult` +- New struct `WebhookResourcePatch` +- New field `ControlFamilyName`, `ControlStatus`, `ResourceOrigin`, `ResourceStatus`, `ResourceStatusChangeDate`, `ResponsibilityDescription`, `ResponsibilityTitle` in struct `ComplianceReportItem` +- New field `ControlName`, `Responsibilities` in struct `Control` +- New field `ControlFamilyName`, `ControlFamilyStatus` in struct `ControlFamily` +- New field `NotApplicableCount`, `PendingCount` in struct `OverviewStatus` +- New field `CertRecords`, `Errors`, `StorageInfo` in struct `ReportProperties` +- New field `Filter`, `Orderby` in struct `ReportsClientListOptions` +- New anonymous field `ReportResourceListResult` in struct `ReportsClientListResponse` +- New field `AccountID`, `ResourceOrigin` in struct `ResourceMetadata` +- New field `Filter`, `Orderby` in struct `SnapshotsClientListOptions` +- New anonymous field `SnapshotResourceListResult` in struct `SnapshotsClientListResponse` + + ## 0.3.0 (2023-11-24) ### Features Added diff --git a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/autorest.md b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/autorest.md index 94705fbe4476..7f988a403f3d 100644 --- a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/autorest.md +++ b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/autorest.md @@ -5,9 +5,9 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/82ea406b73d671269217053d7ef336450d860345/specification/appcomplianceautomation/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/82ea406b73d671269217053d7ef336450d860345/specification/appcomplianceautomation/resource-manager/readme.go.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/appcomplianceautomation/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/appcomplianceautomation/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 0.3.0 +module-version: 1.0.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/client_factory.go b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/client_factory.go index 1a0e8ea99d01..87824d92a91a 100644 --- a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/client_factory.go +++ b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/client_factory.go @@ -16,8 +16,7 @@ import ( // 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 { - credential azcore.TokenCredential - options *arm.ClientOptions + internal *arm.Client } // NewClientFactory creates a new instance of ClientFactory with the specified values. @@ -25,42 +24,81 @@ type ClientFactory struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewClientFactory(credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { - _, err := arm.NewClient(moduleName, moduleVersion, credential, options) + internal, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } return &ClientFactory{ - credential: credential, - options: options.Clone(), + internal: internal, }, nil } +// NewEvidencesClient creates a new instance of EvidencesClient. +func (c *ClientFactory) NewEvidencesClient() *EvidencesClient { + return &EvidencesClient{ + internal: c.internal, + } +} + // NewOperationsClient creates a new instance of OperationsClient. func (c *ClientFactory) NewOperationsClient() *OperationsClient { - subClient, _ := NewOperationsClient(c.credential, c.options) - return subClient + return &OperationsClient{ + internal: c.internal, + } +} + +// NewProviderActionsClient creates a new instance of ProviderActionsClient. +func (c *ClientFactory) NewProviderActionsClient() *ProviderActionsClient { + return &ProviderActionsClient{ + internal: c.internal, + } } // NewReportClient creates a new instance of ReportClient. func (c *ClientFactory) NewReportClient() *ReportClient { - subClient, _ := NewReportClient(c.credential, c.options) - return subClient + return &ReportClient{ + internal: c.internal, + } } // NewReportsClient creates a new instance of ReportsClient. func (c *ClientFactory) NewReportsClient() *ReportsClient { - subClient, _ := NewReportsClient(c.credential, c.options) - return subClient + return &ReportsClient{ + internal: c.internal, + } +} + +// NewScopingConfigurationClient creates a new instance of ScopingConfigurationClient. +func (c *ClientFactory) NewScopingConfigurationClient() *ScopingConfigurationClient { + return &ScopingConfigurationClient{ + internal: c.internal, + } } -// NewSnapshotClient creates a new instance of SnapshotClient. -func (c *ClientFactory) NewSnapshotClient() *SnapshotClient { - subClient, _ := NewSnapshotClient(c.credential, c.options) - return subClient +// NewScopingConfigurationsClient creates a new instance of ScopingConfigurationsClient. +func (c *ClientFactory) NewScopingConfigurationsClient() *ScopingConfigurationsClient { + return &ScopingConfigurationsClient{ + internal: c.internal, + } } // NewSnapshotsClient creates a new instance of SnapshotsClient. func (c *ClientFactory) NewSnapshotsClient() *SnapshotsClient { - subClient, _ := NewSnapshotsClient(c.credential, c.options) - return subClient + return &SnapshotsClient{ + internal: c.internal, + } +} + +// NewToolForMicrosoft365Client creates a new instance of ToolForMicrosoft365Client. +func (c *ClientFactory) NewToolForMicrosoft365Client() *ToolForMicrosoft365Client { + return &ToolForMicrosoft365Client{ + internal: c.internal, + } +} + +// NewWebhooksClient creates a new instance of WebhooksClient. +func (c *ClientFactory) NewWebhooksClient() *WebhooksClient { + return &WebhooksClient{ + internal: c.internal, + } } diff --git a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/constants.go b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/constants.go index 3ded37802ab0..8669e3642a58 100644 --- a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/constants.go +++ b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/constants.go @@ -10,7 +10,7 @@ package armappcomplianceautomation const ( moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation" - moduleVersion = "v0.3.0" + moduleVersion = "v1.0.0" ) // ActionType - Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. @@ -27,71 +27,58 @@ func PossibleActionTypeValues() []ActionType { } } -// AssessmentSeverity - Indicates the assessment severity. -type AssessmentSeverity string - -const ( - AssessmentSeverityHigh AssessmentSeverity = "High" - AssessmentSeverityLow AssessmentSeverity = "Low" - AssessmentSeverityMedium AssessmentSeverity = "Medium" -) - -// PossibleAssessmentSeverityValues returns the possible values for the AssessmentSeverity const type. -func PossibleAssessmentSeverityValues() []AssessmentSeverity { - return []AssessmentSeverity{ - AssessmentSeverityHigh, - AssessmentSeverityLow, - AssessmentSeverityMedium, - } -} - // CategoryStatus - Indicates the category status. type CategoryStatus string const ( - CategoryStatusHealthy CategoryStatus = "Healthy" - CategoryStatusUnhealthy CategoryStatus = "Unhealthy" + // CategoryStatusFailed - The category is failed. + CategoryStatusFailed CategoryStatus = "Failed" + // CategoryStatusNotApplicable - The category is not applicable. + CategoryStatusNotApplicable CategoryStatus = "NotApplicable" + // CategoryStatusPassed - The category is passed. + CategoryStatusPassed CategoryStatus = "Passed" + // CategoryStatusPendingApproval - The category is pending for approval. + CategoryStatusPendingApproval CategoryStatus = "PendingApproval" ) // PossibleCategoryStatusValues returns the possible values for the CategoryStatus const type. func PossibleCategoryStatusValues() []CategoryStatus { return []CategoryStatus{ - CategoryStatusHealthy, - CategoryStatusUnhealthy, + CategoryStatusFailed, + CategoryStatusNotApplicable, + CategoryStatusPassed, + CategoryStatusPendingApproval, } } -// CategoryType - Indicates the compliance category type. -type CategoryType string +// CheckNameAvailabilityReason - The reason why the given name is not available. +type CheckNameAvailabilityReason string const ( - CategoryTypeFullyAutomated CategoryType = "FullyAutomated" - CategoryTypeManual CategoryType = "Manual" - CategoryTypePartiallyAutomated CategoryType = "PartiallyAutomated" + CheckNameAvailabilityReasonAlreadyExists CheckNameAvailabilityReason = "AlreadyExists" + CheckNameAvailabilityReasonInvalid CheckNameAvailabilityReason = "Invalid" ) -// PossibleCategoryTypeValues returns the possible values for the CategoryType const type. -func PossibleCategoryTypeValues() []CategoryType { - return []CategoryType{ - CategoryTypeFullyAutomated, - CategoryTypeManual, - CategoryTypePartiallyAutomated, +// PossibleCheckNameAvailabilityReasonValues returns the possible values for the CheckNameAvailabilityReason const type. +func PossibleCheckNameAvailabilityReasonValues() []CheckNameAvailabilityReason { + return []CheckNameAvailabilityReason{ + CheckNameAvailabilityReasonAlreadyExists, + CheckNameAvailabilityReasonInvalid, } } -// ComplianceState - The compliance result's status. -type ComplianceState string +// ContentType - content type +type ContentType string const ( - ComplianceStateHealthy ComplianceState = "Healthy" - ComplianceStateUnhealthy ComplianceState = "Unhealthy" + // ContentTypeApplicationJSON - The content type is application/json. + ContentTypeApplicationJSON ContentType = "application/json" ) -// PossibleComplianceStateValues returns the possible values for the ComplianceState const type. -func PossibleComplianceStateValues() []ComplianceState { - return []ComplianceState{ - ComplianceStateHealthy, - ComplianceStateUnhealthy, +// PossibleContentTypeValues returns the possible values for the ContentType const type. +func PossibleContentTypeValues() []ContentType { + return []ContentType{ + ContentTypeApplicationJSON, } } @@ -99,33 +86,23 @@ func PossibleComplianceStateValues() []ComplianceState { type ControlFamilyStatus string const ( - ControlFamilyStatusHealthy ControlFamilyStatus = "Healthy" - ControlFamilyStatusUnhealthy ControlFamilyStatus = "Unhealthy" + // ControlFamilyStatusFailed - The control family is failed. + ControlFamilyStatusFailed ControlFamilyStatus = "Failed" + // ControlFamilyStatusNotApplicable - The control family is not applicable. + ControlFamilyStatusNotApplicable ControlFamilyStatus = "NotApplicable" + // ControlFamilyStatusPassed - The control family is passed. + ControlFamilyStatusPassed ControlFamilyStatus = "Passed" + // ControlFamilyStatusPendingApproval - The control family is pending for approval. + ControlFamilyStatusPendingApproval ControlFamilyStatus = "PendingApproval" ) // PossibleControlFamilyStatusValues returns the possible values for the ControlFamilyStatus const type. func PossibleControlFamilyStatusValues() []ControlFamilyStatus { return []ControlFamilyStatus{ - ControlFamilyStatusHealthy, - ControlFamilyStatusUnhealthy, - } -} - -// ControlFamilyType - Indicates the control family type. -type ControlFamilyType string - -const ( - ControlFamilyTypeFullyAutomated ControlFamilyType = "FullyAutomated" - ControlFamilyTypeManual ControlFamilyType = "Manual" - ControlFamilyTypePartiallyAutomated ControlFamilyType = "PartiallyAutomated" -) - -// PossibleControlFamilyTypeValues returns the possible values for the ControlFamilyType const type. -func PossibleControlFamilyTypeValues() []ControlFamilyType { - return []ControlFamilyType{ - ControlFamilyTypeFullyAutomated, - ControlFamilyTypeManual, - ControlFamilyTypePartiallyAutomated, + ControlFamilyStatusFailed, + ControlFamilyStatusNotApplicable, + ControlFamilyStatusPassed, + ControlFamilyStatusPendingApproval, } } @@ -133,9 +110,14 @@ func PossibleControlFamilyTypeValues() []ControlFamilyType { type ControlStatus string const ( - ControlStatusFailed ControlStatus = "Failed" + // ControlStatusFailed - The control is failed. + ControlStatusFailed ControlStatus = "Failed" + // ControlStatusNotApplicable - The control is not applicable. ControlStatusNotApplicable ControlStatus = "NotApplicable" - ControlStatusPassed ControlStatus = "Passed" + // ControlStatusPassed - The control is passed. + ControlStatusPassed ControlStatus = "Passed" + // ControlStatusPendingApproval - The control is pending for approval. + ControlStatusPendingApproval ControlStatus = "PendingApproval" ) // PossibleControlStatusValues returns the possible values for the ControlStatus const type. @@ -144,24 +126,7 @@ func PossibleControlStatusValues() []ControlStatus { ControlStatusFailed, ControlStatusNotApplicable, ControlStatusPassed, - } -} - -// ControlType - Indicates the control type. -type ControlType string - -const ( - ControlTypeFullyAutomated ControlType = "FullyAutomated" - ControlTypeManual ControlType = "Manual" - ControlTypePartiallyAutomated ControlType = "PartiallyAutomated" -) - -// PossibleControlTypeValues returns the possible values for the ControlType const type. -func PossibleControlTypeValues() []ControlType { - return []ControlType{ - ControlTypeFullyAutomated, - ControlTypeManual, - ControlTypePartiallyAutomated, + ControlStatusPendingApproval, } } @@ -185,14 +150,39 @@ func PossibleCreatedByTypeValues() []CreatedByType { } } +// DeliveryStatus - webhook deliveryStatus +type DeliveryStatus string + +const ( + // DeliveryStatusFailed - The webhook is failed to deliver. + DeliveryStatusFailed DeliveryStatus = "Failed" + // DeliveryStatusNotStarted - The webhook is not delivered. + DeliveryStatusNotStarted DeliveryStatus = "NotStarted" + // DeliveryStatusSucceeded - The webhook is delivered successfully. + DeliveryStatusSucceeded DeliveryStatus = "Succeeded" +) + +// PossibleDeliveryStatusValues returns the possible values for the DeliveryStatus const type. +func PossibleDeliveryStatusValues() []DeliveryStatus { + return []DeliveryStatus{ + DeliveryStatusFailed, + DeliveryStatusNotStarted, + DeliveryStatusSucceeded, + } +} + // DownloadType - Indicates the download type. type DownloadType string const ( + // DownloadTypeComplianceDetailedPDFReport - Download the detailed compliance pdf report. DownloadTypeComplianceDetailedPDFReport DownloadType = "ComplianceDetailedPdfReport" - DownloadTypeCompliancePDFReport DownloadType = "CompliancePdfReport" - DownloadTypeComplianceReport DownloadType = "ComplianceReport" - DownloadTypeResourceList DownloadType = "ResourceList" + // DownloadTypeCompliancePDFReport - Download the compliance pdf report. + DownloadTypeCompliancePDFReport DownloadType = "CompliancePdfReport" + // DownloadTypeComplianceReport - Download the compliance report. + DownloadTypeComplianceReport DownloadType = "ComplianceReport" + // DownloadTypeResourceList - Download the resource list of the report. + DownloadTypeResourceList DownloadType = "ResourceList" ) // PossibleDownloadTypeValues returns the possible values for the DownloadType const type. @@ -205,19 +195,153 @@ func PossibleDownloadTypeValues() []DownloadType { } } -// IsPass - Indicates whether all the resource(s) are compliant. -type IsPass string +// EnableSSLVerification - whether to enable ssl verification +type EnableSSLVerification string const ( - IsPassFalse IsPass = "False" - IsPassTrue IsPass = "True" + // EnableSSLVerificationFalse - The ssl verification is not enabled. + EnableSSLVerificationFalse EnableSSLVerification = "false" + // EnableSSLVerificationTrue - The ssl verification is enabled. + EnableSSLVerificationTrue EnableSSLVerification = "true" ) -// PossibleIsPassValues returns the possible values for the IsPass const type. -func PossibleIsPassValues() []IsPass { - return []IsPass{ - IsPassFalse, - IsPassTrue, +// PossibleEnableSSLVerificationValues returns the possible values for the EnableSSLVerification const type. +func PossibleEnableSSLVerificationValues() []EnableSSLVerification { + return []EnableSSLVerification{ + EnableSSLVerificationFalse, + EnableSSLVerificationTrue, + } +} + +// EvidenceType - Evidence type +type EvidenceType string + +const ( + // EvidenceTypeAutoCollectedEvidence - The evidence auto collected by App Compliance Automation. + EvidenceTypeAutoCollectedEvidence EvidenceType = "AutoCollectedEvidence" + // EvidenceTypeData - The evidence is data. + EvidenceTypeData EvidenceType = "Data" + // EvidenceTypeFile - The evidence is a file. + EvidenceTypeFile EvidenceType = "File" +) + +// PossibleEvidenceTypeValues returns the possible values for the EvidenceType const type. +func PossibleEvidenceTypeValues() []EvidenceType { + return []EvidenceType{ + EvidenceTypeAutoCollectedEvidence, + EvidenceTypeData, + EvidenceTypeFile, + } +} + +// InputType - Question input type. +type InputType string + +const ( + // InputTypeBoolean - The input content should be a boolean. + InputTypeBoolean InputType = "Boolean" + // InputTypeDate - The input content should be a date. + InputTypeDate InputType = "Date" + // InputTypeEmail - The input content should be an email address. + InputTypeEmail InputType = "Email" + // InputTypeGroup - The input content is a group of answers. + InputTypeGroup InputType = "Group" + // InputTypeMultiSelectCheckbox - The input content are multiple results seleted from the checkboxes. + InputTypeMultiSelectCheckbox InputType = "MultiSelectCheckbox" + // InputTypeMultiSelectDropdown - The input content are multiple results seleted from the dropdown options. + InputTypeMultiSelectDropdown InputType = "MultiSelectDropdown" + // InputTypeMultiSelectDropdownCustom - The input content are result seleted from the custom dropdown options. + InputTypeMultiSelectDropdownCustom InputType = "MultiSelectDropdownCustom" + // InputTypeMultilineText - The input content should be multiline text. + InputTypeMultilineText InputType = "MultilineText" + // InputTypeNone - The input type is a text box. + InputTypeNone InputType = "None" + // InputTypeNumber - The input content should be a number. + InputTypeNumber InputType = "Number" + // InputTypeSingleSelectDropdown - The input content is a single result seleted from the dropdown options. + InputTypeSingleSelectDropdown InputType = "SingleSelectDropdown" + // InputTypeSingleSelection - The input content is a single result seleted from the options. + InputTypeSingleSelection InputType = "SingleSelection" + // InputTypeTelephone - The input content should be a telephone number. + InputTypeTelephone InputType = "Telephone" + // InputTypeText - The input content is text string. + InputTypeText InputType = "Text" + // InputTypeURL - The input content should be a URL. + InputTypeURL InputType = "Url" + // InputTypeUpload - The input content is a uploaded file. + InputTypeUpload InputType = "Upload" + // InputTypeYearPicker - The input content is a Year, pick from the dropdown list. + InputTypeYearPicker InputType = "YearPicker" + // InputTypeYesNoNa - The input content should be Yes, No or Na. + InputTypeYesNoNa InputType = "YesNoNa" +) + +// PossibleInputTypeValues returns the possible values for the InputType const type. +func PossibleInputTypeValues() []InputType { + return []InputType{ + InputTypeBoolean, + InputTypeDate, + InputTypeEmail, + InputTypeGroup, + InputTypeMultiSelectCheckbox, + InputTypeMultiSelectDropdown, + InputTypeMultiSelectDropdownCustom, + InputTypeMultilineText, + InputTypeNone, + InputTypeNumber, + InputTypeSingleSelectDropdown, + InputTypeSingleSelection, + InputTypeTelephone, + InputTypeText, + InputTypeURL, + InputTypeUpload, + InputTypeYearPicker, + InputTypeYesNoNa, + } +} + +// IsRecommendSolution - Indicates whether this solution is the recommended. +type IsRecommendSolution string + +const ( + // IsRecommendSolutionFalse - This solution is not the recommended. + IsRecommendSolutionFalse IsRecommendSolution = "false" + // IsRecommendSolutionTrue - This solution is the recommended. + IsRecommendSolutionTrue IsRecommendSolution = "true" +) + +// PossibleIsRecommendSolutionValues returns the possible values for the IsRecommendSolution const type. +func PossibleIsRecommendSolutionValues() []IsRecommendSolution { + return []IsRecommendSolution{ + IsRecommendSolutionFalse, + IsRecommendSolutionTrue, + } +} + +// NotificationEvent - notification event. +type NotificationEvent string + +const ( + // NotificationEventAssessmentFailure - The subscribed report failed while collecting the assessments. + NotificationEventAssessmentFailure NotificationEvent = "assessment_failure" + // NotificationEventGenerateSnapshotFailed - The subscribed report's snapshot is failed to generate. + NotificationEventGenerateSnapshotFailed NotificationEvent = "generate_snapshot_failed" + // NotificationEventGenerateSnapshotSuccess - The subscribed report's snapshot is successfully generated. + NotificationEventGenerateSnapshotSuccess NotificationEvent = "generate_snapshot_success" + // NotificationEventReportConfigurationChanges - The subscribed report's configuration is changed. + NotificationEventReportConfigurationChanges NotificationEvent = "report_configuration_changes" + // NotificationEventReportDeletion - The subscribed report is deleted. + NotificationEventReportDeletion NotificationEvent = "report_deletion" +) + +// PossibleNotificationEventValues returns the possible values for the NotificationEvent const type. +func PossibleNotificationEventValues() []NotificationEvent { + return []NotificationEvent{ + NotificationEventAssessmentFailure, + NotificationEventGenerateSnapshotFailed, + NotificationEventGenerateSnapshotSuccess, + NotificationEventReportConfigurationChanges, + NotificationEventReportDeletion, } } @@ -244,12 +368,22 @@ func PossibleOriginValues() []Origin { type ProvisioningState string const ( - ProvisioningStateCanceled ProvisioningState = "Canceled" - ProvisioningStateCreating ProvisioningState = "Creating" - ProvisioningStateDeleting ProvisioningState = "Deleting" - ProvisioningStateFailed ProvisioningState = "Failed" + // ProvisioningStateCanceled - The provision is canceled. + ProvisioningStateCanceled ProvisioningState = "Canceled" + // ProvisioningStateCreating - The creation is in progress. + ProvisioningStateCreating ProvisioningState = "Creating" + // ProvisioningStateDeleting - The deletion is in progress. + ProvisioningStateDeleting ProvisioningState = "Deleting" + // ProvisioningStateFailed - The provision is failed. + ProvisioningStateFailed ProvisioningState = "Failed" + // ProvisioningStateFixing - The fix of the resource in progress. + ProvisioningStateFixing ProvisioningState = "Fixing" + // ProvisioningStateSucceeded - The provision is succeeded. ProvisioningStateSucceeded ProvisioningState = "Succeeded" - ProvisioningStateUpdating ProvisioningState = "Updating" + // ProvisioningStateUpdating - The update of the resource in progress. + ProvisioningStateUpdating ProvisioningState = "Updating" + // ProvisioningStateVerifying - The verification of the resource in progress. + ProvisioningStateVerifying ProvisioningState = "Verifying" ) // PossibleProvisioningStateValues returns the possible values for the ProvisioningState const type. @@ -259,8 +393,10 @@ func PossibleProvisioningStateValues() []ProvisioningState { ProvisioningStateCreating, ProvisioningStateDeleting, ProvisioningStateFailed, + ProvisioningStateFixing, ProvisioningStateSucceeded, ProvisioningStateUpdating, + ProvisioningStateVerifying, } } @@ -268,9 +404,14 @@ func PossibleProvisioningStateValues() []ProvisioningState { type ReportStatus string const ( - ReportStatusActive ReportStatus = "Active" + // ReportStatusActive - The report is active. + ReportStatusActive ReportStatus = "Active" + // ReportStatusDisabled - The report is disabled. ReportStatusDisabled ReportStatus = "Disabled" - ReportStatusFailed ReportStatus = "Failed" + // ReportStatusFailed - The report is failed. + ReportStatusFailed ReportStatus = "Failed" + // ReportStatusReviewing - The report is under reviewing. + ReportStatusReviewing ReportStatus = "Reviewing" ) // PossibleReportStatusValues returns the possible values for the ReportStatus const type. @@ -279,6 +420,28 @@ func PossibleReportStatusValues() []ReportStatus { ReportStatusActive, ReportStatusDisabled, ReportStatusFailed, + ReportStatusReviewing, + } +} + +// ResourceOrigin - Resource Origin. +type ResourceOrigin string + +const ( + // ResourceOriginAWS - The resource is from AWS. + ResourceOriginAWS ResourceOrigin = "AWS" + // ResourceOriginAzure - The resource is from Azure. + ResourceOriginAzure ResourceOrigin = "Azure" + // ResourceOriginGCP - The resource is from GCP. + ResourceOriginGCP ResourceOrigin = "GCP" +) + +// PossibleResourceOriginValues returns the possible values for the ResourceOrigin const type. +func PossibleResourceOriginValues() []ResourceOrigin { + return []ResourceOrigin{ + ResourceOriginAWS, + ResourceOriginAzure, + ResourceOriginGCP, } } @@ -286,16 +449,250 @@ func PossibleReportStatusValues() []ReportStatus { type ResourceStatus string const ( - ResourceStatusHealthy ResourceStatus = "Healthy" - ResourceStatusNotApplicable ResourceStatus = "NotApplicable" - ResourceStatusUnhealthy ResourceStatus = "Unhealthy" + // ResourceStatusHealthy - The resource is healthy. + ResourceStatusHealthy ResourceStatus = "Healthy" + // ResourceStatusUnhealthy - The resource is unhealthy. + ResourceStatusUnhealthy ResourceStatus = "Unhealthy" ) // PossibleResourceStatusValues returns the possible values for the ResourceStatus const type. func PossibleResourceStatusValues() []ResourceStatus { return []ResourceStatus{ ResourceStatusHealthy, - ResourceStatusNotApplicable, ResourceStatusUnhealthy, } } + +// ResponsibilityEnvironment - Indicates the customer responsibility supported cloud environment. +type ResponsibilityEnvironment string + +const ( + // ResponsibilityEnvironmentAWS - The responsibility is supported in AWS. + ResponsibilityEnvironmentAWS ResponsibilityEnvironment = "AWS" + // ResponsibilityEnvironmentAzure - The responsibility is supported in Azure. + ResponsibilityEnvironmentAzure ResponsibilityEnvironment = "Azure" + // ResponsibilityEnvironmentGCP - The responsibility is supported in GCP. + ResponsibilityEnvironmentGCP ResponsibilityEnvironment = "GCP" + // ResponsibilityEnvironmentGeneral - The responsibility is general requirement of all environment. + ResponsibilityEnvironmentGeneral ResponsibilityEnvironment = "General" +) + +// PossibleResponsibilityEnvironmentValues returns the possible values for the ResponsibilityEnvironment const type. +func PossibleResponsibilityEnvironmentValues() []ResponsibilityEnvironment { + return []ResponsibilityEnvironment{ + ResponsibilityEnvironmentAWS, + ResponsibilityEnvironmentAzure, + ResponsibilityEnvironmentGCP, + ResponsibilityEnvironmentGeneral, + } +} + +// ResponsibilitySeverity - Indicates the customer responsibility severity. +type ResponsibilitySeverity string + +const ( + // ResponsibilitySeverityHigh - The responsibility is high severity. + ResponsibilitySeverityHigh ResponsibilitySeverity = "High" + // ResponsibilitySeverityLow - The responsibility is low severity. + ResponsibilitySeverityLow ResponsibilitySeverity = "Low" + // ResponsibilitySeverityMedium - The responsibility is medium severity. + ResponsibilitySeverityMedium ResponsibilitySeverity = "Medium" +) + +// PossibleResponsibilitySeverityValues returns the possible values for the ResponsibilitySeverity const type. +func PossibleResponsibilitySeverityValues() []ResponsibilitySeverity { + return []ResponsibilitySeverity{ + ResponsibilitySeverityHigh, + ResponsibilitySeverityLow, + ResponsibilitySeverityMedium, + } +} + +// ResponsibilityStatus - Indicates the customer responsibility status. +type ResponsibilityStatus string + +const ( + // ResponsibilityStatusFailed - The responsibility is failed. + ResponsibilityStatusFailed ResponsibilityStatus = "Failed" + // ResponsibilityStatusNotApplicable - The responsibility is not applicable. + ResponsibilityStatusNotApplicable ResponsibilityStatus = "NotApplicable" + // ResponsibilityStatusPassed - The responsibility is passed. + ResponsibilityStatusPassed ResponsibilityStatus = "Passed" + // ResponsibilityStatusPendingApproval - The responsibility is pending for approval. + ResponsibilityStatusPendingApproval ResponsibilityStatus = "PendingApproval" +) + +// PossibleResponsibilityStatusValues returns the possible values for the ResponsibilityStatus const type. +func PossibleResponsibilityStatusValues() []ResponsibilityStatus { + return []ResponsibilityStatus{ + ResponsibilityStatusFailed, + ResponsibilityStatusNotApplicable, + ResponsibilityStatusPassed, + ResponsibilityStatusPendingApproval, + } +} + +// ResponsibilityType - Indicates the customer responsibility type. +type ResponsibilityType string + +const ( + // ResponsibilityTypeAutomated - The responsibility is automated. + ResponsibilityTypeAutomated ResponsibilityType = "Automated" + // ResponsibilityTypeManual - The responsibility is manual. + ResponsibilityTypeManual ResponsibilityType = "Manual" + // ResponsibilityTypeScopedManual - The responsibility is scoped manual. + ResponsibilityTypeScopedManual ResponsibilityType = "ScopedManual" +) + +// PossibleResponsibilityTypeValues returns the possible values for the ResponsibilityType const type. +func PossibleResponsibilityTypeValues() []ResponsibilityType { + return []ResponsibilityType{ + ResponsibilityTypeAutomated, + ResponsibilityTypeManual, + ResponsibilityTypeScopedManual, + } +} + +// Result - Indicates whether the fix action is Succeeded or Failed. +type Result string + +const ( + // ResultFailed - The result is failed. + ResultFailed Result = "Failed" + // ResultSucceeded - The result is succeeded. + ResultSucceeded Result = "Succeeded" +) + +// PossibleResultValues returns the possible values for the Result const type. +func PossibleResultValues() []Result { + return []Result{ + ResultFailed, + ResultSucceeded, + } +} + +// Rule - Scoping question rule. +type Rule string + +const ( + // RuleAzureApplication - The question answer should be an AzureApplication. + RuleAzureApplication Rule = "AzureApplication" + // RuleCharLength - The question answer length is limited. + RuleCharLength Rule = "CharLength" + // RuleCreditCardPCI - The question answer should be a CreditCardPCI. + RuleCreditCardPCI Rule = "CreditCardPCI" + // RuleDomains - The question answer should be domains. + RuleDomains Rule = "Domains" + // RuleDynamicDropdown - The question answer should be dynamic dropdown. + RuleDynamicDropdown Rule = "DynamicDropdown" + // RulePreventNonEnglishChar - The question answer should prevent non-english char. + RulePreventNonEnglishChar Rule = "PreventNonEnglishChar" + // RulePublicSOX - The question answer should be a PublicSOX. + RulePublicSOX Rule = "PublicSOX" + // RulePublisherVerification - The question answer should be publisher verification. + RulePublisherVerification Rule = "PublisherVerification" + // RuleRequired - The question is required to answer. + RuleRequired Rule = "Required" + // RuleURL - The question answer should be an Url. + RuleURL Rule = "Url" + // RuleUSPrivacyShield - The question answer should be a UsPrivacyShield. + RuleUSPrivacyShield Rule = "USPrivacyShield" + // RuleUrls - The question answer should be Urls. + RuleUrls Rule = "Urls" + // RuleValidEmail - The question answer should be a valid email. + RuleValidEmail Rule = "ValidEmail" + // RuleValidGUID - The question answer should be a valid guid. + RuleValidGUID Rule = "ValidGuid" +) + +// PossibleRuleValues returns the possible values for the Rule const type. +func PossibleRuleValues() []Rule { + return []Rule{ + RuleAzureApplication, + RuleCharLength, + RuleCreditCardPCI, + RuleDomains, + RuleDynamicDropdown, + RulePreventNonEnglishChar, + RulePublicSOX, + RulePublisherVerification, + RuleRequired, + RuleURL, + RuleUSPrivacyShield, + RuleUrls, + RuleValidEmail, + RuleValidGUID, + } +} + +// SendAllEvents - whether to send notification under any event. +type SendAllEvents string + +const ( + // SendAllEventsFalse - No need to send notification under any event. + SendAllEventsFalse SendAllEvents = "false" + // SendAllEventsTrue - Need send notification under any event. + SendAllEventsTrue SendAllEvents = "true" +) + +// PossibleSendAllEventsValues returns the possible values for the SendAllEvents const type. +func PossibleSendAllEventsValues() []SendAllEvents { + return []SendAllEvents{ + SendAllEventsFalse, + SendAllEventsTrue, + } +} + +// UpdateWebhookKey - whether to update webhookKey. +type UpdateWebhookKey string + +const ( + // UpdateWebhookKeyFalse - No need to update the webhook key. + UpdateWebhookKeyFalse UpdateWebhookKey = "false" + // UpdateWebhookKeyTrue - Need update the webhook key. + UpdateWebhookKeyTrue UpdateWebhookKey = "true" +) + +// PossibleUpdateWebhookKeyValues returns the possible values for the UpdateWebhookKey const type. +func PossibleUpdateWebhookKeyValues() []UpdateWebhookKey { + return []UpdateWebhookKey{ + UpdateWebhookKeyFalse, + UpdateWebhookKeyTrue, + } +} + +// WebhookKeyEnabled - whether webhookKey is enabled. +type WebhookKeyEnabled string + +const ( + // WebhookKeyEnabledFalse - The webhookKey is not enabled. + WebhookKeyEnabledFalse WebhookKeyEnabled = "false" + // WebhookKeyEnabledTrue - The webhookKey is enabled. + WebhookKeyEnabledTrue WebhookKeyEnabled = "true" +) + +// PossibleWebhookKeyEnabledValues returns the possible values for the WebhookKeyEnabled const type. +func PossibleWebhookKeyEnabledValues() []WebhookKeyEnabled { + return []WebhookKeyEnabled{ + WebhookKeyEnabledFalse, + WebhookKeyEnabledTrue, + } +} + +// WebhookStatus - Webhook status. +type WebhookStatus string + +const ( + // WebhookStatusDisabled - The webhook is disabled. + WebhookStatusDisabled WebhookStatus = "Disabled" + // WebhookStatusEnabled - The webhook is enabled. + WebhookStatusEnabled WebhookStatus = "Enabled" +) + +// PossibleWebhookStatusValues returns the possible values for the WebhookStatus const type. +func PossibleWebhookStatusValues() []WebhookStatus { + return []WebhookStatus{ + WebhookStatusDisabled, + WebhookStatusEnabled, + } +} diff --git a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/evidences_client.go b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/evidences_client.go new file mode 100644 index 000000000000..0ce1462b7d78 --- /dev/null +++ b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/evidences_client.go @@ -0,0 +1,364 @@ +//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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armappcomplianceautomation + +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" + "strconv" + "strings" +) + +// EvidencesClient contains the methods for the Evidences group. +// Don't use this type directly, use NewEvidencesClient() instead. +type EvidencesClient struct { + internal *arm.Client +} + +// NewEvidencesClient creates a new instance of EvidencesClient with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewEvidencesClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*EvidencesClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &EvidencesClient{ + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Create or Update an evidence a specified report +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-06-27 +// - reportName - Report Name. +// - evidenceName - The evidence name. +// - parameters - Parameters for the create or update operation +// - options - EvidencesClientCreateOrUpdateOptions contains the optional parameters for the EvidencesClient.CreateOrUpdate +// method. +func (client *EvidencesClient) CreateOrUpdate(ctx context.Context, reportName string, evidenceName string, parameters EvidenceResource, options *EvidencesClientCreateOrUpdateOptions) (EvidencesClientCreateOrUpdateResponse, error) { + var err error + const operationName = "EvidencesClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, reportName, evidenceName, parameters, options) + if err != nil { + return EvidencesClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return EvidencesClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return EvidencesClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *EvidencesClient) createOrUpdateCreateRequest(ctx context.Context, reportName string, evidenceName string, parameters EvidenceResource, options *EvidencesClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.AppComplianceAutomation/reports/{reportName}/evidences/{evidenceName}" + if reportName == "" { + return nil, errors.New("parameter reportName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reportName}", url.PathEscape(reportName)) + if evidenceName == "" { + return nil, errors.New("parameter evidenceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{evidenceName}", url.PathEscape(evidenceName)) + 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", "2024-06-27") + if options != nil && options.OfferGUID != nil { + reqQP.Set("offerGuid", *options.OfferGUID) + } + if options != nil && options.ReportCreatorTenantID != nil { + reqQP.Set("reportCreatorTenantId", *options.ReportCreatorTenantID) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *EvidencesClient) createOrUpdateHandleResponse(resp *http.Response) (EvidencesClientCreateOrUpdateResponse, error) { + result := EvidencesClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.EvidenceResource); err != nil { + return EvidencesClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Delete an existent evidence from a specified report +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-06-27 +// - reportName - Report Name. +// - evidenceName - The evidence name. +// - options - EvidencesClientDeleteOptions contains the optional parameters for the EvidencesClient.Delete method. +func (client *EvidencesClient) Delete(ctx context.Context, reportName string, evidenceName string, options *EvidencesClientDeleteOptions) (EvidencesClientDeleteResponse, error) { + var err error + const operationName = "EvidencesClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, reportName, evidenceName, options) + if err != nil { + return EvidencesClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return EvidencesClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return EvidencesClientDeleteResponse{}, err + } + return EvidencesClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *EvidencesClient) deleteCreateRequest(ctx context.Context, reportName string, evidenceName string, options *EvidencesClientDeleteOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.AppComplianceAutomation/reports/{reportName}/evidences/{evidenceName}" + if reportName == "" { + return nil, errors.New("parameter reportName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reportName}", url.PathEscape(reportName)) + if evidenceName == "" { + return nil, errors.New("parameter evidenceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{evidenceName}", url.PathEscape(evidenceName)) + 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", "2024-06-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Download - Download evidence file. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-06-27 +// - reportName - Report Name. +// - evidenceName - The evidence name. +// - body - Parameters for the query operation +// - options - EvidencesClientDownloadOptions contains the optional parameters for the EvidencesClient.Download method. +func (client *EvidencesClient) Download(ctx context.Context, reportName string, evidenceName string, body EvidenceFileDownloadRequest, options *EvidencesClientDownloadOptions) (EvidencesClientDownloadResponse, error) { + var err error + const operationName = "EvidencesClient.Download" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.downloadCreateRequest(ctx, reportName, evidenceName, body, options) + if err != nil { + return EvidencesClientDownloadResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return EvidencesClientDownloadResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return EvidencesClientDownloadResponse{}, err + } + resp, err := client.downloadHandleResponse(httpResp) + return resp, err +} + +// downloadCreateRequest creates the Download request. +func (client *EvidencesClient) downloadCreateRequest(ctx context.Context, reportName string, evidenceName string, body EvidenceFileDownloadRequest, options *EvidencesClientDownloadOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.AppComplianceAutomation/reports/{reportName}/evidences/{evidenceName}/download" + if reportName == "" { + return nil, errors.New("parameter reportName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reportName}", url.PathEscape(reportName)) + if evidenceName == "" { + return nil, errors.New("parameter evidenceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{evidenceName}", url.PathEscape(evidenceName)) + 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", "2024-06-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} + +// downloadHandleResponse handles the Download response. +func (client *EvidencesClient) downloadHandleResponse(resp *http.Response) (EvidencesClientDownloadResponse, error) { + result := EvidencesClientDownloadResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.EvidenceFileDownloadResponse); err != nil { + return EvidencesClientDownloadResponse{}, err + } + return result, nil +} + +// Get - Get the evidence metadata +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-06-27 +// - reportName - Report Name. +// - evidenceName - The evidence name. +// - options - EvidencesClientGetOptions contains the optional parameters for the EvidencesClient.Get method. +func (client *EvidencesClient) Get(ctx context.Context, reportName string, evidenceName string, options *EvidencesClientGetOptions) (EvidencesClientGetResponse, error) { + var err error + const operationName = "EvidencesClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, reportName, evidenceName, options) + if err != nil { + return EvidencesClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return EvidencesClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return EvidencesClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *EvidencesClient) getCreateRequest(ctx context.Context, reportName string, evidenceName string, options *EvidencesClientGetOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.AppComplianceAutomation/reports/{reportName}/evidences/{evidenceName}" + if reportName == "" { + return nil, errors.New("parameter reportName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reportName}", url.PathEscape(reportName)) + if evidenceName == "" { + return nil, errors.New("parameter evidenceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{evidenceName}", url.PathEscape(evidenceName)) + 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", "2024-06-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *EvidencesClient) getHandleResponse(resp *http.Response) (EvidencesClientGetResponse, error) { + result := EvidencesClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.EvidenceResource); err != nil { + return EvidencesClientGetResponse{}, err + } + return result, nil +} + +// NewListByReportPager - Returns a paginated list of evidences for a specified report. +// +// Generated from API version 2024-06-27 +// - reportName - Report Name. +// - options - EvidencesClientListByReportOptions contains the optional parameters for the EvidencesClient.NewListByReportPager +// method. +func (client *EvidencesClient) NewListByReportPager(reportName string, options *EvidencesClientListByReportOptions) *runtime.Pager[EvidencesClientListByReportResponse] { + return runtime.NewPager(runtime.PagingHandler[EvidencesClientListByReportResponse]{ + More: func(page EvidencesClientListByReportResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *EvidencesClientListByReportResponse) (EvidencesClientListByReportResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "EvidencesClient.NewListByReportPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByReportCreateRequest(ctx, reportName, options) + }, nil) + if err != nil { + return EvidencesClientListByReportResponse{}, err + } + return client.listByReportHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByReportCreateRequest creates the ListByReport request. +func (client *EvidencesClient) listByReportCreateRequest(ctx context.Context, reportName string, options *EvidencesClientListByReportOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.AppComplianceAutomation/reports/{reportName}/evidences" + if reportName == "" { + return nil, errors.New("parameter reportName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reportName}", url.PathEscape(reportName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Orderby != nil { + reqQP.Set("$orderby", *options.Orderby) + } + if options != nil && options.Select != nil { + reqQP.Set("$select", *options.Select) + } + if options != nil && options.SkipToken != nil { + reqQP.Set("$skipToken", *options.SkipToken) + } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-06-27") + if options != nil && options.OfferGUID != nil { + reqQP.Set("offerGuid", *options.OfferGUID) + } + if options != nil && options.ReportCreatorTenantID != nil { + reqQP.Set("reportCreatorTenantId", *options.ReportCreatorTenantID) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByReportHandleResponse handles the ListByReport response. +func (client *EvidencesClient) listByReportHandleResponse(resp *http.Response) (EvidencesClientListByReportResponse, error) { + result := EvidencesClientListByReportResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.EvidenceResourceListResult); err != nil { + return EvidencesClientListByReportResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/fake/evidences_server.go b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/fake/evidences_server.go new file mode 100644 index 000000000000..9523d250a668 --- /dev/null +++ b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/fake/evidences_server.go @@ -0,0 +1,349 @@ +//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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// EvidencesServer is a fake server for instances of the armappcomplianceautomation.EvidencesClient type. +type EvidencesServer struct { + // CreateOrUpdate is the fake for method EvidencesClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, reportName string, evidenceName string, parameters armappcomplianceautomation.EvidenceResource, options *armappcomplianceautomation.EvidencesClientCreateOrUpdateOptions) (resp azfake.Responder[armappcomplianceautomation.EvidencesClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method EvidencesClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, reportName string, evidenceName string, options *armappcomplianceautomation.EvidencesClientDeleteOptions) (resp azfake.Responder[armappcomplianceautomation.EvidencesClientDeleteResponse], errResp azfake.ErrorResponder) + + // Download is the fake for method EvidencesClient.Download + // HTTP status codes to indicate success: http.StatusOK + Download func(ctx context.Context, reportName string, evidenceName string, body armappcomplianceautomation.EvidenceFileDownloadRequest, options *armappcomplianceautomation.EvidencesClientDownloadOptions) (resp azfake.Responder[armappcomplianceautomation.EvidencesClientDownloadResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method EvidencesClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, reportName string, evidenceName string, options *armappcomplianceautomation.EvidencesClientGetOptions) (resp azfake.Responder[armappcomplianceautomation.EvidencesClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByReportPager is the fake for method EvidencesClient.NewListByReportPager + // HTTP status codes to indicate success: http.StatusOK + NewListByReportPager func(reportName string, options *armappcomplianceautomation.EvidencesClientListByReportOptions) (resp azfake.PagerResponder[armappcomplianceautomation.EvidencesClientListByReportResponse]) +} + +// NewEvidencesServerTransport creates a new instance of EvidencesServerTransport with the provided implementation. +// The returned EvidencesServerTransport instance is connected to an instance of armappcomplianceautomation.EvidencesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewEvidencesServerTransport(srv *EvidencesServer) *EvidencesServerTransport { + return &EvidencesServerTransport{ + srv: srv, + newListByReportPager: newTracker[azfake.PagerResponder[armappcomplianceautomation.EvidencesClientListByReportResponse]](), + } +} + +// EvidencesServerTransport connects instances of armappcomplianceautomation.EvidencesClient to instances of EvidencesServer. +// Don't use this type directly, use NewEvidencesServerTransport instead. +type EvidencesServerTransport struct { + srv *EvidencesServer + newListByReportPager *tracker[azfake.PagerResponder[armappcomplianceautomation.EvidencesClientListByReportResponse]] +} + +// Do implements the policy.Transporter interface for EvidencesServerTransport. +func (e *EvidencesServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "EvidencesClient.CreateOrUpdate": + resp, err = e.dispatchCreateOrUpdate(req) + case "EvidencesClient.Delete": + resp, err = e.dispatchDelete(req) + case "EvidencesClient.Download": + resp, err = e.dispatchDownload(req) + case "EvidencesClient.Get": + resp, err = e.dispatchGet(req) + case "EvidencesClient.NewListByReportPager": + resp, err = e.dispatchNewListByReportPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (e *EvidencesServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if e.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/providers/Microsoft\.AppComplianceAutomation/reports/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/evidences/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + body, err := server.UnmarshalRequestAsJSON[armappcomplianceautomation.EvidenceResource](req) + if err != nil { + return nil, err + } + offerGUIDUnescaped, err := url.QueryUnescape(qp.Get("offerGuid")) + if err != nil { + return nil, err + } + offerGUIDParam := getOptional(offerGUIDUnescaped) + reportCreatorTenantIDUnescaped, err := url.QueryUnescape(qp.Get("reportCreatorTenantId")) + if err != nil { + return nil, err + } + reportCreatorTenantIDParam := getOptional(reportCreatorTenantIDUnescaped) + reportNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("reportName")]) + if err != nil { + return nil, err + } + evidenceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("evidenceName")]) + if err != nil { + return nil, err + } + var options *armappcomplianceautomation.EvidencesClientCreateOrUpdateOptions + if offerGUIDParam != nil || reportCreatorTenantIDParam != nil { + options = &armappcomplianceautomation.EvidencesClientCreateOrUpdateOptions{ + OfferGUID: offerGUIDParam, + ReportCreatorTenantID: reportCreatorTenantIDParam, + } + } + respr, errRespr := e.srv.CreateOrUpdate(req.Context(), reportNameParam, evidenceNameParam, body, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).EvidenceResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (e *EvidencesServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if e.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/providers/Microsoft\.AppComplianceAutomation/reports/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/evidences/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + reportNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("reportName")]) + if err != nil { + return nil, err + } + evidenceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("evidenceName")]) + if err != nil { + return nil, err + } + respr, errRespr := e.srv.Delete(req.Context(), reportNameParam, evidenceNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (e *EvidencesServerTransport) dispatchDownload(req *http.Request) (*http.Response, error) { + if e.srv.Download == nil { + return nil, &nonRetriableError{errors.New("fake for method Download not implemented")} + } + const regexStr = `/providers/Microsoft\.AppComplianceAutomation/reports/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/evidences/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/download` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armappcomplianceautomation.EvidenceFileDownloadRequest](req) + if err != nil { + return nil, err + } + reportNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("reportName")]) + if err != nil { + return nil, err + } + evidenceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("evidenceName")]) + if err != nil { + return nil, err + } + respr, errRespr := e.srv.Download(req.Context(), reportNameParam, evidenceNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).EvidenceFileDownloadResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (e *EvidencesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if e.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/providers/Microsoft\.AppComplianceAutomation/reports/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/evidences/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + reportNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("reportName")]) + if err != nil { + return nil, err + } + evidenceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("evidenceName")]) + if err != nil { + return nil, err + } + respr, errRespr := e.srv.Get(req.Context(), reportNameParam, evidenceNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).EvidenceResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (e *EvidencesServerTransport) dispatchNewListByReportPager(req *http.Request) (*http.Response, error) { + if e.srv.NewListByReportPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByReportPager not implemented")} + } + newListByReportPager := e.newListByReportPager.get(req) + if newListByReportPager == nil { + const regexStr = `/providers/Microsoft\.AppComplianceAutomation/reports/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/evidences` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + skipTokenUnescaped, err := url.QueryUnescape(qp.Get("$skipToken")) + if err != nil { + return nil, err + } + skipTokenParam := getOptional(skipTokenUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + selectUnescaped, err := url.QueryUnescape(qp.Get("$select")) + if err != nil { + return nil, err + } + selectParam := getOptional(selectUnescaped) + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + orderbyUnescaped, err := url.QueryUnescape(qp.Get("$orderby")) + if err != nil { + return nil, err + } + orderbyParam := getOptional(orderbyUnescaped) + offerGUIDUnescaped, err := url.QueryUnescape(qp.Get("offerGuid")) + if err != nil { + return nil, err + } + offerGUIDParam := getOptional(offerGUIDUnescaped) + reportCreatorTenantIDUnescaped, err := url.QueryUnescape(qp.Get("reportCreatorTenantId")) + if err != nil { + return nil, err + } + reportCreatorTenantIDParam := getOptional(reportCreatorTenantIDUnescaped) + reportNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("reportName")]) + if err != nil { + return nil, err + } + var options *armappcomplianceautomation.EvidencesClientListByReportOptions + if skipTokenParam != nil || topParam != nil || selectParam != nil || filterParam != nil || orderbyParam != nil || offerGUIDParam != nil || reportCreatorTenantIDParam != nil { + options = &armappcomplianceautomation.EvidencesClientListByReportOptions{ + SkipToken: skipTokenParam, + Top: topParam, + Select: selectParam, + Filter: filterParam, + Orderby: orderbyParam, + OfferGUID: offerGUIDParam, + ReportCreatorTenantID: reportCreatorTenantIDParam, + } + } + resp := e.srv.NewListByReportPager(reportNameParam, options) + newListByReportPager = &resp + e.newListByReportPager.add(req, newListByReportPager) + server.PagerResponderInjectNextLinks(newListByReportPager, req, func(page *armappcomplianceautomation.EvidencesClientListByReportResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByReportPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + e.newListByReportPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByReportPager) { + e.newListByReportPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/fake/provideractions_server.go b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/fake/provideractions_server.go new file mode 100644 index 000000000000..93b2fa1b145e --- /dev/null +++ b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/fake/provideractions_server.go @@ -0,0 +1,261 @@ +//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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation" + "net/http" +) + +// ProviderActionsServer is a fake server for instances of the armappcomplianceautomation.ProviderActionsClient type. +type ProviderActionsServer struct { + // CheckNameAvailability is the fake for method ProviderActionsClient.CheckNameAvailability + // HTTP status codes to indicate success: http.StatusOK + CheckNameAvailability func(ctx context.Context, body armappcomplianceautomation.CheckNameAvailabilityRequest, options *armappcomplianceautomation.ProviderActionsClientCheckNameAvailabilityOptions) (resp azfake.Responder[armappcomplianceautomation.ProviderActionsClientCheckNameAvailabilityResponse], errResp azfake.ErrorResponder) + + // GetCollectionCount is the fake for method ProviderActionsClient.GetCollectionCount + // HTTP status codes to indicate success: http.StatusOK + GetCollectionCount func(ctx context.Context, body armappcomplianceautomation.GetCollectionCountRequest, options *armappcomplianceautomation.ProviderActionsClientGetCollectionCountOptions) (resp azfake.Responder[armappcomplianceautomation.ProviderActionsClientGetCollectionCountResponse], errResp azfake.ErrorResponder) + + // GetOverviewStatus is the fake for method ProviderActionsClient.GetOverviewStatus + // HTTP status codes to indicate success: http.StatusOK + GetOverviewStatus func(ctx context.Context, body armappcomplianceautomation.GetOverviewStatusRequest, options *armappcomplianceautomation.ProviderActionsClientGetOverviewStatusOptions) (resp azfake.Responder[armappcomplianceautomation.ProviderActionsClientGetOverviewStatusResponse], errResp azfake.ErrorResponder) + + // ListInUseStorageAccounts is the fake for method ProviderActionsClient.ListInUseStorageAccounts + // HTTP status codes to indicate success: http.StatusOK + ListInUseStorageAccounts func(ctx context.Context, body armappcomplianceautomation.ListInUseStorageAccountsRequest, options *armappcomplianceautomation.ProviderActionsClientListInUseStorageAccountsOptions) (resp azfake.Responder[armappcomplianceautomation.ProviderActionsClientListInUseStorageAccountsResponse], errResp azfake.ErrorResponder) + + // BeginOnboard is the fake for method ProviderActionsClient.BeginOnboard + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginOnboard func(ctx context.Context, body armappcomplianceautomation.OnboardRequest, options *armappcomplianceautomation.ProviderActionsClientBeginOnboardOptions) (resp azfake.PollerResponder[armappcomplianceautomation.ProviderActionsClientOnboardResponse], errResp azfake.ErrorResponder) + + // BeginTriggerEvaluation is the fake for method ProviderActionsClient.BeginTriggerEvaluation + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginTriggerEvaluation func(ctx context.Context, body armappcomplianceautomation.TriggerEvaluationRequest, options *armappcomplianceautomation.ProviderActionsClientBeginTriggerEvaluationOptions) (resp azfake.PollerResponder[armappcomplianceautomation.ProviderActionsClientTriggerEvaluationResponse], errResp azfake.ErrorResponder) +} + +// NewProviderActionsServerTransport creates a new instance of ProviderActionsServerTransport with the provided implementation. +// The returned ProviderActionsServerTransport instance is connected to an instance of armappcomplianceautomation.ProviderActionsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewProviderActionsServerTransport(srv *ProviderActionsServer) *ProviderActionsServerTransport { + return &ProviderActionsServerTransport{ + srv: srv, + beginOnboard: newTracker[azfake.PollerResponder[armappcomplianceautomation.ProviderActionsClientOnboardResponse]](), + beginTriggerEvaluation: newTracker[azfake.PollerResponder[armappcomplianceautomation.ProviderActionsClientTriggerEvaluationResponse]](), + } +} + +// ProviderActionsServerTransport connects instances of armappcomplianceautomation.ProviderActionsClient to instances of ProviderActionsServer. +// Don't use this type directly, use NewProviderActionsServerTransport instead. +type ProviderActionsServerTransport struct { + srv *ProviderActionsServer + beginOnboard *tracker[azfake.PollerResponder[armappcomplianceautomation.ProviderActionsClientOnboardResponse]] + beginTriggerEvaluation *tracker[azfake.PollerResponder[armappcomplianceautomation.ProviderActionsClientTriggerEvaluationResponse]] +} + +// Do implements the policy.Transporter interface for ProviderActionsServerTransport. +func (p *ProviderActionsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "ProviderActionsClient.CheckNameAvailability": + resp, err = p.dispatchCheckNameAvailability(req) + case "ProviderActionsClient.GetCollectionCount": + resp, err = p.dispatchGetCollectionCount(req) + case "ProviderActionsClient.GetOverviewStatus": + resp, err = p.dispatchGetOverviewStatus(req) + case "ProviderActionsClient.ListInUseStorageAccounts": + resp, err = p.dispatchListInUseStorageAccounts(req) + case "ProviderActionsClient.BeginOnboard": + resp, err = p.dispatchBeginOnboard(req) + case "ProviderActionsClient.BeginTriggerEvaluation": + resp, err = p.dispatchBeginTriggerEvaluation(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (p *ProviderActionsServerTransport) dispatchCheckNameAvailability(req *http.Request) (*http.Response, error) { + if p.srv.CheckNameAvailability == nil { + return nil, &nonRetriableError{errors.New("fake for method CheckNameAvailability not implemented")} + } + body, err := server.UnmarshalRequestAsJSON[armappcomplianceautomation.CheckNameAvailabilityRequest](req) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.CheckNameAvailability(req.Context(), body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).CheckNameAvailabilityResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (p *ProviderActionsServerTransport) dispatchGetCollectionCount(req *http.Request) (*http.Response, error) { + if p.srv.GetCollectionCount == nil { + return nil, &nonRetriableError{errors.New("fake for method GetCollectionCount not implemented")} + } + body, err := server.UnmarshalRequestAsJSON[armappcomplianceautomation.GetCollectionCountRequest](req) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.GetCollectionCount(req.Context(), body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).GetCollectionCountResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (p *ProviderActionsServerTransport) dispatchGetOverviewStatus(req *http.Request) (*http.Response, error) { + if p.srv.GetOverviewStatus == nil { + return nil, &nonRetriableError{errors.New("fake for method GetOverviewStatus not implemented")} + } + body, err := server.UnmarshalRequestAsJSON[armappcomplianceautomation.GetOverviewStatusRequest](req) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.GetOverviewStatus(req.Context(), body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).GetOverviewStatusResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (p *ProviderActionsServerTransport) dispatchListInUseStorageAccounts(req *http.Request) (*http.Response, error) { + if p.srv.ListInUseStorageAccounts == nil { + return nil, &nonRetriableError{errors.New("fake for method ListInUseStorageAccounts not implemented")} + } + body, err := server.UnmarshalRequestAsJSON[armappcomplianceautomation.ListInUseStorageAccountsRequest](req) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.ListInUseStorageAccounts(req.Context(), body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ListInUseStorageAccountsResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (p *ProviderActionsServerTransport) dispatchBeginOnboard(req *http.Request) (*http.Response, error) { + if p.srv.BeginOnboard == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginOnboard not implemented")} + } + beginOnboard := p.beginOnboard.get(req) + if beginOnboard == nil { + body, err := server.UnmarshalRequestAsJSON[armappcomplianceautomation.OnboardRequest](req) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.BeginOnboard(req.Context(), body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginOnboard = &respr + p.beginOnboard.add(req, beginOnboard) + } + + resp, err := server.PollerResponderNext(beginOnboard, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + p.beginOnboard.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginOnboard) { + p.beginOnboard.remove(req) + } + + return resp, nil +} + +func (p *ProviderActionsServerTransport) dispatchBeginTriggerEvaluation(req *http.Request) (*http.Response, error) { + if p.srv.BeginTriggerEvaluation == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginTriggerEvaluation not implemented")} + } + beginTriggerEvaluation := p.beginTriggerEvaluation.get(req) + if beginTriggerEvaluation == nil { + body, err := server.UnmarshalRequestAsJSON[armappcomplianceautomation.TriggerEvaluationRequest](req) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.BeginTriggerEvaluation(req.Context(), body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginTriggerEvaluation = &respr + p.beginTriggerEvaluation.add(req, beginTriggerEvaluation) + } + + resp, err := server.PollerResponderNext(beginTriggerEvaluation, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + p.beginTriggerEvaluation.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginTriggerEvaluation) { + p.beginTriggerEvaluation.remove(req) + } + + return resp, nil +} diff --git a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/fake/report_server.go b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/fake/report_server.go index cb7f91b70fbf..7e0cc5addeb9 100644 --- a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/fake/report_server.go +++ b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/fake/report_server.go @@ -23,21 +23,9 @@ import ( // ReportServer is a fake server for instances of the armappcomplianceautomation.ReportClient type. type ReportServer struct { - // BeginCreateOrUpdate is the fake for method ReportClient.BeginCreateOrUpdate - // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated - BeginCreateOrUpdate func(ctx context.Context, reportName string, parameters armappcomplianceautomation.ReportResource, options *armappcomplianceautomation.ReportClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armappcomplianceautomation.ReportClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) - - // BeginDelete is the fake for method ReportClient.BeginDelete - // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent - BeginDelete func(ctx context.Context, reportName string, options *armappcomplianceautomation.ReportClientBeginDeleteOptions) (resp azfake.PollerResponder[armappcomplianceautomation.ReportClientDeleteResponse], errResp azfake.ErrorResponder) - - // Get is the fake for method ReportClient.Get - // HTTP status codes to indicate success: http.StatusOK - Get func(ctx context.Context, reportName string, options *armappcomplianceautomation.ReportClientGetOptions) (resp azfake.Responder[armappcomplianceautomation.ReportClientGetResponse], errResp azfake.ErrorResponder) - - // BeginUpdate is the fake for method ReportClient.BeginUpdate - // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated, http.StatusAccepted - BeginUpdate func(ctx context.Context, reportName string, parameters armappcomplianceautomation.ReportResourcePatch, options *armappcomplianceautomation.ReportClientBeginUpdateOptions) (resp azfake.PollerResponder[armappcomplianceautomation.ReportClientUpdateResponse], errResp azfake.ErrorResponder) + // BeginVerify is the fake for method ReportClient.BeginVerify + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginVerify func(ctx context.Context, reportName string, options *armappcomplianceautomation.ReportClientBeginVerifyOptions) (resp azfake.PollerResponder[armappcomplianceautomation.ReportClientVerifyResponse], errResp azfake.ErrorResponder) } // NewReportServerTransport creates a new instance of ReportServerTransport with the provided implementation. @@ -45,20 +33,16 @@ type ReportServer struct { // azcore.ClientOptions.Transporter field in the client's constructor parameters. func NewReportServerTransport(srv *ReportServer) *ReportServerTransport { return &ReportServerTransport{ - srv: srv, - beginCreateOrUpdate: newTracker[azfake.PollerResponder[armappcomplianceautomation.ReportClientCreateOrUpdateResponse]](), - beginDelete: newTracker[azfake.PollerResponder[armappcomplianceautomation.ReportClientDeleteResponse]](), - beginUpdate: newTracker[azfake.PollerResponder[armappcomplianceautomation.ReportClientUpdateResponse]](), + srv: srv, + beginVerify: newTracker[azfake.PollerResponder[armappcomplianceautomation.ReportClientVerifyResponse]](), } } // ReportServerTransport connects instances of armappcomplianceautomation.ReportClient to instances of ReportServer. // Don't use this type directly, use NewReportServerTransport instead. type ReportServerTransport struct { - srv *ReportServer - beginCreateOrUpdate *tracker[azfake.PollerResponder[armappcomplianceautomation.ReportClientCreateOrUpdateResponse]] - beginDelete *tracker[azfake.PollerResponder[armappcomplianceautomation.ReportClientDeleteResponse]] - beginUpdate *tracker[azfake.PollerResponder[armappcomplianceautomation.ReportClientUpdateResponse]] + srv *ReportServer + beginVerify *tracker[azfake.PollerResponder[armappcomplianceautomation.ReportClientVerifyResponse]] } // Do implements the policy.Transporter interface for ReportServerTransport. @@ -73,14 +57,8 @@ func (r *ReportServerTransport) Do(req *http.Request) (*http.Response, error) { var err error switch method { - case "ReportClient.BeginCreateOrUpdate": - resp, err = r.dispatchBeginCreateOrUpdate(req) - case "ReportClient.BeginDelete": - resp, err = r.dispatchBeginDelete(req) - case "ReportClient.Get": - resp, err = r.dispatchGet(req) - case "ReportClient.BeginUpdate": - resp, err = r.dispatchBeginUpdate(req) + case "ReportClient.BeginVerify": + resp, err = r.dispatchBeginVerify(req) default: err = fmt.Errorf("unhandled API %s", method) } @@ -92,158 +70,41 @@ func (r *ReportServerTransport) Do(req *http.Request) (*http.Response, error) { return resp, nil } -func (r *ReportServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { - if r.srv.BeginCreateOrUpdate == nil { - return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} - } - beginCreateOrUpdate := r.beginCreateOrUpdate.get(req) - if beginCreateOrUpdate == nil { - const regexStr = `/providers/Microsoft\.AppComplianceAutomation/reports/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - body, err := server.UnmarshalRequestAsJSON[armappcomplianceautomation.ReportResource](req) - if err != nil { - return nil, err - } - reportNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("reportName")]) - if err != nil { - return nil, err - } - respr, errRespr := r.srv.BeginCreateOrUpdate(req.Context(), reportNameParam, body, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - beginCreateOrUpdate = &respr - r.beginCreateOrUpdate.add(req, beginCreateOrUpdate) - } - - resp, err := server.PollerResponderNext(beginCreateOrUpdate, req) - if err != nil { - return nil, err - } - - if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { - r.beginCreateOrUpdate.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} - } - if !server.PollerResponderMore(beginCreateOrUpdate) { - r.beginCreateOrUpdate.remove(req) - } - - return resp, nil -} - -func (r *ReportServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { - if r.srv.BeginDelete == nil { - return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} - } - beginDelete := r.beginDelete.get(req) - if beginDelete == nil { - const regexStr = `/providers/Microsoft\.AppComplianceAutomation/reports/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - reportNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("reportName")]) - if err != nil { - return nil, err - } - respr, errRespr := r.srv.BeginDelete(req.Context(), reportNameParam, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - beginDelete = &respr - r.beginDelete.add(req, beginDelete) - } - - resp, err := server.PollerResponderNext(beginDelete, req) - if err != nil { - return nil, err - } - - if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { - r.beginDelete.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} - } - if !server.PollerResponderMore(beginDelete) { - r.beginDelete.remove(req) - } - - return resp, nil -} - -func (r *ReportServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { - if r.srv.Get == nil { - return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} - } - const regexStr = `/providers/Microsoft\.AppComplianceAutomation/reports/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - reportNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("reportName")]) - if err != nil { - return nil, err - } - respr, errRespr := r.srv.Get(req.Context(), reportNameParam, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} - } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ReportResource, req) - if err != nil { - return nil, err - } - return resp, nil -} - -func (r *ReportServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { - if r.srv.BeginUpdate == nil { - return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} +func (r *ReportServerTransport) dispatchBeginVerify(req *http.Request) (*http.Response, error) { + if r.srv.BeginVerify == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginVerify not implemented")} } - beginUpdate := r.beginUpdate.get(req) - if beginUpdate == nil { - const regexStr = `/providers/Microsoft\.AppComplianceAutomation/reports/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + beginVerify := r.beginVerify.get(req) + if beginVerify == nil { + const regexStr = `/providers/Microsoft\.AppComplianceAutomation/reports/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/verify` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 1 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - body, err := server.UnmarshalRequestAsJSON[armappcomplianceautomation.ReportResourcePatch](req) - if err != nil { - return nil, err - } reportNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("reportName")]) if err != nil { return nil, err } - respr, errRespr := r.srv.BeginUpdate(req.Context(), reportNameParam, body, nil) + respr, errRespr := r.srv.BeginVerify(req.Context(), reportNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } - beginUpdate = &respr - r.beginUpdate.add(req, beginUpdate) + beginVerify = &respr + r.beginVerify.add(req, beginVerify) } - resp, err := server.PollerResponderNext(beginUpdate, req) + resp, err := server.PollerResponderNext(beginVerify, req) if err != nil { return nil, err } - if !contains([]int{http.StatusOK, http.StatusCreated, http.StatusAccepted}, resp.StatusCode) { - r.beginUpdate.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated, http.StatusAccepted", resp.StatusCode)} + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + r.beginVerify.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} } - if !server.PollerResponderMore(beginUpdate) { - r.beginUpdate.remove(req) + if !server.PollerResponderMore(beginVerify) { + r.beginVerify.remove(req) } return resp, nil diff --git a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/fake/reports_server.go b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/fake/reports_server.go index 6c143635c7ce..ffccbd615d97 100644 --- a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/fake/reports_server.go +++ b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/fake/reports_server.go @@ -9,6 +9,7 @@ package fake import ( + "context" "errors" "fmt" azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" @@ -18,14 +19,43 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation" "net/http" "net/url" + "regexp" "strconv" ) // ReportsServer is a fake server for instances of the armappcomplianceautomation.ReportsClient type. type ReportsServer struct { + // BeginCreateOrUpdate is the fake for method ReportsClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreateOrUpdate func(ctx context.Context, reportName string, parameters armappcomplianceautomation.ReportResource, options *armappcomplianceautomation.ReportsClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armappcomplianceautomation.ReportsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method ReportsClient.BeginDelete + // HTTP status codes to indicate success: http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, reportName string, options *armappcomplianceautomation.ReportsClientBeginDeleteOptions) (resp azfake.PollerResponder[armappcomplianceautomation.ReportsClientDeleteResponse], errResp azfake.ErrorResponder) + + // BeginFix is the fake for method ReportsClient.BeginFix + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginFix func(ctx context.Context, reportName string, options *armappcomplianceautomation.ReportsClientBeginFixOptions) (resp azfake.PollerResponder[armappcomplianceautomation.ReportsClientFixResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method ReportsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, reportName string, options *armappcomplianceautomation.ReportsClientGetOptions) (resp azfake.Responder[armappcomplianceautomation.ReportsClientGetResponse], errResp azfake.ErrorResponder) + // NewListPager is the fake for method ReportsClient.NewListPager // HTTP status codes to indicate success: http.StatusOK NewListPager func(options *armappcomplianceautomation.ReportsClientListOptions) (resp azfake.PagerResponder[armappcomplianceautomation.ReportsClientListResponse]) + + // NestedResourceCheckNameAvailability is the fake for method ReportsClient.NestedResourceCheckNameAvailability + // HTTP status codes to indicate success: http.StatusOK + NestedResourceCheckNameAvailability func(ctx context.Context, reportName string, body armappcomplianceautomation.CheckNameAvailabilityRequest, options *armappcomplianceautomation.ReportsClientNestedResourceCheckNameAvailabilityOptions) (resp azfake.Responder[armappcomplianceautomation.ReportsClientNestedResourceCheckNameAvailabilityResponse], errResp azfake.ErrorResponder) + + // BeginSyncCertRecord is the fake for method ReportsClient.BeginSyncCertRecord + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginSyncCertRecord func(ctx context.Context, reportName string, body armappcomplianceautomation.SyncCertRecordRequest, options *armappcomplianceautomation.ReportsClientBeginSyncCertRecordOptions) (resp azfake.PollerResponder[armappcomplianceautomation.ReportsClientSyncCertRecordResponse], errResp azfake.ErrorResponder) + + // BeginUpdate is the fake for method ReportsClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdate func(ctx context.Context, reportName string, properties armappcomplianceautomation.ReportResourcePatch, options *armappcomplianceautomation.ReportsClientBeginUpdateOptions) (resp azfake.PollerResponder[armappcomplianceautomation.ReportsClientUpdateResponse], errResp azfake.ErrorResponder) } // NewReportsServerTransport creates a new instance of ReportsServerTransport with the provided implementation. @@ -33,16 +63,26 @@ type ReportsServer struct { // azcore.ClientOptions.Transporter field in the client's constructor parameters. func NewReportsServerTransport(srv *ReportsServer) *ReportsServerTransport { return &ReportsServerTransport{ - srv: srv, - newListPager: newTracker[azfake.PagerResponder[armappcomplianceautomation.ReportsClientListResponse]](), + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armappcomplianceautomation.ReportsClientCreateOrUpdateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armappcomplianceautomation.ReportsClientDeleteResponse]](), + beginFix: newTracker[azfake.PollerResponder[armappcomplianceautomation.ReportsClientFixResponse]](), + newListPager: newTracker[azfake.PagerResponder[armappcomplianceautomation.ReportsClientListResponse]](), + beginSyncCertRecord: newTracker[azfake.PollerResponder[armappcomplianceautomation.ReportsClientSyncCertRecordResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armappcomplianceautomation.ReportsClientUpdateResponse]](), } } // ReportsServerTransport connects instances of armappcomplianceautomation.ReportsClient to instances of ReportsServer. // Don't use this type directly, use NewReportsServerTransport instead. type ReportsServerTransport struct { - srv *ReportsServer - newListPager *tracker[azfake.PagerResponder[armappcomplianceautomation.ReportsClientListResponse]] + srv *ReportsServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armappcomplianceautomation.ReportsClientCreateOrUpdateResponse]] + beginDelete *tracker[azfake.PollerResponder[armappcomplianceautomation.ReportsClientDeleteResponse]] + beginFix *tracker[azfake.PollerResponder[armappcomplianceautomation.ReportsClientFixResponse]] + newListPager *tracker[azfake.PagerResponder[armappcomplianceautomation.ReportsClientListResponse]] + beginSyncCertRecord *tracker[azfake.PollerResponder[armappcomplianceautomation.ReportsClientSyncCertRecordResponse]] + beginUpdate *tracker[azfake.PollerResponder[armappcomplianceautomation.ReportsClientUpdateResponse]] } // Do implements the policy.Transporter interface for ReportsServerTransport. @@ -57,8 +97,22 @@ func (r *ReportsServerTransport) Do(req *http.Request) (*http.Response, error) { var err error switch method { + case "ReportsClient.BeginCreateOrUpdate": + resp, err = r.dispatchBeginCreateOrUpdate(req) + case "ReportsClient.BeginDelete": + resp, err = r.dispatchBeginDelete(req) + case "ReportsClient.BeginFix": + resp, err = r.dispatchBeginFix(req) + case "ReportsClient.Get": + resp, err = r.dispatchGet(req) case "ReportsClient.NewListPager": resp, err = r.dispatchNewListPager(req) + case "ReportsClient.NestedResourceCheckNameAvailability": + resp, err = r.dispatchNestedResourceCheckNameAvailability(req) + case "ReportsClient.BeginSyncCertRecord": + resp, err = r.dispatchBeginSyncCertRecord(req) + case "ReportsClient.BeginUpdate": + resp, err = r.dispatchBeginUpdate(req) default: err = fmt.Errorf("unhandled API %s", method) } @@ -70,6 +124,159 @@ func (r *ReportsServerTransport) Do(req *http.Request) (*http.Response, error) { return resp, nil } +func (r *ReportsServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if r.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := r.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/providers/Microsoft\.AppComplianceAutomation/reports/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armappcomplianceautomation.ReportResource](req) + if err != nil { + return nil, err + } + reportNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("reportName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.BeginCreateOrUpdate(req.Context(), reportNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + r.beginCreateOrUpdate.add(req, beginCreateOrUpdate) + } + + resp, err := server.PollerResponderNext(beginCreateOrUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + r.beginCreateOrUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdate) { + r.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (r *ReportsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if r.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := r.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/providers/Microsoft\.AppComplianceAutomation/reports/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + reportNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("reportName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.BeginDelete(req.Context(), reportNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + r.beginDelete.add(req, beginDelete) + } + + resp, err := server.PollerResponderNext(beginDelete, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + r.beginDelete.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDelete) { + r.beginDelete.remove(req) + } + + return resp, nil +} + +func (r *ReportsServerTransport) dispatchBeginFix(req *http.Request) (*http.Response, error) { + if r.srv.BeginFix == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginFix not implemented")} + } + beginFix := r.beginFix.get(req) + if beginFix == nil { + const regexStr = `/providers/Microsoft\.AppComplianceAutomation/reports/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/fix` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + reportNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("reportName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.BeginFix(req.Context(), reportNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginFix = &respr + r.beginFix.add(req, beginFix) + } + + resp, err := server.PollerResponderNext(beginFix, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + r.beginFix.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginFix) { + r.beginFix.remove(req) + } + + return resp, nil +} + +func (r *ReportsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if r.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/providers/Microsoft\.AppComplianceAutomation/reports/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + reportNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("reportName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.Get(req.Context(), reportNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ReportResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + func (r *ReportsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { if r.srv.NewListPager == nil { return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} @@ -101,6 +308,16 @@ func (r *ReportsServerTransport) dispatchNewListPager(req *http.Request) (*http. return nil, err } selectParam := getOptional(selectUnescaped) + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + orderbyUnescaped, err := url.QueryUnescape(qp.Get("$orderby")) + if err != nil { + return nil, err + } + orderbyParam := getOptional(orderbyUnescaped) offerGUIDUnescaped, err := url.QueryUnescape(qp.Get("offerGuid")) if err != nil { return nil, err @@ -112,11 +329,13 @@ func (r *ReportsServerTransport) dispatchNewListPager(req *http.Request) (*http. } reportCreatorTenantIDParam := getOptional(reportCreatorTenantIDUnescaped) var options *armappcomplianceautomation.ReportsClientListOptions - if skipTokenParam != nil || topParam != nil || selectParam != nil || offerGUIDParam != nil || reportCreatorTenantIDParam != nil { + if skipTokenParam != nil || topParam != nil || selectParam != nil || filterParam != nil || orderbyParam != nil || offerGUIDParam != nil || reportCreatorTenantIDParam != nil { options = &armappcomplianceautomation.ReportsClientListOptions{ SkipToken: skipTokenParam, Top: topParam, Select: selectParam, + Filter: filterParam, + Orderby: orderbyParam, OfferGUID: offerGUIDParam, ReportCreatorTenantID: reportCreatorTenantIDParam, } @@ -141,3 +360,124 @@ func (r *ReportsServerTransport) dispatchNewListPager(req *http.Request) (*http. } return resp, nil } + +func (r *ReportsServerTransport) dispatchNestedResourceCheckNameAvailability(req *http.Request) (*http.Response, error) { + if r.srv.NestedResourceCheckNameAvailability == nil { + return nil, &nonRetriableError{errors.New("fake for method NestedResourceCheckNameAvailability not implemented")} + } + const regexStr = `/providers/Microsoft\.AppComplianceAutomation/reports/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/checkNameAvailability` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armappcomplianceautomation.CheckNameAvailabilityRequest](req) + if err != nil { + return nil, err + } + reportNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("reportName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.NestedResourceCheckNameAvailability(req.Context(), reportNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).CheckNameAvailabilityResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *ReportsServerTransport) dispatchBeginSyncCertRecord(req *http.Request) (*http.Response, error) { + if r.srv.BeginSyncCertRecord == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginSyncCertRecord not implemented")} + } + beginSyncCertRecord := r.beginSyncCertRecord.get(req) + if beginSyncCertRecord == nil { + const regexStr = `/providers/Microsoft\.AppComplianceAutomation/reports/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/syncCertRecord` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armappcomplianceautomation.SyncCertRecordRequest](req) + if err != nil { + return nil, err + } + reportNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("reportName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.BeginSyncCertRecord(req.Context(), reportNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginSyncCertRecord = &respr + r.beginSyncCertRecord.add(req, beginSyncCertRecord) + } + + resp, err := server.PollerResponderNext(beginSyncCertRecord, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + r.beginSyncCertRecord.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginSyncCertRecord) { + r.beginSyncCertRecord.remove(req) + } + + return resp, nil +} + +func (r *ReportsServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if r.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} + } + beginUpdate := r.beginUpdate.get(req) + if beginUpdate == nil { + const regexStr = `/providers/Microsoft\.AppComplianceAutomation/reports/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armappcomplianceautomation.ReportResourcePatch](req) + if err != nil { + return nil, err + } + reportNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("reportName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.BeginUpdate(req.Context(), reportNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdate = &respr + r.beginUpdate.add(req, beginUpdate) + } + + resp, err := server.PollerResponderNext(beginUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + r.beginUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginUpdate) { + r.beginUpdate.remove(req) + } + + return resp, nil +} diff --git a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/fake/scopingconfiguration_server.go b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/fake/scopingconfiguration_server.go new file mode 100644 index 000000000000..f540ec09d7a2 --- /dev/null +++ b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/fake/scopingconfiguration_server.go @@ -0,0 +1,182 @@ +//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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation" + "net/http" + "net/url" + "regexp" +) + +// ScopingConfigurationServer is a fake server for instances of the armappcomplianceautomation.ScopingConfigurationClient type. +type ScopingConfigurationServer struct { + // CreateOrUpdate is the fake for method ScopingConfigurationClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, reportName string, scopingConfigurationName string, parameters armappcomplianceautomation.ScopingConfigurationResource, options *armappcomplianceautomation.ScopingConfigurationClientCreateOrUpdateOptions) (resp azfake.Responder[armappcomplianceautomation.ScopingConfigurationClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method ScopingConfigurationClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, reportName string, scopingConfigurationName string, options *armappcomplianceautomation.ScopingConfigurationClientDeleteOptions) (resp azfake.Responder[armappcomplianceautomation.ScopingConfigurationClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method ScopingConfigurationClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, reportName string, scopingConfigurationName string, options *armappcomplianceautomation.ScopingConfigurationClientGetOptions) (resp azfake.Responder[armappcomplianceautomation.ScopingConfigurationClientGetResponse], errResp azfake.ErrorResponder) +} + +// NewScopingConfigurationServerTransport creates a new instance of ScopingConfigurationServerTransport with the provided implementation. +// The returned ScopingConfigurationServerTransport instance is connected to an instance of armappcomplianceautomation.ScopingConfigurationClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewScopingConfigurationServerTransport(srv *ScopingConfigurationServer) *ScopingConfigurationServerTransport { + return &ScopingConfigurationServerTransport{srv: srv} +} + +// ScopingConfigurationServerTransport connects instances of armappcomplianceautomation.ScopingConfigurationClient to instances of ScopingConfigurationServer. +// Don't use this type directly, use NewScopingConfigurationServerTransport instead. +type ScopingConfigurationServerTransport struct { + srv *ScopingConfigurationServer +} + +// Do implements the policy.Transporter interface for ScopingConfigurationServerTransport. +func (s *ScopingConfigurationServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "ScopingConfigurationClient.CreateOrUpdate": + resp, err = s.dispatchCreateOrUpdate(req) + case "ScopingConfigurationClient.Delete": + resp, err = s.dispatchDelete(req) + case "ScopingConfigurationClient.Get": + resp, err = s.dispatchGet(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (s *ScopingConfigurationServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if s.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/providers/Microsoft\.AppComplianceAutomation/reports/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/scopingConfigurations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armappcomplianceautomation.ScopingConfigurationResource](req) + if err != nil { + return nil, err + } + reportNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("reportName")]) + if err != nil { + return nil, err + } + scopingConfigurationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("scopingConfigurationName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.CreateOrUpdate(req.Context(), reportNameParam, scopingConfigurationNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ScopingConfigurationResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *ScopingConfigurationServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if s.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/providers/Microsoft\.AppComplianceAutomation/reports/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/scopingConfigurations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + reportNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("reportName")]) + if err != nil { + return nil, err + } + scopingConfigurationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("scopingConfigurationName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.Delete(req.Context(), reportNameParam, scopingConfigurationNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *ScopingConfigurationServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if s.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/providers/Microsoft\.AppComplianceAutomation/reports/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/scopingConfigurations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + reportNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("reportName")]) + if err != nil { + return nil, err + } + scopingConfigurationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("scopingConfigurationName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.Get(req.Context(), reportNameParam, scopingConfigurationNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ScopingConfigurationResource, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/fake/scopingconfigurations_server.go b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/fake/scopingconfigurations_server.go new file mode 100644 index 000000000000..211d91d04d3a --- /dev/null +++ b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/fake/scopingconfigurations_server.go @@ -0,0 +1,108 @@ +//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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation" + "net/http" + "net/url" + "regexp" +) + +// ScopingConfigurationsServer is a fake server for instances of the armappcomplianceautomation.ScopingConfigurationsClient type. +type ScopingConfigurationsServer struct { + // NewListPager is the fake for method ScopingConfigurationsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(reportName string, options *armappcomplianceautomation.ScopingConfigurationsClientListOptions) (resp azfake.PagerResponder[armappcomplianceautomation.ScopingConfigurationsClientListResponse]) +} + +// NewScopingConfigurationsServerTransport creates a new instance of ScopingConfigurationsServerTransport with the provided implementation. +// The returned ScopingConfigurationsServerTransport instance is connected to an instance of armappcomplianceautomation.ScopingConfigurationsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewScopingConfigurationsServerTransport(srv *ScopingConfigurationsServer) *ScopingConfigurationsServerTransport { + return &ScopingConfigurationsServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armappcomplianceautomation.ScopingConfigurationsClientListResponse]](), + } +} + +// ScopingConfigurationsServerTransport connects instances of armappcomplianceautomation.ScopingConfigurationsClient to instances of ScopingConfigurationsServer. +// Don't use this type directly, use NewScopingConfigurationsServerTransport instead. +type ScopingConfigurationsServerTransport struct { + srv *ScopingConfigurationsServer + newListPager *tracker[azfake.PagerResponder[armappcomplianceautomation.ScopingConfigurationsClientListResponse]] +} + +// Do implements the policy.Transporter interface for ScopingConfigurationsServerTransport. +func (s *ScopingConfigurationsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "ScopingConfigurationsClient.NewListPager": + resp, err = s.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (s *ScopingConfigurationsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if s.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := s.newListPager.get(req) + if newListPager == nil { + const regexStr = `/providers/Microsoft\.AppComplianceAutomation/reports/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/scopingConfigurations` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + reportNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("reportName")]) + if err != nil { + return nil, err + } + resp := s.srv.NewListPager(reportNameParam, nil) + newListPager = &resp + s.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armappcomplianceautomation.ScopingConfigurationsClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + s.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + s.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/fake/server_factory.go b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/fake/server_factory.go index 5a6b9582f52c..2baa77c6cc58 100644 --- a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/fake/server_factory.go +++ b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/fake/server_factory.go @@ -19,11 +19,16 @@ import ( // ServerFactory is a fake server for instances of the armappcomplianceautomation.ClientFactory type. type ServerFactory struct { - OperationsServer OperationsServer - ReportServer ReportServer - ReportsServer ReportsServer - SnapshotServer SnapshotServer - SnapshotsServer SnapshotsServer + EvidencesServer EvidencesServer + OperationsServer OperationsServer + ProviderActionsServer ProviderActionsServer + ReportServer ReportServer + ReportsServer ReportsServer + ScopingConfigurationServer ScopingConfigurationServer + ScopingConfigurationsServer ScopingConfigurationsServer + SnapshotsServer SnapshotsServer + ToolForMicrosoft365Server ToolForMicrosoft365Server + WebhooksServer WebhooksServer } // NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. @@ -38,13 +43,18 @@ func NewServerFactoryTransport(srv *ServerFactory) *ServerFactoryTransport { // ServerFactoryTransport connects instances of armappcomplianceautomation.ClientFactory to instances of ServerFactory. // Don't use this type directly, use NewServerFactoryTransport instead. type ServerFactoryTransport struct { - srv *ServerFactory - trMu sync.Mutex - trOperationsServer *OperationsServerTransport - trReportServer *ReportServerTransport - trReportsServer *ReportsServerTransport - trSnapshotServer *SnapshotServerTransport - trSnapshotsServer *SnapshotsServerTransport + srv *ServerFactory + trMu sync.Mutex + trEvidencesServer *EvidencesServerTransport + trOperationsServer *OperationsServerTransport + trProviderActionsServer *ProviderActionsServerTransport + trReportServer *ReportServerTransport + trReportsServer *ReportsServerTransport + trScopingConfigurationServer *ScopingConfigurationServerTransport + trScopingConfigurationsServer *ScopingConfigurationsServerTransport + trSnapshotsServer *SnapshotsServerTransport + trToolForMicrosoft365Server *ToolForMicrosoft365ServerTransport + trWebhooksServer *WebhooksServerTransport } // Do implements the policy.Transporter interface for ServerFactoryTransport. @@ -60,21 +70,44 @@ func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { var err error switch client { + case "EvidencesClient": + initServer(s, &s.trEvidencesServer, func() *EvidencesServerTransport { return NewEvidencesServerTransport(&s.srv.EvidencesServer) }) + resp, err = s.trEvidencesServer.Do(req) case "OperationsClient": initServer(s, &s.trOperationsServer, func() *OperationsServerTransport { return NewOperationsServerTransport(&s.srv.OperationsServer) }) resp, err = s.trOperationsServer.Do(req) + case "ProviderActionsClient": + initServer(s, &s.trProviderActionsServer, func() *ProviderActionsServerTransport { + return NewProviderActionsServerTransport(&s.srv.ProviderActionsServer) + }) + resp, err = s.trProviderActionsServer.Do(req) case "ReportClient": initServer(s, &s.trReportServer, func() *ReportServerTransport { return NewReportServerTransport(&s.srv.ReportServer) }) resp, err = s.trReportServer.Do(req) case "ReportsClient": initServer(s, &s.trReportsServer, func() *ReportsServerTransport { return NewReportsServerTransport(&s.srv.ReportsServer) }) resp, err = s.trReportsServer.Do(req) - case "SnapshotClient": - initServer(s, &s.trSnapshotServer, func() *SnapshotServerTransport { return NewSnapshotServerTransport(&s.srv.SnapshotServer) }) - resp, err = s.trSnapshotServer.Do(req) + case "ScopingConfigurationClient": + initServer(s, &s.trScopingConfigurationServer, func() *ScopingConfigurationServerTransport { + return NewScopingConfigurationServerTransport(&s.srv.ScopingConfigurationServer) + }) + resp, err = s.trScopingConfigurationServer.Do(req) + case "ScopingConfigurationsClient": + initServer(s, &s.trScopingConfigurationsServer, func() *ScopingConfigurationsServerTransport { + return NewScopingConfigurationsServerTransport(&s.srv.ScopingConfigurationsServer) + }) + resp, err = s.trScopingConfigurationsServer.Do(req) case "SnapshotsClient": initServer(s, &s.trSnapshotsServer, func() *SnapshotsServerTransport { return NewSnapshotsServerTransport(&s.srv.SnapshotsServer) }) resp, err = s.trSnapshotsServer.Do(req) + case "ToolForMicrosoft365Client": + initServer(s, &s.trToolForMicrosoft365Server, func() *ToolForMicrosoft365ServerTransport { + return NewToolForMicrosoft365ServerTransport(&s.srv.ToolForMicrosoft365Server) + }) + resp, err = s.trToolForMicrosoft365Server.Do(req) + case "WebhooksClient": + initServer(s, &s.trWebhooksServer, func() *WebhooksServerTransport { return NewWebhooksServerTransport(&s.srv.WebhooksServer) }) + resp, err = s.trWebhooksServer.Do(req) default: err = fmt.Errorf("unhandled client %s", client) } diff --git a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/fake/snapshot_server.go b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/fake/snapshot_server.go deleted file mode 100644 index 7c8f4e75da0f..000000000000 --- a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/fake/snapshot_server.go +++ /dev/null @@ -1,158 +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. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package fake - -import ( - "context" - "errors" - "fmt" - azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation" - "net/http" - "net/url" - "regexp" -) - -// SnapshotServer is a fake server for instances of the armappcomplianceautomation.SnapshotClient type. -type SnapshotServer struct { - // BeginDownload is the fake for method SnapshotClient.BeginDownload - // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted - BeginDownload func(ctx context.Context, reportName string, snapshotName string, parameters armappcomplianceautomation.SnapshotDownloadRequest, options *armappcomplianceautomation.SnapshotClientBeginDownloadOptions) (resp azfake.PollerResponder[armappcomplianceautomation.SnapshotClientDownloadResponse], errResp azfake.ErrorResponder) - - // Get is the fake for method SnapshotClient.Get - // HTTP status codes to indicate success: http.StatusOK - Get func(ctx context.Context, reportName string, snapshotName string, options *armappcomplianceautomation.SnapshotClientGetOptions) (resp azfake.Responder[armappcomplianceautomation.SnapshotClientGetResponse], errResp azfake.ErrorResponder) -} - -// NewSnapshotServerTransport creates a new instance of SnapshotServerTransport with the provided implementation. -// The returned SnapshotServerTransport instance is connected to an instance of armappcomplianceautomation.SnapshotClient via the -// azcore.ClientOptions.Transporter field in the client's constructor parameters. -func NewSnapshotServerTransport(srv *SnapshotServer) *SnapshotServerTransport { - return &SnapshotServerTransport{ - srv: srv, - beginDownload: newTracker[azfake.PollerResponder[armappcomplianceautomation.SnapshotClientDownloadResponse]](), - } -} - -// SnapshotServerTransport connects instances of armappcomplianceautomation.SnapshotClient to instances of SnapshotServer. -// Don't use this type directly, use NewSnapshotServerTransport instead. -type SnapshotServerTransport struct { - srv *SnapshotServer - beginDownload *tracker[azfake.PollerResponder[armappcomplianceautomation.SnapshotClientDownloadResponse]] -} - -// Do implements the policy.Transporter interface for SnapshotServerTransport. -func (s *SnapshotServerTransport) Do(req *http.Request) (*http.Response, error) { - rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) - method, ok := rawMethod.(string) - if !ok { - return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} - } - - var resp *http.Response - var err error - - switch method { - case "SnapshotClient.BeginDownload": - resp, err = s.dispatchBeginDownload(req) - case "SnapshotClient.Get": - resp, err = s.dispatchGet(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } - - if err != nil { - return nil, err - } - - return resp, nil -} - -func (s *SnapshotServerTransport) dispatchBeginDownload(req *http.Request) (*http.Response, error) { - if s.srv.BeginDownload == nil { - return nil, &nonRetriableError{errors.New("fake for method BeginDownload not implemented")} - } - beginDownload := s.beginDownload.get(req) - if beginDownload == nil { - const regexStr = `/providers/Microsoft\.AppComplianceAutomation/reports/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/snapshots/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/download` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - body, err := server.UnmarshalRequestAsJSON[armappcomplianceautomation.SnapshotDownloadRequest](req) - if err != nil { - return nil, err - } - reportNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("reportName")]) - if err != nil { - return nil, err - } - snapshotNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("snapshotName")]) - if err != nil { - return nil, err - } - respr, errRespr := s.srv.BeginDownload(req.Context(), reportNameParam, snapshotNameParam, body, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - beginDownload = &respr - s.beginDownload.add(req, beginDownload) - } - - resp, err := server.PollerResponderNext(beginDownload, req) - if err != nil { - return nil, err - } - - if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { - s.beginDownload.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} - } - if !server.PollerResponderMore(beginDownload) { - s.beginDownload.remove(req) - } - - return resp, nil -} - -func (s *SnapshotServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { - if s.srv.Get == nil { - return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} - } - const regexStr = `/providers/Microsoft\.AppComplianceAutomation/reports/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/snapshots/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - reportNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("reportName")]) - if err != nil { - return nil, err - } - snapshotNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("snapshotName")]) - if err != nil { - return nil, err - } - respr, errRespr := s.srv.Get(req.Context(), reportNameParam, snapshotNameParam, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} - } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).SnapshotResource, req) - if err != nil { - return nil, err - } - return resp, nil -} diff --git a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/fake/snapshots_server.go b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/fake/snapshots_server.go index e26176f3af96..a06a0b0df3d9 100644 --- a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/fake/snapshots_server.go +++ b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/fake/snapshots_server.go @@ -9,6 +9,7 @@ package fake import ( + "context" "errors" "fmt" azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" @@ -24,6 +25,14 @@ import ( // SnapshotsServer is a fake server for instances of the armappcomplianceautomation.SnapshotsClient type. type SnapshotsServer struct { + // BeginDownload is the fake for method SnapshotsClient.BeginDownload + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginDownload func(ctx context.Context, reportName string, snapshotName string, body armappcomplianceautomation.SnapshotDownloadRequest, options *armappcomplianceautomation.SnapshotsClientBeginDownloadOptions) (resp azfake.PollerResponder[armappcomplianceautomation.SnapshotsClientDownloadResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method SnapshotsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, reportName string, snapshotName string, options *armappcomplianceautomation.SnapshotsClientGetOptions) (resp azfake.Responder[armappcomplianceautomation.SnapshotsClientGetResponse], errResp azfake.ErrorResponder) + // NewListPager is the fake for method SnapshotsClient.NewListPager // HTTP status codes to indicate success: http.StatusOK NewListPager func(reportName string, options *armappcomplianceautomation.SnapshotsClientListOptions) (resp azfake.PagerResponder[armappcomplianceautomation.SnapshotsClientListResponse]) @@ -34,16 +43,18 @@ type SnapshotsServer struct { // azcore.ClientOptions.Transporter field in the client's constructor parameters. func NewSnapshotsServerTransport(srv *SnapshotsServer) *SnapshotsServerTransport { return &SnapshotsServerTransport{ - srv: srv, - newListPager: newTracker[azfake.PagerResponder[armappcomplianceautomation.SnapshotsClientListResponse]](), + srv: srv, + beginDownload: newTracker[azfake.PollerResponder[armappcomplianceautomation.SnapshotsClientDownloadResponse]](), + newListPager: newTracker[azfake.PagerResponder[armappcomplianceautomation.SnapshotsClientListResponse]](), } } // SnapshotsServerTransport connects instances of armappcomplianceautomation.SnapshotsClient to instances of SnapshotsServer. // Don't use this type directly, use NewSnapshotsServerTransport instead. type SnapshotsServerTransport struct { - srv *SnapshotsServer - newListPager *tracker[azfake.PagerResponder[armappcomplianceautomation.SnapshotsClientListResponse]] + srv *SnapshotsServer + beginDownload *tracker[azfake.PollerResponder[armappcomplianceautomation.SnapshotsClientDownloadResponse]] + newListPager *tracker[azfake.PagerResponder[armappcomplianceautomation.SnapshotsClientListResponse]] } // Do implements the policy.Transporter interface for SnapshotsServerTransport. @@ -58,6 +69,10 @@ func (s *SnapshotsServerTransport) Do(req *http.Request) (*http.Response, error) var err error switch method { + case "SnapshotsClient.BeginDownload": + resp, err = s.dispatchBeginDownload(req) + case "SnapshotsClient.Get": + resp, err = s.dispatchGet(req) case "SnapshotsClient.NewListPager": resp, err = s.dispatchNewListPager(req) default: @@ -71,6 +86,87 @@ func (s *SnapshotsServerTransport) Do(req *http.Request) (*http.Response, error) return resp, nil } +func (s *SnapshotsServerTransport) dispatchBeginDownload(req *http.Request) (*http.Response, error) { + if s.srv.BeginDownload == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDownload not implemented")} + } + beginDownload := s.beginDownload.get(req) + if beginDownload == nil { + const regexStr = `/providers/Microsoft\.AppComplianceAutomation/reports/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/snapshots/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/download` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armappcomplianceautomation.SnapshotDownloadRequest](req) + if err != nil { + return nil, err + } + reportNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("reportName")]) + if err != nil { + return nil, err + } + snapshotNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("snapshotName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.BeginDownload(req.Context(), reportNameParam, snapshotNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDownload = &respr + s.beginDownload.add(req, beginDownload) + } + + resp, err := server.PollerResponderNext(beginDownload, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + s.beginDownload.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDownload) { + s.beginDownload.remove(req) + } + + return resp, nil +} + +func (s *SnapshotsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if s.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/providers/Microsoft\.AppComplianceAutomation/reports/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/snapshots/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + reportNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("reportName")]) + if err != nil { + return nil, err + } + snapshotNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("snapshotName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.Get(req.Context(), reportNameParam, snapshotNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).SnapshotResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + func (s *SnapshotsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { if s.srv.NewListPager == nil { return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} @@ -84,10 +180,6 @@ func (s *SnapshotsServerTransport) dispatchNewListPager(req *http.Request) (*htt return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } qp := req.URL.Query() - reportNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("reportName")]) - if err != nil { - return nil, err - } skipTokenUnescaped, err := url.QueryUnescape(qp.Get("$skipToken")) if err != nil { return nil, err @@ -112,24 +204,40 @@ func (s *SnapshotsServerTransport) dispatchNewListPager(req *http.Request) (*htt return nil, err } selectParam := getOptional(selectUnescaped) - reportCreatorTenantIDUnescaped, err := url.QueryUnescape(qp.Get("reportCreatorTenantId")) + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) if err != nil { return nil, err } - reportCreatorTenantIDParam := getOptional(reportCreatorTenantIDUnescaped) + filterParam := getOptional(filterUnescaped) + orderbyUnescaped, err := url.QueryUnescape(qp.Get("$orderby")) + if err != nil { + return nil, err + } + orderbyParam := getOptional(orderbyUnescaped) offerGUIDUnescaped, err := url.QueryUnescape(qp.Get("offerGuid")) if err != nil { return nil, err } offerGUIDParam := getOptional(offerGUIDUnescaped) + reportCreatorTenantIDUnescaped, err := url.QueryUnescape(qp.Get("reportCreatorTenantId")) + if err != nil { + return nil, err + } + reportCreatorTenantIDParam := getOptional(reportCreatorTenantIDUnescaped) + reportNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("reportName")]) + if err != nil { + return nil, err + } var options *armappcomplianceautomation.SnapshotsClientListOptions - if skipTokenParam != nil || topParam != nil || selectParam != nil || reportCreatorTenantIDParam != nil || offerGUIDParam != nil { + if skipTokenParam != nil || topParam != nil || selectParam != nil || filterParam != nil || orderbyParam != nil || offerGUIDParam != nil || reportCreatorTenantIDParam != nil { options = &armappcomplianceautomation.SnapshotsClientListOptions{ SkipToken: skipTokenParam, Top: topParam, Select: selectParam, - ReportCreatorTenantID: reportCreatorTenantIDParam, + Filter: filterParam, + Orderby: orderbyParam, OfferGUID: offerGUIDParam, + ReportCreatorTenantID: reportCreatorTenantIDParam, } } resp := s.srv.NewListPager(reportNameParam, options) diff --git a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/fake/time_rfc3339.go b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/fake/time_rfc3339.go index b0535a7b63e6..81f308b0d343 100644 --- a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/fake/time_rfc3339.go +++ b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/fake/time_rfc3339.go @@ -19,12 +19,16 @@ import ( ) // Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. -var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) +var tzOffsetRegex = regexp.MustCompile(`(?:Z|z|\+|-)(?:\d+:\d+)*"*$`) const ( - utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` - utcDateTime = "2006-01-02T15:04:05.999999999" - dateTimeJSON = `"` + time.RFC3339Nano + `"` + utcDateTime = "2006-01-02T15:04:05.999999999" + utcDateTimeJSON = `"` + utcDateTime + `"` + utcDateTimeNoT = "2006-01-02 15:04:05.999999999" + utcDateTimeJSONNoT = `"` + utcDateTimeNoT + `"` + dateTimeNoT = `2006-01-02 15:04:05.999999999Z07:00` + dateTimeJSON = `"` + time.RFC3339Nano + `"` + dateTimeJSONNoT = `"` + dateTimeNoT + `"` ) type dateTimeRFC3339 time.Time @@ -40,17 +44,33 @@ func (t dateTimeRFC3339) MarshalText() ([]byte, error) { } func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { - layout := utcDateTimeJSON - if tzOffsetRegex.Match(data) { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { layout = dateTimeJSON + } else if tzOffset { + layout = dateTimeJSONNoT + } else if hasT { + layout = utcDateTimeJSON + } else { + layout = utcDateTimeJSONNoT } return t.Parse(layout, string(data)) } func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { - layout := utcDateTime - if tzOffsetRegex.Match(data) { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { layout = time.RFC3339Nano + } else if tzOffset { + layout = dateTimeNoT + } else if hasT { + layout = utcDateTime + } else { + layout = utcDateTimeNoT } return t.Parse(layout, string(data)) } @@ -61,6 +81,10 @@ func (t *dateTimeRFC3339) Parse(layout, value string) error { return err } +func (t dateTimeRFC3339) String() string { + return time.Time(t).Format(time.RFC3339Nano) +} + func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return @@ -74,7 +98,7 @@ func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { } func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { - if data == nil || strings.EqualFold(string(data), "null") { + if data == nil || string(data) == "null" { return nil } var aux dateTimeRFC3339 diff --git a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/fake/toolformicrosoft365_server.go b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/fake/toolformicrosoft365_server.go new file mode 100644 index 000000000000..c152fc92ffde --- /dev/null +++ b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/fake/toolformicrosoft365_server.go @@ -0,0 +1,96 @@ +//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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation" + "net/http" + "net/url" + "regexp" +) + +// ToolForMicrosoft365Server is a fake server for instances of the armappcomplianceautomation.ToolForMicrosoft365Client type. +type ToolForMicrosoft365Server struct { + // GetScopingQuestions is the fake for method ToolForMicrosoft365Client.GetScopingQuestions + // HTTP status codes to indicate success: http.StatusOK + GetScopingQuestions func(ctx context.Context, reportName string, options *armappcomplianceautomation.ToolForMicrosoft365ClientGetScopingQuestionsOptions) (resp azfake.Responder[armappcomplianceautomation.ToolForMicrosoft365ClientGetScopingQuestionsResponse], errResp azfake.ErrorResponder) +} + +// NewToolForMicrosoft365ServerTransport creates a new instance of ToolForMicrosoft365ServerTransport with the provided implementation. +// The returned ToolForMicrosoft365ServerTransport instance is connected to an instance of armappcomplianceautomation.ToolForMicrosoft365Client via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewToolForMicrosoft365ServerTransport(srv *ToolForMicrosoft365Server) *ToolForMicrosoft365ServerTransport { + return &ToolForMicrosoft365ServerTransport{srv: srv} +} + +// ToolForMicrosoft365ServerTransport connects instances of armappcomplianceautomation.ToolForMicrosoft365Client to instances of ToolForMicrosoft365Server. +// Don't use this type directly, use NewToolForMicrosoft365ServerTransport instead. +type ToolForMicrosoft365ServerTransport struct { + srv *ToolForMicrosoft365Server +} + +// Do implements the policy.Transporter interface for ToolForMicrosoft365ServerTransport. +func (t *ToolForMicrosoft365ServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "ToolForMicrosoft365Client.GetScopingQuestions": + resp, err = t.dispatchGetScopingQuestions(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (t *ToolForMicrosoft365ServerTransport) dispatchGetScopingQuestions(req *http.Request) (*http.Response, error) { + if t.srv.GetScopingQuestions == nil { + return nil, &nonRetriableError{errors.New("fake for method GetScopingQuestions not implemented")} + } + const regexStr = `/providers/Microsoft\.AppComplianceAutomation/reports/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/getScopingQuestions` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + reportNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("reportName")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.GetScopingQuestions(req.Context(), reportNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ScopingQuestions, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/fake/webhooks_server.go b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/fake/webhooks_server.go new file mode 100644 index 000000000000..c88e19e66460 --- /dev/null +++ b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/fake/webhooks_server.go @@ -0,0 +1,331 @@ +//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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// WebhooksServer is a fake server for instances of the armappcomplianceautomation.WebhooksClient type. +type WebhooksServer struct { + // CreateOrUpdate is the fake for method WebhooksClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, reportName string, webhookName string, parameters armappcomplianceautomation.WebhookResource, options *armappcomplianceautomation.WebhooksClientCreateOrUpdateOptions) (resp azfake.Responder[armappcomplianceautomation.WebhooksClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method WebhooksClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, reportName string, webhookName string, options *armappcomplianceautomation.WebhooksClientDeleteOptions) (resp azfake.Responder[armappcomplianceautomation.WebhooksClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method WebhooksClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, reportName string, webhookName string, options *armappcomplianceautomation.WebhooksClientGetOptions) (resp azfake.Responder[armappcomplianceautomation.WebhooksClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method WebhooksClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(reportName string, options *armappcomplianceautomation.WebhooksClientListOptions) (resp azfake.PagerResponder[armappcomplianceautomation.WebhooksClientListResponse]) + + // Update is the fake for method WebhooksClient.Update + // HTTP status codes to indicate success: http.StatusOK + Update func(ctx context.Context, reportName string, webhookName string, properties armappcomplianceautomation.WebhookResourcePatch, options *armappcomplianceautomation.WebhooksClientUpdateOptions) (resp azfake.Responder[armappcomplianceautomation.WebhooksClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewWebhooksServerTransport creates a new instance of WebhooksServerTransport with the provided implementation. +// The returned WebhooksServerTransport instance is connected to an instance of armappcomplianceautomation.WebhooksClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewWebhooksServerTransport(srv *WebhooksServer) *WebhooksServerTransport { + return &WebhooksServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armappcomplianceautomation.WebhooksClientListResponse]](), + } +} + +// WebhooksServerTransport connects instances of armappcomplianceautomation.WebhooksClient to instances of WebhooksServer. +// Don't use this type directly, use NewWebhooksServerTransport instead. +type WebhooksServerTransport struct { + srv *WebhooksServer + newListPager *tracker[azfake.PagerResponder[armappcomplianceautomation.WebhooksClientListResponse]] +} + +// Do implements the policy.Transporter interface for WebhooksServerTransport. +func (w *WebhooksServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "WebhooksClient.CreateOrUpdate": + resp, err = w.dispatchCreateOrUpdate(req) + case "WebhooksClient.Delete": + resp, err = w.dispatchDelete(req) + case "WebhooksClient.Get": + resp, err = w.dispatchGet(req) + case "WebhooksClient.NewListPager": + resp, err = w.dispatchNewListPager(req) + case "WebhooksClient.Update": + resp, err = w.dispatchUpdate(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (w *WebhooksServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if w.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/providers/Microsoft\.AppComplianceAutomation/reports/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/webhooks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armappcomplianceautomation.WebhookResource](req) + if err != nil { + return nil, err + } + reportNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("reportName")]) + if err != nil { + return nil, err + } + webhookNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("webhookName")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.CreateOrUpdate(req.Context(), reportNameParam, webhookNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).WebhookResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WebhooksServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if w.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/providers/Microsoft\.AppComplianceAutomation/reports/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/webhooks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + reportNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("reportName")]) + if err != nil { + return nil, err + } + webhookNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("webhookName")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Delete(req.Context(), reportNameParam, webhookNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WebhooksServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if w.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/providers/Microsoft\.AppComplianceAutomation/reports/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/webhooks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + reportNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("reportName")]) + if err != nil { + return nil, err + } + webhookNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("webhookName")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Get(req.Context(), reportNameParam, webhookNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).WebhookResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WebhooksServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if w.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := w.newListPager.get(req) + if newListPager == nil { + const regexStr = `/providers/Microsoft\.AppComplianceAutomation/reports/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/webhooks` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + skipTokenUnescaped, err := url.QueryUnescape(qp.Get("$skipToken")) + if err != nil { + return nil, err + } + skipTokenParam := getOptional(skipTokenUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + selectUnescaped, err := url.QueryUnescape(qp.Get("$select")) + if err != nil { + return nil, err + } + selectParam := getOptional(selectUnescaped) + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + orderbyUnescaped, err := url.QueryUnescape(qp.Get("$orderby")) + if err != nil { + return nil, err + } + orderbyParam := getOptional(orderbyUnescaped) + offerGUIDUnescaped, err := url.QueryUnescape(qp.Get("offerGuid")) + if err != nil { + return nil, err + } + offerGUIDParam := getOptional(offerGUIDUnescaped) + reportCreatorTenantIDUnescaped, err := url.QueryUnescape(qp.Get("reportCreatorTenantId")) + if err != nil { + return nil, err + } + reportCreatorTenantIDParam := getOptional(reportCreatorTenantIDUnescaped) + reportNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("reportName")]) + if err != nil { + return nil, err + } + var options *armappcomplianceautomation.WebhooksClientListOptions + if skipTokenParam != nil || topParam != nil || selectParam != nil || filterParam != nil || orderbyParam != nil || offerGUIDParam != nil || reportCreatorTenantIDParam != nil { + options = &armappcomplianceautomation.WebhooksClientListOptions{ + SkipToken: skipTokenParam, + Top: topParam, + Select: selectParam, + Filter: filterParam, + Orderby: orderbyParam, + OfferGUID: offerGUIDParam, + ReportCreatorTenantID: reportCreatorTenantIDParam, + } + } + resp := w.srv.NewListPager(reportNameParam, options) + newListPager = &resp + w.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armappcomplianceautomation.WebhooksClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + w.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + w.newListPager.remove(req) + } + return resp, nil +} + +func (w *WebhooksServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { + if w.srv.Update == nil { + return nil, &nonRetriableError{errors.New("fake for method Update not implemented")} + } + const regexStr = `/providers/Microsoft\.AppComplianceAutomation/reports/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/webhooks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armappcomplianceautomation.WebhookResourcePatch](req) + if err != nil { + return nil, err + } + reportNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("reportName")]) + if err != nil { + return nil, err + } + webhookNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("webhookName")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Update(req.Context(), reportNameParam, webhookNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).WebhookResource, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/go.mod b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/go.mod index d7cecf7f791d..fcd136f2906c 100644 --- a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/go.mod +++ b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/go.mod @@ -2,20 +2,10 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/appcomplianceautoma go 1.18 -require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.11.1 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.5.2 -) +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.11.1 require ( github.com/Azure/azure-sdk-for-go/sdk/internal v1.7.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect - github.com/golang-jwt/jwt/v5 v5.2.1 // indirect - github.com/google/uuid v1.6.0 // indirect - github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect - golang.org/x/crypto v0.22.0 // indirect golang.org/x/net v0.24.0 // indirect - golang.org/x/sys v0.19.0 // indirect golang.org/x/text v0.14.0 // indirect ) diff --git a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/go.sum b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/go.sum index 453385ef9f88..ffdff03203f8 100644 --- a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/go.sum +++ b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/go.sum @@ -1,29 +1,12 @@ github.com/Azure/azure-sdk-for-go/sdk/azcore v1.11.1 h1:E+OJmp2tPvt1W+amx48v1eqbjDYsgN+RzP4q16yV5eM= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.11.1/go.mod h1:a6xsAQUZg+VsS3TJ05SRp524Hs4pZ/AeFSr5ENf0Yjo= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.5.2 h1:FDif4R1+UUR+00q6wquyX90K7A8dN+R5E8GEadoP7sU= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.5.2/go.mod h1:aiYBYui4BJ/BJCAIKs92XiPyQfTaBWqvHujDwKb6CBU= github.com/Azure/azure-sdk-for-go/sdk/internal v1.7.0 h1:rTfKOCZGy5ViVrlA74ZPE99a+SgoEE2K/yg3RyW9dFA= github.com/Azure/azure-sdk-for-go/sdk/internal v1.7.0/go.mod h1:4OG6tQ9EOP/MT0NMjDlRzWoVFxfu9rN9B2X+tlSVktg= -github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 h1:XHOnouVk1mxXfQidrMEnLlPk9UMeRtyBTnEFtxkV0kU= -github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk= -github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/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-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= -github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= -golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= -golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= -golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/models.go b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/models.go index c769f4acf925..66362f8de9f1 100644 --- a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/models.go +++ b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/models.go @@ -10,58 +10,52 @@ package armappcomplianceautomation import "time" -// Assessment - A class represent the assessment. -type Assessment struct { - // READ-ONLY; The description of the assessment. - Description *string +// Category - A class represent the compliance category. +type Category struct { + // READ-ONLY; The name of the compliance category. e.g. "Operational Security" + CategoryName *string - // READ-ONLY; Indicates whether all the resource(s) are compliant. - IsPass *IsPass + // READ-ONLY; Category status. + CategoryStatus *CategoryStatus - // READ-ONLY; The name of the assessment. - Name *string + // READ-ONLY; List of control families. + ControlFamilies []*ControlFamily +} - // READ-ONLY; The policy id mapping to this assessment. - PolicyID *string +// CertSyncRecord - A class represent the certification record synchronized from app compliance. +type CertSyncRecord struct { + // Indicates the status of certification process. + CertificationStatus *string - // READ-ONLY; The remediation of the assessment. - Remediation *string + // The control records list to be synchronized. + Controls []*ControlSyncRecord - // READ-ONLY; List of resource assessments. - ResourceList []*AssessmentResource + // Indicates the status of compliance process. + IngestionStatus *string - // READ-ONLY; The severity level of this assessment. - Severity *AssessmentSeverity + // The offerGuid which mapping to the reports. + OfferGUID *string } -// AssessmentResource - A class represent the assessment resource. -type AssessmentResource struct { - // READ-ONLY; The reason for the N/A resource. - Reason *string - - // READ-ONLY; The Id of the resource. - ResourceID *string - - // READ-ONLY; Resource status. - ResourceStatus *ResourceStatus +// CheckNameAvailabilityRequest - The check availability request body. +type CheckNameAvailabilityRequest struct { + // The name of the resource for which availability needs to be checked. + Name *string - // READ-ONLY; The status change date for the resource. For unavailable date, set it as N/A. - StatusChangeDate *string + // The resource type. + Type *string } -// Category - A class represent the compliance category. -type Category struct { - // READ-ONLY; The name of the compliance category. e.g. "Operational Security" - CategoryName *string - - // READ-ONLY; Category status. - CategoryStatus *CategoryStatus +// CheckNameAvailabilityResponse - The check availability result. +type CheckNameAvailabilityResponse struct { + // Detailed reason why the given name is available. + Message *string - // READ-ONLY; The category type - CategoryType *CategoryType + // Indicates if the resource name is available. + NameAvailable *bool - // READ-ONLY; List of control families. - ControlFamilies []*ControlFamily + // The reason why the given name is not available. + Reason *CheckNameAvailabilityReason } // ComplianceReportItem - Object that includes all the content for single compliance result. @@ -69,8 +63,8 @@ type ComplianceReportItem struct { // READ-ONLY; The category name. CategoryName *string - // READ-ONLY; The compliance result's status. - ComplianceState *ComplianceState + // READ-ONLY; The control family name. + ControlFamilyName *string // READ-ONLY; The control Id - e.g. "1". ControlID *string @@ -78,33 +72,29 @@ type ComplianceReportItem struct { // READ-ONLY; The control name. ControlName *string - // READ-ONLY; The control type. - ControlType *ControlType - - // READ-ONLY; The policy's detail description. - PolicyDescription *string + // READ-ONLY; Control status. + ControlStatus *ControlStatus - // READ-ONLY; The policy's display name. - PolicyDisplayName *string + // READ-ONLY; The Id of the resource. + ResourceID *string - // READ-ONLY; The compliance result mapped policy Id. - PolicyID *string + // READ-ONLY; Resource origin. + ResourceOrigin *ResourceOrigin - // READ-ONLY; The compliance result mapped resource group. - ResourceGroup *string + // READ-ONLY; Resource status. + ResourceStatus *ResourceStatus - // READ-ONLY; The compliance result mapped resource Id - e.g. "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Compute/virtualMachines/vm1". - ResourceID *string + // READ-ONLY; The status change date for the resource. + ResourceStatusChangeDate *time.Time - // READ-ONLY; The compliance result mapped resource type. + // READ-ONLY; The type of the resource. e.g. "Microsoft.SignalRService/SignalR" ResourceType *string - // READ-ONLY; The compliance result last changed date - e.g. "2022-10-24T02:55:16.3274379Z". For unavailable date, set it - // as "N/A". - StatusChangeDate *string + // READ-ONLY; The description of the customer responsibility. + ResponsibilityDescription *string - // READ-ONLY; The compliance result mapped subscription Id. - SubscriptionID *string + // READ-ONLY; The title of the customer responsibility. + ResponsibilityTitle *string } // ComplianceResult - A class represent the compliance result. @@ -118,9 +108,6 @@ type ComplianceResult struct { // Control - A class represent the control. type Control struct { - // READ-ONLY; List of assessments. - Assessments []*Assessment - // READ-ONLY; The control's description ControlDescription *string @@ -131,61 +118,186 @@ type Control struct { // not in use." ControlFullName *string - // READ-ONLY; The Id of the control. e.g. "Operational Security#10" + // READ-ONLY; The Id of the control. e.g. "OperationalSecurity10" ControlID *string - // READ-ONLY; The short name of the control. e.g. "Unsupported OS and Software." - ControlShortName *string + // READ-ONLY; The name of the control. e.g. "Unsupported OS and Software." + ControlName *string // READ-ONLY; Control status. ControlStatus *ControlStatus - // READ-ONLY; The control type - ControlType *ControlType + // READ-ONLY; List of customer responsibility. + Responsibilities []*Responsibility } // ControlFamily - A class represent the control family. type ControlFamily struct { + // READ-ONLY; The name of the control family. e.g. "Malware Protection - Anti-Virus" + ControlFamilyName *string + + // READ-ONLY; The control family status + ControlFamilyStatus *ControlFamilyStatus + // READ-ONLY; List of controls. Controls []*Control +} - // READ-ONLY; The name of the control family. e.g. "Malware Protection - Anti-Virus" - FamilyName *string - - // READ-ONLY; Control family status. - FamilyStatus *ControlFamilyStatus +// ControlSyncRecord - A class represent the control record synchronized from app compliance. +type ControlSyncRecord struct { + // The Id of the control. e.g. "OperationalSecurity10" + ControlID *string - // READ-ONLY; The control family type - FamilyType *ControlFamilyType + // Control status synchronized from app compliance. + ControlStatus *string } // DownloadResponse - Object that includes all the possible response for the download operation. type DownloadResponse struct { - // READ-ONLY; compliance detailed pdf report + // READ-ONLY; The detailed compliance pdf report ComplianceDetailedPDFReport *DownloadResponseComplianceDetailedPDFReport - // READ-ONLY; compliance pdf report + // READ-ONLY; Compliance pdf report CompliancePDFReport *DownloadResponseCompliancePDFReport // READ-ONLY; List of the compliance result ComplianceReport []*ComplianceReportItem - // READ-ONLY; List of the reports + // READ-ONLY; Resource list of the report ResourceList []*ResourceItem } -// DownloadResponseComplianceDetailedPDFReport - compliance detailed pdf report +// DownloadResponseComplianceDetailedPDFReport - The detailed compliance pdf report type DownloadResponseComplianceDetailedPDFReport struct { - // READ-ONLY; uri of compliance detailed pdf report + // READ-ONLY; The uri of detailed compliance pdf report SasURI *string } -// DownloadResponseCompliancePDFReport - compliance pdf report +// DownloadResponseCompliancePDFReport - Compliance pdf report type DownloadResponseCompliancePDFReport struct { - // READ-ONLY; uri of compliance pdf report + // READ-ONLY; The uri of compliance pdf report SasURI *string } +// EvidenceFileDownloadRequest - Evidence file's download request. +type EvidenceFileDownloadRequest struct { + // The offerGuid which mapping to the reports. + OfferGUID *string + + // Tenant id. + ReportCreatorTenantID *string +} + +// EvidenceFileDownloadResponse - Object that includes all the possible response for the evidence file download operation. +type EvidenceFileDownloadResponse struct { + // READ-ONLY; The uri of evidence file + EvidenceFile *EvidenceFileDownloadResponseEvidenceFile +} + +// EvidenceFileDownloadResponseEvidenceFile - The uri of evidence file +type EvidenceFileDownloadResponseEvidenceFile struct { + // READ-ONLY; The url of evidence file + URL *string +} + +// EvidenceProperties - Evidence's properties. +type EvidenceProperties struct { + // REQUIRED; The path of the file in storage. + FilePath *string + + // Control id. + ControlID *string + + // Evidence type. + EvidenceType *EvidenceType + + // Extra data considered as evidence. + ExtraData *string + + // Responsibility id. + ResponsibilityID *string + + // READ-ONLY; Azure lifecycle management + ProvisioningState *ProvisioningState +} + +// EvidenceResource - A class represent an AppComplianceAutomation evidence resource. +type EvidenceResource struct { + // REQUIRED; Evidence property. + Properties *EvidenceProperties + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// EvidenceResourceListResult - The response of a EvidenceResource list operation. +type EvidenceResourceListResult struct { + // REQUIRED; The EvidenceResource items on this page + Value []*EvidenceResource + + // The link to the next page of items + NextLink *string +} + +// GetCollectionCountRequest - Get collection count's request object. +type GetCollectionCountRequest struct { + // The resource type. + Type *string +} + +// GetCollectionCountResponse - The get collection count response. +type GetCollectionCountResponse struct { + // The count of the specified resource. + Count *int32 +} + +// GetOverviewStatusRequest - Get overview status request object. +type GetOverviewStatusRequest struct { + // The resource type. + Type *string +} + +// GetOverviewStatusResponse - The get overview status response. +type GetOverviewStatusResponse struct { + // List of different status items. + StatusList []*StatusItem +} + +// ListInUseStorageAccountsRequest - Parameters for listing in use storage accounts operation. If subscription list is null, +// it will check the user's all subscriptions. +type ListInUseStorageAccountsRequest struct { + // List of subscription ids to be query. If the list is null or empty, the API will query all the subscriptions of the user. + SubscriptionIDs []*string +} + +// ListInUseStorageAccountsResponse - Parameters for listing in use storage accounts operation. If subscription list is null, +// it will check the user's all subscriptions. +type ListInUseStorageAccountsResponse struct { + // The storage account list which in use in related reports. + StorageAccountList []*StorageInfo +} + +// OnboardRequest - Parameters for onboard operation +type OnboardRequest struct { + // REQUIRED; List of subscription ids to be onboarded + SubscriptionIDs []*string +} + +// OnboardResponse - Success. The response indicates given subscriptions has been onboarded. +type OnboardResponse struct { + // List of subscription ids that are onboarded + SubscriptionIDs []*string +} + // Operation - Details of a REST API operation, returned from the Resource Provider Operations API type Operation struct { // Localized display information for this particular operation. @@ -237,23 +349,134 @@ type OperationListResult struct { // OverviewStatus - The overview of the compliance result for one report. type OverviewStatus struct { - // The count of all failed full automation control. + // READ-ONLY; The count of all failed control. FailedCount *int32 - // The count of all manual control. + // READ-ONLY; The count of all manual control. ManualCount *int32 - // The count of all passed full automation control. + // READ-ONLY; The count of all not applicable control. + NotApplicableCount *int32 + + // READ-ONLY; The count of all passed control. PassedCount *int32 + + // READ-ONLY; The count of all pending for approval control. + PendingCount *int32 +} + +// QuickAssessment - A class represent the quick assessment. +type QuickAssessment struct { + // READ-ONLY; Quick assessment display name. + Description *string + + // READ-ONLY; Quick assessment display name. + DisplayName *string + + // READ-ONLY; Link to remediation steps for this quick assessment. + RemediationLink *string + + // READ-ONLY; Resource id. + ResourceID *string + + // READ-ONLY; Quick assessment status. + ResourceStatus *ResourceStatus + + // READ-ONLY; Responsibility id. + ResponsibilityID *string + + // READ-ONLY; The timestamp of resource creation (UTC). + Timestamp *time.Time +} + +// Recommendation - A class represent the recommendation. +type Recommendation struct { + // READ-ONLY; The Id of the recommendation. + RecommendationID *string + + // READ-ONLY; The short name of the recommendation. e.g. "Invalid TLS config" + RecommendationShortName *string + + // READ-ONLY; List of recommendation solutions. + RecommendationSolutions []*RecommendationSolution +} + +// RecommendationSolution - A class represent the recommendation solution. +type RecommendationSolution struct { + // READ-ONLY; Indicates whether this solution is the recommended. + IsRecommendSolution *IsRecommendSolution + + // READ-ONLY; The detail steps of the recommendation solution. + RecommendationSolutionContent *string + + // READ-ONLY; The index of the recommendation solution. + RecommendationSolutionIndex *string } // ReportComplianceStatus - A list which includes all the compliance result for one report. type ReportComplianceStatus struct { - // The Microsoft 365 certification name. + // READ-ONLY; The Microsoft 365 certification name. M365 *OverviewStatus } -// ReportProperties - Report's properties. +// ReportFixResult - Report fix result. +type ReportFixResult struct { + // READ-ONLY; If the report fix action failed, to indicate the detailed failed reason. + Reason *string + + // READ-ONLY; Indicates whether the fix action is Succeeded or Failed. + Result *Result +} + +// ReportPatchProperties - Patch Report's properties. +type ReportPatchProperties struct { + // A list of comma-separated offerGuids indicates a series of offerGuids that map to the report. For example, "00000000-0000-0000-0000-000000000001,00000000-0000-0000-0000-000000000002" + // and + // "00000000-0000-0000-0000-000000000003". + OfferGUID *string + + // List of resource data. + Resources []*ResourceMetadata + + // The information of 'bring your own storage' binding to the report + StorageInfo *StorageInfo + + // Report collection trigger time's time zone, the available list can be obtained by executing "Get-TimeZone -ListAvailable" + // in PowerShell. An example of valid timezone id is "Pacific Standard Time". + TimeZone *string + + // Report collection trigger time. + TriggerTime *time.Time + + // READ-ONLY; List of synchronized certification records. + CertRecords []*CertSyncRecord + + // READ-ONLY; Report compliance status. + ComplianceStatus *ReportComplianceStatus + + // READ-ONLY; List of report error codes. + Errors []*string + + // READ-ONLY; Report last collection trigger time. + LastTriggerTime *time.Time + + // READ-ONLY; Report next collection trigger time. + NextTriggerTime *time.Time + + // READ-ONLY; Azure lifecycle management + ProvisioningState *ProvisioningState + + // READ-ONLY; Report status. + Status *ReportStatus + + // READ-ONLY; List of subscription Ids. + Subscriptions []*string + + // READ-ONLY; Report's tenant id. + TenantID *string +} + +// ReportProperties - Create Report's properties. type ReportProperties struct { // REQUIRED; List of resource data. Resources []*ResourceMetadata @@ -265,14 +488,22 @@ type ReportProperties struct { // REQUIRED; Report collection trigger time. TriggerTime *time.Time - // Report offer Guid. + // A list of comma-separated offerGuids indicates a series of offerGuids that map to the report. For example, "00000000-0000-0000-0000-000000000001,00000000-0000-0000-0000-000000000002" + // and + // "00000000-0000-0000-0000-000000000003". OfferGUID *string + // The information of 'bring your own storage' binding to the report + StorageInfo *StorageInfo + + // READ-ONLY; List of synchronized certification records. + CertRecords []*CertSyncRecord + // READ-ONLY; Report compliance status. ComplianceStatus *ReportComplianceStatus - // READ-ONLY; Report id in database. - ID *string + // READ-ONLY; List of report error codes. + Errors []*string // READ-ONLY; Report last collection trigger time. LastTriggerTime *time.Time @@ -283,9 +514,6 @@ type ReportProperties struct { // READ-ONLY; Azure lifecycle management ProvisioningState *ProvisioningState - // READ-ONLY; Report name. - ReportName *string - // READ-ONLY; Report status. Status *ReportStatus @@ -314,19 +542,28 @@ type ReportResource struct { Type *string } -// ReportResourceList - Object that includes an array of resources and a possible link for next set. -type ReportResourceList struct { - // The URL the client should use to fetch the next page (per server side paging). It's null for now, added for future use. - NextLink *string - - // READ-ONLY; List of the reports +// ReportResourceListResult - The response of a ReportResource list operation. +type ReportResourceListResult struct { + // REQUIRED; The ReportResource items on this page Value []*ReportResource + + // The link to the next page of items + NextLink *string } // ReportResourcePatch - A class represent a AppComplianceAutomation report resource update properties. type ReportResourcePatch struct { // Report property. - Properties *ReportProperties + Properties *ReportPatchProperties +} + +// ReportVerificationResult - Report health status verification result. +type ReportVerificationResult struct { + // READ-ONLY; If the report verification action failed, to indicate the detailed failed reason. + Reason *string + + // READ-ONLY; Indicates whether the report verification action is Succeeded or Failed. + Result *Result } // ResourceItem - Resource Id. @@ -337,7 +574,7 @@ type ResourceItem struct { // READ-ONLY; The resource Id - e.g. "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Compute/virtualMachines/vm1". ResourceID *string - // READ-ONLY; The resource type of this resource. + // READ-ONLY; The resource type of this resource. e.g. "Microsoft.SignalRService/SignalR" ResourceType *string // READ-ONLY; The subscription Id of this resource. @@ -349,17 +586,158 @@ type ResourceMetadata struct { // REQUIRED; Resource Id - e.g. "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Compute/virtualMachines/vm1". ResourceID *string + // Account Id. For example - the AWS account id. + AccountID *string + // Resource kind. ResourceKind *string - // Resource name. - ResourceName *string + // Resource Origin. + ResourceOrigin *ResourceOrigin + + // Resource type. e.g. "Microsoft.Compute/virtualMachines" + ResourceType *string +} + +// Responsibility - A class represent the customer responsibility. +type Responsibility struct { + // List of evidence file url. + EvidenceFiles []*string + + // The count of all failed resources. + FailedResourceCount *int32 + + // The count of all resources. + TotalResourceCount *int32 + + // READ-ONLY; The evidence upload guidance description. + Guidance *string + + // READ-ONLY; The justification given by the user to clarify the reason. + Justification *string + + // READ-ONLY; List of recommendation. + RecommendationList []*Recommendation + + // READ-ONLY; List of resource. + ResourceList []*ResponsibilityResource + + // READ-ONLY; The description of the customer responsibility. + ResponsibilityDescription *string + + // READ-ONLY; The supported cloud environment of this customer responsibility. + ResponsibilityEnvironment *ResponsibilityEnvironment + + // READ-ONLY; The id of the customer responsibility. + ResponsibilityID *string + + // READ-ONLY; The severity level of this customer responsibility. + ResponsibilitySeverity *ResponsibilitySeverity - // Resource type. + // READ-ONLY; The status of this customer responsibility. + ResponsibilityStatus *ResponsibilityStatus + + // READ-ONLY; The title of the customer responsibility. + ResponsibilityTitle *string + + // READ-ONLY; The type of customer responsibility. + ResponsibilityType *ResponsibilityType +} + +// ResponsibilityResource - A class represent the resource. +type ResponsibilityResource struct { + // List of recommendation id. + RecommendationIDs []*string + + // READ-ONLY; Account Id. For example - AWS account Id. + AccountID *string + + // READ-ONLY; The Id of the resource. + ResourceID *string + + // READ-ONLY; Resource origin. + ResourceOrigin *ResourceOrigin + + // READ-ONLY; Resource status. + ResourceStatus *ResourceStatus + + // READ-ONLY; The status change date for the resource. + ResourceStatusChangeDate *time.Time + + // READ-ONLY; The type of the resource. e.g. "Microsoft.SignalRService/SignalR" ResourceType *string +} - // Resource's tag type. - Tags map[string]*string +// ScopingAnswer - Scoping answer. +type ScopingAnswer struct { + // REQUIRED; Question answer value list. + Answers []*string + + // REQUIRED; Question id. + QuestionID *string +} + +// ScopingConfigurationProperties - ScopingConfiguration's properties. +type ScopingConfigurationProperties struct { + // List of scoping question answers. + Answers []*ScopingAnswer + + // READ-ONLY; Azure lifecycle management + ProvisioningState *ProvisioningState +} + +// ScopingConfigurationResource - A class represent an AppComplianceAutomation scoping configuration resource. +type ScopingConfigurationResource struct { + // REQUIRED; ScopingConfiguration property. + Properties *ScopingConfigurationProperties + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// ScopingConfigurationResourceListResult - The response of a ScopingConfigurationResource list operation. +type ScopingConfigurationResourceListResult struct { + // REQUIRED; The ScopingConfigurationResource items on this page + Value []*ScopingConfigurationResource + + // The link to the next page of items + NextLink *string +} + +// ScopingQuestion - The definition of a scoping question. +type ScopingQuestion struct { + // READ-ONLY; Input type of the question answer. + InputType *InputType + + // READ-ONLY; Option id list. + OptionIDs []*string + + // READ-ONLY; Question id. + QuestionID *string + + // READ-ONLY; The rule of the question. + Rules []*Rule + + // READ-ONLY; The answer value to show the sub questions. + ShowSubQuestionsValue *string + + // READ-ONLY; Superior question id. + SuperiorQuestionID *string +} + +// ScopingQuestions - Scoping question list. +type ScopingQuestions struct { + // List of scoping questions. + Questions []*ScopingQuestion } // SnapshotDownloadRequest - Snapshot's download request. @@ -382,9 +760,6 @@ type SnapshotProperties struct { // READ-ONLY; The timestamp of resource creation (UTC). CreatedAt *time.Time - // READ-ONLY; Snapshot id in the database. - ID *string - // READ-ONLY; Azure lifecycle management ProvisioningState *ProvisioningState @@ -400,15 +775,15 @@ type SnapshotProperties struct { // SnapshotResource - A class represent a AppComplianceAutomation snapshot resource. type SnapshotResource struct { + // Snapshot's property. + Properties *SnapshotProperties + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} ID *string // READ-ONLY; The name of the resource Name *string - // READ-ONLY; Snapshot's property'. - Properties *SnapshotProperties - // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. SystemData *SystemData @@ -416,13 +791,49 @@ type SnapshotResource struct { Type *string } -// SnapshotResourceList - Object that includes an array of resources and a possible link for next set. -type SnapshotResourceList struct { - // The URL the client should use to fetch the next page (per server side paging). It's null for now, added for future use. +// SnapshotResourceListResult - The response of a SnapshotResource list operation. +type SnapshotResourceListResult struct { + // REQUIRED; The SnapshotResource items on this page + Value []*SnapshotResource + + // The link to the next page of items NextLink *string +} - // READ-ONLY; List of the snapshots - Value []*SnapshotResource +// StatusItem - Single status. +type StatusItem struct { + // Status name - e.g. "Active", "Failed". + StatusName *string + + // Status value. e.g. "100", or "100%". + StatusValue *string +} + +// StorageInfo - The information of 'bring your own storage' account binding to the report +type StorageInfo struct { + // 'bring your own storage' account name + AccountName *string + + // The region of 'bring your own storage' account + Location *string + + // The resourceGroup which 'bring your own storage' account belongs to + ResourceGroup *string + + // The subscription id which 'bring your own storage' account belongs to + SubscriptionID *string +} + +// SyncCertRecordRequest - Synchronize certification record request. +type SyncCertRecordRequest struct { + // REQUIRED; certification record to be synchronized. + CertRecord *CertSyncRecord +} + +// SyncCertRecordResponse - Synchronize certification record response. +type SyncCertRecordResponse struct { + // certification record synchronized. + CertRecord *CertSyncRecord } // SystemData - Metadata pertaining to creation and last modification of the resource. @@ -445,3 +856,105 @@ type SystemData struct { // The type of identity that last modified the resource. LastModifiedByType *CreatedByType } + +// TriggerEvaluationProperty - Trigger evaluation response. +type TriggerEvaluationProperty struct { + // List of quick assessments + QuickAssessments []*QuickAssessment + + // List of resource ids to be evaluated + ResourceIDs []*string + + // READ-ONLY; The time when the evaluation is end. + EvaluationEndTime *time.Time + + // READ-ONLY; The time when the evaluation is triggered. + TriggerTime *time.Time +} + +// TriggerEvaluationRequest - Trigger evaluation request. +type TriggerEvaluationRequest struct { + // REQUIRED; List of resource ids to be evaluated + ResourceIDs []*string +} + +// TriggerEvaluationResponse - Trigger evaluation response. +type TriggerEvaluationResponse struct { + // trigger evaluation property. + Properties *TriggerEvaluationProperty +} + +// WebhookProperties - Webhook properties. +type WebhookProperties struct { + // content type + ContentType *ContentType + + // whether to enable ssl verification + EnableSSLVerification *EnableSSLVerification + + // under which event notification should be sent. + Events []*NotificationEvent + + // webhook payload url + PayloadURL *string + + // whether to send notification under any event. + SendAllEvents *SendAllEvents + + // Webhook status. + Status *WebhookStatus + + // whether to update webhookKey. + UpdateWebhookKey *UpdateWebhookKey + + // webhook secret token. If not set, this field value is null; otherwise, please set a string value. + WebhookKey *string + + // READ-ONLY; webhook deliveryStatus + DeliveryStatus *DeliveryStatus + + // READ-ONLY; Azure Resource Provisioning State + ProvisioningState *ProvisioningState + + // READ-ONLY; Tenant id. + TenantID *string + + // READ-ONLY; Webhook id in database. + WebhookID *string + + // READ-ONLY; whether webhookKey is enabled. + WebhookKeyEnabled *WebhookKeyEnabled +} + +// WebhookResource - A class represent an AppComplianceAutomation webhook resource. +type WebhookResource struct { + // REQUIRED; Webhook property. + Properties *WebhookProperties + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// WebhookResourceListResult - The response of a WebhookResource list operation. +type WebhookResourceListResult struct { + // REQUIRED; The WebhookResource items on this page + Value []*WebhookResource + + // The link to the next page of items + NextLink *string +} + +// WebhookResourcePatch - A class represent a AppComplianceAutomation webhook resource update properties. +type WebhookResourcePatch struct { + // Webhook property. + Properties *WebhookProperties +} diff --git a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/models_serde.go b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/models_serde.go index 85941ed407b2..92dd8c6ba27d 100644 --- a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/models_serde.go +++ b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/models_serde.go @@ -15,108 +15,122 @@ import ( "reflect" ) -// MarshalJSON implements the json.Marshaller interface for type Assessment. -func (a Assessment) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type Category. +func (c Category) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "description", a.Description) - populate(objectMap, "isPass", a.IsPass) - populate(objectMap, "name", a.Name) - populate(objectMap, "policyId", a.PolicyID) - populate(objectMap, "remediation", a.Remediation) - populate(objectMap, "resourceList", a.ResourceList) - populate(objectMap, "severity", a.Severity) + populate(objectMap, "categoryName", c.CategoryName) + populate(objectMap, "categoryStatus", c.CategoryStatus) + populate(objectMap, "controlFamilies", c.ControlFamilies) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type Assessment. -func (a *Assessment) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type Category. +func (c *Category) 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) + 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", &a.Description) + case "categoryName": + err = unpopulate(val, "CategoryName", &c.CategoryName) delete(rawMsg, key) - case "isPass": - err = unpopulate(val, "IsPass", &a.IsPass) + case "categoryStatus": + err = unpopulate(val, "CategoryStatus", &c.CategoryStatus) delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &a.Name) + case "controlFamilies": + err = unpopulate(val, "ControlFamilies", &c.ControlFamilies) delete(rawMsg, key) - case "policyId": - err = unpopulate(val, "PolicyID", &a.PolicyID) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CertSyncRecord. +func (c CertSyncRecord) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "certificationStatus", c.CertificationStatus) + populate(objectMap, "controls", c.Controls) + populate(objectMap, "ingestionStatus", c.IngestionStatus) + populate(objectMap, "offerGuid", c.OfferGUID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CertSyncRecord. +func (c *CertSyncRecord) 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 "certificationStatus": + err = unpopulate(val, "CertificationStatus", &c.CertificationStatus) delete(rawMsg, key) - case "remediation": - err = unpopulate(val, "Remediation", &a.Remediation) + case "controls": + err = unpopulate(val, "Controls", &c.Controls) delete(rawMsg, key) - case "resourceList": - err = unpopulate(val, "ResourceList", &a.ResourceList) + case "ingestionStatus": + err = unpopulate(val, "IngestionStatus", &c.IngestionStatus) delete(rawMsg, key) - case "severity": - err = unpopulate(val, "Severity", &a.Severity) + case "offerGuid": + err = unpopulate(val, "OfferGUID", &c.OfferGUID) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", a, err) + return fmt.Errorf("unmarshalling type %T: %v", c, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type AssessmentResource. -func (a AssessmentResource) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type CheckNameAvailabilityRequest. +func (c CheckNameAvailabilityRequest) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "reason", a.Reason) - populate(objectMap, "resourceId", a.ResourceID) - populate(objectMap, "resourceStatus", a.ResourceStatus) - populate(objectMap, "statusChangeDate", a.StatusChangeDate) + populate(objectMap, "name", c.Name) + populate(objectMap, "type", c.Type) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type AssessmentResource. -func (a *AssessmentResource) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type CheckNameAvailabilityRequest. +func (c *CheckNameAvailabilityRequest) 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) + return fmt.Errorf("unmarshalling type %T: %v", c, err) } for key, val := range rawMsg { var err error switch key { - case "reason": - err = unpopulate(val, "Reason", &a.Reason) - delete(rawMsg, key) - case "resourceId": - err = unpopulate(val, "ResourceID", &a.ResourceID) - delete(rawMsg, key) - case "resourceStatus": - err = unpopulate(val, "ResourceStatus", &a.ResourceStatus) + case "name": + err = unpopulate(val, "Name", &c.Name) delete(rawMsg, key) - case "statusChangeDate": - err = unpopulate(val, "StatusChangeDate", &a.StatusChangeDate) + case "type": + err = unpopulate(val, "Type", &c.Type) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", a, err) + return fmt.Errorf("unmarshalling type %T: %v", c, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type Category. -func (c Category) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type CheckNameAvailabilityResponse. +func (c CheckNameAvailabilityResponse) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "categoryName", c.CategoryName) - populate(objectMap, "categoryStatus", c.CategoryStatus) - populate(objectMap, "categoryType", c.CategoryType) - populate(objectMap, "controlFamilies", c.ControlFamilies) + populate(objectMap, "message", c.Message) + populate(objectMap, "nameAvailable", c.NameAvailable) + populate(objectMap, "reason", c.Reason) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type Category. -func (c *Category) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type CheckNameAvailabilityResponse. +func (c *CheckNameAvailabilityResponse) 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) @@ -124,17 +138,14 @@ func (c *Category) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "categoryName": - err = unpopulate(val, "CategoryName", &c.CategoryName) - delete(rawMsg, key) - case "categoryStatus": - err = unpopulate(val, "CategoryStatus", &c.CategoryStatus) + case "message": + err = unpopulate(val, "Message", &c.Message) delete(rawMsg, key) - case "categoryType": - err = unpopulate(val, "CategoryType", &c.CategoryType) + case "nameAvailable": + err = unpopulate(val, "NameAvailable", &c.NameAvailable) delete(rawMsg, key) - case "controlFamilies": - err = unpopulate(val, "ControlFamilies", &c.ControlFamilies) + case "reason": + err = unpopulate(val, "Reason", &c.Reason) delete(rawMsg, key) } if err != nil { @@ -148,18 +159,17 @@ func (c *Category) UnmarshalJSON(data []byte) error { func (c ComplianceReportItem) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "categoryName", c.CategoryName) - populate(objectMap, "complianceState", c.ComplianceState) + populate(objectMap, "controlFamilyName", c.ControlFamilyName) populate(objectMap, "controlId", c.ControlID) populate(objectMap, "controlName", c.ControlName) - populate(objectMap, "controlType", c.ControlType) - populate(objectMap, "policyDescription", c.PolicyDescription) - populate(objectMap, "policyDisplayName", c.PolicyDisplayName) - populate(objectMap, "policyId", c.PolicyID) - populate(objectMap, "resourceGroup", c.ResourceGroup) + populate(objectMap, "controlStatus", c.ControlStatus) populate(objectMap, "resourceId", c.ResourceID) + populate(objectMap, "resourceOrigin", c.ResourceOrigin) + populate(objectMap, "resourceStatus", c.ResourceStatus) + populateDateTimeRFC3339(objectMap, "resourceStatusChangeDate", c.ResourceStatusChangeDate) populate(objectMap, "resourceType", c.ResourceType) - populate(objectMap, "statusChangeDate", c.StatusChangeDate) - populate(objectMap, "subscriptionId", c.SubscriptionID) + populate(objectMap, "responsibilityDescription", c.ResponsibilityDescription) + populate(objectMap, "responsibilityTitle", c.ResponsibilityTitle) return json.Marshal(objectMap) } @@ -175,8 +185,8 @@ func (c *ComplianceReportItem) UnmarshalJSON(data []byte) error { case "categoryName": err = unpopulate(val, "CategoryName", &c.CategoryName) delete(rawMsg, key) - case "complianceState": - err = unpopulate(val, "ComplianceState", &c.ComplianceState) + case "controlFamilyName": + err = unpopulate(val, "ControlFamilyName", &c.ControlFamilyName) delete(rawMsg, key) case "controlId": err = unpopulate(val, "ControlID", &c.ControlID) @@ -184,32 +194,29 @@ func (c *ComplianceReportItem) UnmarshalJSON(data []byte) error { case "controlName": err = unpopulate(val, "ControlName", &c.ControlName) delete(rawMsg, key) - case "controlType": - err = unpopulate(val, "ControlType", &c.ControlType) - delete(rawMsg, key) - case "policyDescription": - err = unpopulate(val, "PolicyDescription", &c.PolicyDescription) + case "controlStatus": + err = unpopulate(val, "ControlStatus", &c.ControlStatus) delete(rawMsg, key) - case "policyDisplayName": - err = unpopulate(val, "PolicyDisplayName", &c.PolicyDisplayName) + case "resourceId": + err = unpopulate(val, "ResourceID", &c.ResourceID) delete(rawMsg, key) - case "policyId": - err = unpopulate(val, "PolicyID", &c.PolicyID) + case "resourceOrigin": + err = unpopulate(val, "ResourceOrigin", &c.ResourceOrigin) delete(rawMsg, key) - case "resourceGroup": - err = unpopulate(val, "ResourceGroup", &c.ResourceGroup) + case "resourceStatus": + err = unpopulate(val, "ResourceStatus", &c.ResourceStatus) delete(rawMsg, key) - case "resourceId": - err = unpopulate(val, "ResourceID", &c.ResourceID) + case "resourceStatusChangeDate": + err = unpopulateDateTimeRFC3339(val, "ResourceStatusChangeDate", &c.ResourceStatusChangeDate) delete(rawMsg, key) case "resourceType": err = unpopulate(val, "ResourceType", &c.ResourceType) delete(rawMsg, key) - case "statusChangeDate": - err = unpopulate(val, "StatusChangeDate", &c.StatusChangeDate) + case "responsibilityDescription": + err = unpopulate(val, "ResponsibilityDescription", &c.ResponsibilityDescription) delete(rawMsg, key) - case "subscriptionId": - err = unpopulate(val, "SubscriptionID", &c.SubscriptionID) + case "responsibilityTitle": + err = unpopulate(val, "ResponsibilityTitle", &c.ResponsibilityTitle) delete(rawMsg, key) } if err != nil { @@ -253,14 +260,13 @@ func (c *ComplianceResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Control. func (c Control) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "assessments", c.Assessments) populate(objectMap, "controlDescription", c.ControlDescription) populate(objectMap, "controlDescriptionHyperLink", c.ControlDescriptionHyperLink) populate(objectMap, "controlFullName", c.ControlFullName) populate(objectMap, "controlId", c.ControlID) - populate(objectMap, "controlShortName", c.ControlShortName) + populate(objectMap, "controlName", c.ControlName) populate(objectMap, "controlStatus", c.ControlStatus) - populate(objectMap, "controlType", c.ControlType) + populate(objectMap, "responsibilities", c.Responsibilities) return json.Marshal(objectMap) } @@ -273,9 +279,6 @@ func (c *Control) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "assessments": - err = unpopulate(val, "Assessments", &c.Assessments) - delete(rawMsg, key) case "controlDescription": err = unpopulate(val, "ControlDescription", &c.ControlDescription) delete(rawMsg, key) @@ -288,14 +291,14 @@ func (c *Control) UnmarshalJSON(data []byte) error { case "controlId": err = unpopulate(val, "ControlID", &c.ControlID) delete(rawMsg, key) - case "controlShortName": - err = unpopulate(val, "ControlShortName", &c.ControlShortName) + case "controlName": + err = unpopulate(val, "ControlName", &c.ControlName) delete(rawMsg, key) case "controlStatus": err = unpopulate(val, "ControlStatus", &c.ControlStatus) delete(rawMsg, key) - case "controlType": - err = unpopulate(val, "ControlType", &c.ControlType) + case "responsibilities": + err = unpopulate(val, "Responsibilities", &c.Responsibilities) delete(rawMsg, key) } if err != nil { @@ -308,10 +311,9 @@ func (c *Control) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ControlFamily. func (c ControlFamily) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) + populate(objectMap, "controlFamilyName", c.ControlFamilyName) + populate(objectMap, "controlFamilyStatus", c.ControlFamilyStatus) populate(objectMap, "controls", c.Controls) - populate(objectMap, "familyName", c.FamilyName) - populate(objectMap, "familyStatus", c.FamilyStatus) - populate(objectMap, "familyType", c.FamilyType) return json.Marshal(objectMap) } @@ -324,17 +326,45 @@ func (c *ControlFamily) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "controlFamilyName": + err = unpopulate(val, "ControlFamilyName", &c.ControlFamilyName) + delete(rawMsg, key) + case "controlFamilyStatus": + err = unpopulate(val, "ControlFamilyStatus", &c.ControlFamilyStatus) + delete(rawMsg, key) case "controls": err = unpopulate(val, "Controls", &c.Controls) delete(rawMsg, key) - case "familyName": - err = unpopulate(val, "FamilyName", &c.FamilyName) - delete(rawMsg, key) - case "familyStatus": - err = unpopulate(val, "FamilyStatus", &c.FamilyStatus) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ControlSyncRecord. +func (c ControlSyncRecord) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "controlId", c.ControlID) + populate(objectMap, "controlStatus", c.ControlStatus) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ControlSyncRecord. +func (c *ControlSyncRecord) 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 "controlId": + err = unpopulate(val, "ControlID", &c.ControlID) delete(rawMsg, key) - case "familyType": - err = unpopulate(val, "FamilyType", &c.FamilyType) + case "controlStatus": + err = unpopulate(val, "ControlStatus", &c.ControlStatus) delete(rawMsg, key) } if err != nil { @@ -437,641 +467,2066 @@ func (d *DownloadResponseCompliancePDFReport) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type Operation. -func (o Operation) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type EvidenceFileDownloadRequest. +func (e EvidenceFileDownloadRequest) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "actionType", o.ActionType) - populate(objectMap, "display", o.Display) - populate(objectMap, "isDataAction", o.IsDataAction) - populate(objectMap, "name", o.Name) - populate(objectMap, "origin", o.Origin) + populate(objectMap, "offerGuid", e.OfferGUID) + populate(objectMap, "reportCreatorTenantId", e.ReportCreatorTenantID) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type Operation. -func (o *Operation) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type EvidenceFileDownloadRequest. +func (e *EvidenceFileDownloadRequest) 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) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } for key, val := range rawMsg { var err error switch key { - case "actionType": - err = unpopulate(val, "ActionType", &o.ActionType) - delete(rawMsg, key) - case "display": - err = unpopulate(val, "Display", &o.Display) + case "offerGuid": + err = unpopulate(val, "OfferGUID", &e.OfferGUID) delete(rawMsg, key) - case "isDataAction": - err = unpopulate(val, "IsDataAction", &o.IsDataAction) + case "reportCreatorTenantId": + err = unpopulate(val, "ReportCreatorTenantID", &e.ReportCreatorTenantID) delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &o.Name) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type EvidenceFileDownloadResponse. +func (e EvidenceFileDownloadResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "evidenceFile", e.EvidenceFile) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EvidenceFileDownloadResponse. +func (e *EvidenceFileDownloadResponse) 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 "evidenceFile": + err = unpopulate(val, "EvidenceFile", &e.EvidenceFile) delete(rawMsg, key) - case "origin": - err = unpopulate(val, "Origin", &o.Origin) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type EvidenceFileDownloadResponseEvidenceFile. +func (e EvidenceFileDownloadResponseEvidenceFile) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "url", e.URL) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EvidenceFileDownloadResponseEvidenceFile. +func (e *EvidenceFileDownloadResponseEvidenceFile) 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 "url": + err = unpopulate(val, "URL", &e.URL) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", o, err) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type OperationDisplay. -func (o OperationDisplay) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type EvidenceProperties. +func (e EvidenceProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "description", o.Description) - populate(objectMap, "operation", o.Operation) - populate(objectMap, "provider", o.Provider) - populate(objectMap, "resource", o.Resource) + populate(objectMap, "controlId", e.ControlID) + populate(objectMap, "evidenceType", e.EvidenceType) + populate(objectMap, "extraData", e.ExtraData) + populate(objectMap, "filePath", e.FilePath) + populate(objectMap, "provisioningState", e.ProvisioningState) + populate(objectMap, "responsibilityId", e.ResponsibilityID) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type OperationDisplay. -func (o *OperationDisplay) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type EvidenceProperties. +func (e *EvidenceProperties) 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) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } for key, val := range rawMsg { var err error switch key { - case "description": - err = unpopulate(val, "Description", &o.Description) + case "controlId": + err = unpopulate(val, "ControlID", &e.ControlID) delete(rawMsg, key) - case "operation": - err = unpopulate(val, "Operation", &o.Operation) + case "evidenceType": + err = unpopulate(val, "EvidenceType", &e.EvidenceType) delete(rawMsg, key) - case "provider": - err = unpopulate(val, "Provider", &o.Provider) + case "extraData": + err = unpopulate(val, "ExtraData", &e.ExtraData) delete(rawMsg, key) - case "resource": - err = unpopulate(val, "Resource", &o.Resource) + case "filePath": + err = unpopulate(val, "FilePath", &e.FilePath) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &e.ProvisioningState) + delete(rawMsg, key) + case "responsibilityId": + err = unpopulate(val, "ResponsibilityID", &e.ResponsibilityID) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", o, err) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type OperationListResult. -func (o OperationListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type EvidenceResource. +func (e EvidenceResource) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "nextLink", o.NextLink) - populate(objectMap, "value", o.Value) + populate(objectMap, "id", e.ID) + populate(objectMap, "name", e.Name) + populate(objectMap, "properties", e.Properties) + populate(objectMap, "systemData", e.SystemData) + populate(objectMap, "type", e.Type) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type OperationListResult. -func (o *OperationListResult) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type EvidenceResource. +func (e *EvidenceResource) 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) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } for key, val := range rawMsg { var err error switch key { - case "nextLink": - err = unpopulate(val, "NextLink", &o.NextLink) + case "id": + err = unpopulate(val, "ID", &e.ID) delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &o.Value) + case "name": + err = unpopulate(val, "Name", &e.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &e.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &e.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &e.Type) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", o, err) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type OverviewStatus. -func (o OverviewStatus) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type EvidenceResourceListResult. +func (e EvidenceResourceListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "failedCount", o.FailedCount) - populate(objectMap, "manualCount", o.ManualCount) - populate(objectMap, "passedCount", o.PassedCount) + populate(objectMap, "nextLink", e.NextLink) + populate(objectMap, "value", e.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type OverviewStatus. -func (o *OverviewStatus) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type EvidenceResourceListResult. +func (e *EvidenceResourceListResult) 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) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } for key, val := range rawMsg { var err error switch key { - case "failedCount": - err = unpopulate(val, "FailedCount", &o.FailedCount) - delete(rawMsg, key) - case "manualCount": - err = unpopulate(val, "ManualCount", &o.ManualCount) + case "nextLink": + err = unpopulate(val, "NextLink", &e.NextLink) delete(rawMsg, key) - case "passedCount": - err = unpopulate(val, "PassedCount", &o.PassedCount) + case "value": + err = unpopulate(val, "Value", &e.Value) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", o, err) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type ReportComplianceStatus. -func (r ReportComplianceStatus) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type GetCollectionCountRequest. +func (g GetCollectionCountRequest) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "m365", r.M365) + populate(objectMap, "type", g.Type) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ReportComplianceStatus. -func (r *ReportComplianceStatus) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type GetCollectionCountRequest. +func (g *GetCollectionCountRequest) 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) + return fmt.Errorf("unmarshalling type %T: %v", g, err) } for key, val := range rawMsg { var err error switch key { - case "m365": - err = unpopulate(val, "M365", &r.M365) + case "type": + err = unpopulate(val, "Type", &g.Type) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) + return fmt.Errorf("unmarshalling type %T: %v", g, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type ReportProperties. -func (r ReportProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type GetCollectionCountResponse. +func (g GetCollectionCountResponse) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "complianceStatus", r.ComplianceStatus) - populate(objectMap, "id", r.ID) - populateDateTimeRFC3339(objectMap, "lastTriggerTime", r.LastTriggerTime) - populateDateTimeRFC3339(objectMap, "nextTriggerTime", r.NextTriggerTime) - populate(objectMap, "offerGuid", r.OfferGUID) - populate(objectMap, "provisioningState", r.ProvisioningState) - populate(objectMap, "reportName", r.ReportName) - populate(objectMap, "resources", r.Resources) - populate(objectMap, "status", r.Status) - populate(objectMap, "subscriptions", r.Subscriptions) - populate(objectMap, "tenantId", r.TenantID) - populate(objectMap, "timeZone", r.TimeZone) - populateDateTimeRFC3339(objectMap, "triggerTime", r.TriggerTime) + populate(objectMap, "count", g.Count) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ReportProperties. -func (r *ReportProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type GetCollectionCountResponse. +func (g *GetCollectionCountResponse) 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) + return fmt.Errorf("unmarshalling type %T: %v", g, err) } for key, val := range rawMsg { var err error switch key { - case "complianceStatus": - err = unpopulate(val, "ComplianceStatus", &r.ComplianceStatus) + case "count": + err = unpopulate(val, "Count", &g.Count) delete(rawMsg, key) - case "id": + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type GetOverviewStatusRequest. +func (g GetOverviewStatusRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "type", g.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GetOverviewStatusRequest. +func (g *GetOverviewStatusRequest) 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 "type": + err = unpopulate(val, "Type", &g.Type) + 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 GetOverviewStatusResponse. +func (g GetOverviewStatusResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "statusList", g.StatusList) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GetOverviewStatusResponse. +func (g *GetOverviewStatusResponse) 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 "statusList": + err = unpopulate(val, "StatusList", &g.StatusList) + 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 ListInUseStorageAccountsRequest. +func (l ListInUseStorageAccountsRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "subscriptionIds", l.SubscriptionIDs) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ListInUseStorageAccountsRequest. +func (l *ListInUseStorageAccountsRequest) 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", l, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "subscriptionIds": + err = unpopulate(val, "SubscriptionIDs", &l.SubscriptionIDs) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ListInUseStorageAccountsResponse. +func (l ListInUseStorageAccountsResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "storageAccountList", l.StorageAccountList) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ListInUseStorageAccountsResponse. +func (l *ListInUseStorageAccountsResponse) 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", l, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "storageAccountList": + err = unpopulate(val, "StorageAccountList", &l.StorageAccountList) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OnboardRequest. +func (o OnboardRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "subscriptionIds", o.SubscriptionIDs) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OnboardRequest. +func (o *OnboardRequest) 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 "subscriptionIds": + err = unpopulate(val, "SubscriptionIDs", &o.SubscriptionIDs) + 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 OnboardResponse. +func (o OnboardResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "subscriptionIds", o.SubscriptionIDs) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OnboardResponse. +func (o *OnboardResponse) 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 "subscriptionIds": + err = unpopulate(val, "SubscriptionIDs", &o.SubscriptionIDs) + 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 Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "actionType", o.ActionType) + populate(objectMap, "display", o.Display) + populate(objectMap, "isDataAction", o.IsDataAction) + populate(objectMap, "name", o.Name) + populate(objectMap, "origin", o.Origin) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Operation. +func (o *Operation) 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 "actionType": + err = unpopulate(val, "ActionType", &o.ActionType) + delete(rawMsg, key) + case "display": + err = unpopulate(val, "Display", &o.Display) + delete(rawMsg, key) + case "isDataAction": + err = unpopulate(val, "IsDataAction", &o.IsDataAction) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + case "origin": + err = unpopulate(val, "Origin", &o.Origin) + 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 OperationDisplay. +func (o OperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", o.Description) + populate(objectMap, "operation", o.Operation) + populate(objectMap, "provider", o.Provider) + populate(objectMap, "resource", o.Resource) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationDisplay. +func (o *OperationDisplay) 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 "description": + err = unpopulate(val, "Description", &o.Description) + delete(rawMsg, key) + case "operation": + err = unpopulate(val, "Operation", &o.Operation) + delete(rawMsg, key) + case "provider": + err = unpopulate(val, "Provider", &o.Provider) + delete(rawMsg, key) + case "resource": + err = unpopulate(val, "Resource", &o.Resource) + 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 OperationListResult. +func (o OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationListResult. +func (o *OperationListResult) 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 "nextLink": + err = unpopulate(val, "NextLink", &o.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &o.Value) + 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 OverviewStatus. +func (o OverviewStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "failedCount", o.FailedCount) + populate(objectMap, "manualCount", o.ManualCount) + populate(objectMap, "notApplicableCount", o.NotApplicableCount) + populate(objectMap, "passedCount", o.PassedCount) + populate(objectMap, "pendingCount", o.PendingCount) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OverviewStatus. +func (o *OverviewStatus) 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 "failedCount": + err = unpopulate(val, "FailedCount", &o.FailedCount) + delete(rawMsg, key) + case "manualCount": + err = unpopulate(val, "ManualCount", &o.ManualCount) + delete(rawMsg, key) + case "notApplicableCount": + err = unpopulate(val, "NotApplicableCount", &o.NotApplicableCount) + delete(rawMsg, key) + case "passedCount": + err = unpopulate(val, "PassedCount", &o.PassedCount) + delete(rawMsg, key) + case "pendingCount": + err = unpopulate(val, "PendingCount", &o.PendingCount) + 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 QuickAssessment. +func (q QuickAssessment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", q.Description) + populate(objectMap, "displayName", q.DisplayName) + populate(objectMap, "remediationLink", q.RemediationLink) + populate(objectMap, "resourceId", q.ResourceID) + populate(objectMap, "resourceStatus", q.ResourceStatus) + populate(objectMap, "responsibilityId", q.ResponsibilityID) + populateDateTimeRFC3339(objectMap, "timestamp", q.Timestamp) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type QuickAssessment. +func (q *QuickAssessment) 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", q, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &q.Description) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &q.DisplayName) + delete(rawMsg, key) + case "remediationLink": + err = unpopulate(val, "RemediationLink", &q.RemediationLink) + delete(rawMsg, key) + case "resourceId": + err = unpopulate(val, "ResourceID", &q.ResourceID) + delete(rawMsg, key) + case "resourceStatus": + err = unpopulate(val, "ResourceStatus", &q.ResourceStatus) + delete(rawMsg, key) + case "responsibilityId": + err = unpopulate(val, "ResponsibilityID", &q.ResponsibilityID) + delete(rawMsg, key) + case "timestamp": + err = unpopulateDateTimeRFC3339(val, "Timestamp", &q.Timestamp) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", q, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Recommendation. +func (r Recommendation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "recommendationId", r.RecommendationID) + populate(objectMap, "recommendationShortName", r.RecommendationShortName) + populate(objectMap, "recommendationSolutions", r.RecommendationSolutions) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Recommendation. +func (r *Recommendation) 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 "recommendationId": + err = unpopulate(val, "RecommendationID", &r.RecommendationID) + delete(rawMsg, key) + case "recommendationShortName": + err = unpopulate(val, "RecommendationShortName", &r.RecommendationShortName) + delete(rawMsg, key) + case "recommendationSolutions": + err = unpopulate(val, "RecommendationSolutions", &r.RecommendationSolutions) + 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 RecommendationSolution. +func (r RecommendationSolution) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "isRecommendSolution", r.IsRecommendSolution) + populate(objectMap, "recommendationSolutionContent", r.RecommendationSolutionContent) + populate(objectMap, "recommendationSolutionIndex", r.RecommendationSolutionIndex) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RecommendationSolution. +func (r *RecommendationSolution) 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 "isRecommendSolution": + err = unpopulate(val, "IsRecommendSolution", &r.IsRecommendSolution) + delete(rawMsg, key) + case "recommendationSolutionContent": + err = unpopulate(val, "RecommendationSolutionContent", &r.RecommendationSolutionContent) + delete(rawMsg, key) + case "recommendationSolutionIndex": + err = unpopulate(val, "RecommendationSolutionIndex", &r.RecommendationSolutionIndex) + 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 ReportComplianceStatus. +func (r ReportComplianceStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "m365", r.M365) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReportComplianceStatus. +func (r *ReportComplianceStatus) 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 "m365": + err = unpopulate(val, "M365", &r.M365) + 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 ReportFixResult. +func (r ReportFixResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "reason", r.Reason) + populate(objectMap, "result", r.Result) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReportFixResult. +func (r *ReportFixResult) 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 "reason": + err = unpopulate(val, "Reason", &r.Reason) + delete(rawMsg, key) + case "result": + err = unpopulate(val, "Result", &r.Result) + 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 ReportPatchProperties. +func (r ReportPatchProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "certRecords", r.CertRecords) + populate(objectMap, "complianceStatus", r.ComplianceStatus) + populate(objectMap, "errors", r.Errors) + populateDateTimeRFC3339(objectMap, "lastTriggerTime", r.LastTriggerTime) + populateDateTimeRFC3339(objectMap, "nextTriggerTime", r.NextTriggerTime) + populate(objectMap, "offerGuid", r.OfferGUID) + populate(objectMap, "provisioningState", r.ProvisioningState) + populate(objectMap, "resources", r.Resources) + populate(objectMap, "status", r.Status) + populate(objectMap, "storageInfo", r.StorageInfo) + populate(objectMap, "subscriptions", r.Subscriptions) + populate(objectMap, "tenantId", r.TenantID) + populate(objectMap, "timeZone", r.TimeZone) + populateDateTimeRFC3339(objectMap, "triggerTime", r.TriggerTime) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReportPatchProperties. +func (r *ReportPatchProperties) 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 "certRecords": + err = unpopulate(val, "CertRecords", &r.CertRecords) + delete(rawMsg, key) + case "complianceStatus": + err = unpopulate(val, "ComplianceStatus", &r.ComplianceStatus) + delete(rawMsg, key) + case "errors": + err = unpopulate(val, "Errors", &r.Errors) + delete(rawMsg, key) + case "lastTriggerTime": + err = unpopulateDateTimeRFC3339(val, "LastTriggerTime", &r.LastTriggerTime) + delete(rawMsg, key) + case "nextTriggerTime": + err = unpopulateDateTimeRFC3339(val, "NextTriggerTime", &r.NextTriggerTime) + delete(rawMsg, key) + case "offerGuid": + err = unpopulate(val, "OfferGUID", &r.OfferGUID) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &r.ProvisioningState) + delete(rawMsg, key) + case "resources": + err = unpopulate(val, "Resources", &r.Resources) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &r.Status) + delete(rawMsg, key) + case "storageInfo": + err = unpopulate(val, "StorageInfo", &r.StorageInfo) + delete(rawMsg, key) + case "subscriptions": + err = unpopulate(val, "Subscriptions", &r.Subscriptions) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &r.TenantID) + delete(rawMsg, key) + case "timeZone": + err = unpopulate(val, "TimeZone", &r.TimeZone) + delete(rawMsg, key) + case "triggerTime": + err = unpopulateDateTimeRFC3339(val, "TriggerTime", &r.TriggerTime) + 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 ReportProperties. +func (r ReportProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "certRecords", r.CertRecords) + populate(objectMap, "complianceStatus", r.ComplianceStatus) + populate(objectMap, "errors", r.Errors) + populateDateTimeRFC3339(objectMap, "lastTriggerTime", r.LastTriggerTime) + populateDateTimeRFC3339(objectMap, "nextTriggerTime", r.NextTriggerTime) + populate(objectMap, "offerGuid", r.OfferGUID) + populate(objectMap, "provisioningState", r.ProvisioningState) + populate(objectMap, "resources", r.Resources) + populate(objectMap, "status", r.Status) + populate(objectMap, "storageInfo", r.StorageInfo) + populate(objectMap, "subscriptions", r.Subscriptions) + populate(objectMap, "tenantId", r.TenantID) + populate(objectMap, "timeZone", r.TimeZone) + populateDateTimeRFC3339(objectMap, "triggerTime", r.TriggerTime) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReportProperties. +func (r *ReportProperties) 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 "certRecords": + err = unpopulate(val, "CertRecords", &r.CertRecords) + delete(rawMsg, key) + case "complianceStatus": + err = unpopulate(val, "ComplianceStatus", &r.ComplianceStatus) + delete(rawMsg, key) + case "errors": + err = unpopulate(val, "Errors", &r.Errors) + delete(rawMsg, key) + case "lastTriggerTime": + err = unpopulateDateTimeRFC3339(val, "LastTriggerTime", &r.LastTriggerTime) + delete(rawMsg, key) + case "nextTriggerTime": + err = unpopulateDateTimeRFC3339(val, "NextTriggerTime", &r.NextTriggerTime) + delete(rawMsg, key) + case "offerGuid": + err = unpopulate(val, "OfferGUID", &r.OfferGUID) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &r.ProvisioningState) + delete(rawMsg, key) + case "resources": + err = unpopulate(val, "Resources", &r.Resources) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &r.Status) + delete(rawMsg, key) + case "storageInfo": + err = unpopulate(val, "StorageInfo", &r.StorageInfo) + delete(rawMsg, key) + case "subscriptions": + err = unpopulate(val, "Subscriptions", &r.Subscriptions) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &r.TenantID) + delete(rawMsg, key) + case "timeZone": + err = unpopulate(val, "TimeZone", &r.TimeZone) + delete(rawMsg, key) + case "triggerTime": + err = unpopulateDateTimeRFC3339(val, "TriggerTime", &r.TriggerTime) + 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 ReportResource. +func (r ReportResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "properties", r.Properties) + populate(objectMap, "systemData", r.SystemData) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReportResource. +func (r *ReportResource) 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 "id": err = unpopulate(val, "ID", &r.ID) delete(rawMsg, key) - case "lastTriggerTime": - err = unpopulateDateTimeRFC3339(val, "LastTriggerTime", &r.LastTriggerTime) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &r.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &r.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &r.Type) + 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 ReportResourceListResult. +func (r ReportResourceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", r.NextLink) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReportResourceListResult. +func (r *ReportResourceListResult) 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 "nextLink": + err = unpopulate(val, "NextLink", &r.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &r.Value) + 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 ReportResourcePatch. +func (r ReportResourcePatch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", r.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReportResourcePatch. +func (r *ReportResourcePatch) 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 "properties": + err = unpopulate(val, "Properties", &r.Properties) + 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 ReportVerificationResult. +func (r ReportVerificationResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "reason", r.Reason) + populate(objectMap, "result", r.Result) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReportVerificationResult. +func (r *ReportVerificationResult) 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 "reason": + err = unpopulate(val, "Reason", &r.Reason) + delete(rawMsg, key) + case "result": + err = unpopulate(val, "Result", &r.Result) + 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 ResourceItem. +func (r ResourceItem) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "resourceGroup", r.ResourceGroup) + populate(objectMap, "resourceId", r.ResourceID) + populate(objectMap, "resourceType", r.ResourceType) + populate(objectMap, "subscriptionId", r.SubscriptionID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceItem. +func (r *ResourceItem) 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 "resourceGroup": + err = unpopulate(val, "ResourceGroup", &r.ResourceGroup) + delete(rawMsg, key) + case "resourceId": + err = unpopulate(val, "ResourceID", &r.ResourceID) + delete(rawMsg, key) + case "resourceType": + err = unpopulate(val, "ResourceType", &r.ResourceType) + delete(rawMsg, key) + case "subscriptionId": + err = unpopulate(val, "SubscriptionID", &r.SubscriptionID) + 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 ResourceMetadata. +func (r ResourceMetadata) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "accountId", r.AccountID) + populate(objectMap, "resourceId", r.ResourceID) + populate(objectMap, "resourceKind", r.ResourceKind) + populate(objectMap, "resourceOrigin", r.ResourceOrigin) + populate(objectMap, "resourceType", r.ResourceType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceMetadata. +func (r *ResourceMetadata) 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 "accountId": + err = unpopulate(val, "AccountID", &r.AccountID) + delete(rawMsg, key) + case "resourceId": + err = unpopulate(val, "ResourceID", &r.ResourceID) + delete(rawMsg, key) + case "resourceKind": + err = unpopulate(val, "ResourceKind", &r.ResourceKind) + delete(rawMsg, key) + case "resourceOrigin": + err = unpopulate(val, "ResourceOrigin", &r.ResourceOrigin) + delete(rawMsg, key) + case "resourceType": + err = unpopulate(val, "ResourceType", &r.ResourceType) + 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 Responsibility. +func (r Responsibility) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "evidenceFiles", r.EvidenceFiles) + populate(objectMap, "failedResourceCount", r.FailedResourceCount) + populate(objectMap, "guidance", r.Guidance) + populate(objectMap, "justification", r.Justification) + populate(objectMap, "recommendationList", r.RecommendationList) + populate(objectMap, "resourceList", r.ResourceList) + populate(objectMap, "responsibilityDescription", r.ResponsibilityDescription) + populate(objectMap, "responsibilityEnvironment", r.ResponsibilityEnvironment) + populate(objectMap, "responsibilityId", r.ResponsibilityID) + populate(objectMap, "responsibilitySeverity", r.ResponsibilitySeverity) + populate(objectMap, "responsibilityStatus", r.ResponsibilityStatus) + populate(objectMap, "responsibilityTitle", r.ResponsibilityTitle) + populate(objectMap, "responsibilityType", r.ResponsibilityType) + populate(objectMap, "totalResourceCount", r.TotalResourceCount) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Responsibility. +func (r *Responsibility) 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 "evidenceFiles": + err = unpopulate(val, "EvidenceFiles", &r.EvidenceFiles) + delete(rawMsg, key) + case "failedResourceCount": + err = unpopulate(val, "FailedResourceCount", &r.FailedResourceCount) + delete(rawMsg, key) + case "guidance": + err = unpopulate(val, "Guidance", &r.Guidance) + delete(rawMsg, key) + case "justification": + err = unpopulate(val, "Justification", &r.Justification) + delete(rawMsg, key) + case "recommendationList": + err = unpopulate(val, "RecommendationList", &r.RecommendationList) + delete(rawMsg, key) + case "resourceList": + err = unpopulate(val, "ResourceList", &r.ResourceList) + delete(rawMsg, key) + case "responsibilityDescription": + err = unpopulate(val, "ResponsibilityDescription", &r.ResponsibilityDescription) + delete(rawMsg, key) + case "responsibilityEnvironment": + err = unpopulate(val, "ResponsibilityEnvironment", &r.ResponsibilityEnvironment) + delete(rawMsg, key) + case "responsibilityId": + err = unpopulate(val, "ResponsibilityID", &r.ResponsibilityID) + delete(rawMsg, key) + case "responsibilitySeverity": + err = unpopulate(val, "ResponsibilitySeverity", &r.ResponsibilitySeverity) + delete(rawMsg, key) + case "responsibilityStatus": + err = unpopulate(val, "ResponsibilityStatus", &r.ResponsibilityStatus) + delete(rawMsg, key) + case "responsibilityTitle": + err = unpopulate(val, "ResponsibilityTitle", &r.ResponsibilityTitle) + delete(rawMsg, key) + case "responsibilityType": + err = unpopulate(val, "ResponsibilityType", &r.ResponsibilityType) + delete(rawMsg, key) + case "totalResourceCount": + err = unpopulate(val, "TotalResourceCount", &r.TotalResourceCount) + 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 ResponsibilityResource. +func (r ResponsibilityResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "accountId", r.AccountID) + populate(objectMap, "recommendationIds", r.RecommendationIDs) + populate(objectMap, "resourceId", r.ResourceID) + populate(objectMap, "resourceOrigin", r.ResourceOrigin) + populate(objectMap, "resourceStatus", r.ResourceStatus) + populateDateTimeRFC3339(objectMap, "resourceStatusChangeDate", r.ResourceStatusChangeDate) + populate(objectMap, "resourceType", r.ResourceType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResponsibilityResource. +func (r *ResponsibilityResource) 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 "accountId": + err = unpopulate(val, "AccountID", &r.AccountID) + delete(rawMsg, key) + case "recommendationIds": + err = unpopulate(val, "RecommendationIDs", &r.RecommendationIDs) + delete(rawMsg, key) + case "resourceId": + err = unpopulate(val, "ResourceID", &r.ResourceID) + delete(rawMsg, key) + case "resourceOrigin": + err = unpopulate(val, "ResourceOrigin", &r.ResourceOrigin) + delete(rawMsg, key) + case "resourceStatus": + err = unpopulate(val, "ResourceStatus", &r.ResourceStatus) + delete(rawMsg, key) + case "resourceStatusChangeDate": + err = unpopulateDateTimeRFC3339(val, "ResourceStatusChangeDate", &r.ResourceStatusChangeDate) + delete(rawMsg, key) + case "resourceType": + err = unpopulate(val, "ResourceType", &r.ResourceType) + 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 ScopingAnswer. +func (s ScopingAnswer) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "answers", s.Answers) + populate(objectMap, "questionId", s.QuestionID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ScopingAnswer. +func (s *ScopingAnswer) 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 "answers": + err = unpopulate(val, "Answers", &s.Answers) + delete(rawMsg, key) + case "questionId": + err = unpopulate(val, "QuestionID", &s.QuestionID) + 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 ScopingConfigurationProperties. +func (s ScopingConfigurationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "answers", s.Answers) + populate(objectMap, "provisioningState", s.ProvisioningState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ScopingConfigurationProperties. +func (s *ScopingConfigurationProperties) 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 "answers": + err = unpopulate(val, "Answers", &s.Answers) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &s.ProvisioningState) + 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 ScopingConfigurationResource. +func (s ScopingConfigurationResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", s.ID) + populate(objectMap, "name", s.Name) + populate(objectMap, "properties", s.Properties) + populate(objectMap, "systemData", s.SystemData) + populate(objectMap, "type", s.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ScopingConfigurationResource. +func (s *ScopingConfigurationResource) 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 "id": + err = unpopulate(val, "ID", &s.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &s.Name) delete(rawMsg, key) - case "nextTriggerTime": - err = unpopulateDateTimeRFC3339(val, "NextTriggerTime", &r.NextTriggerTime) + case "properties": + err = unpopulate(val, "Properties", &s.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &s.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &s.Type) + 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 ScopingConfigurationResourceListResult. +func (s ScopingConfigurationResourceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", s.NextLink) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ScopingConfigurationResourceListResult. +func (s *ScopingConfigurationResourceListResult) 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 "nextLink": + err = unpopulate(val, "NextLink", &s.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &s.Value) + 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 ScopingQuestion. +func (s ScopingQuestion) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "inputType", s.InputType) + populate(objectMap, "optionIds", s.OptionIDs) + populate(objectMap, "questionId", s.QuestionID) + populate(objectMap, "rules", s.Rules) + populate(objectMap, "showSubQuestionsValue", s.ShowSubQuestionsValue) + populate(objectMap, "superiorQuestionId", s.SuperiorQuestionID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ScopingQuestion. +func (s *ScopingQuestion) 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 "inputType": + err = unpopulate(val, "InputType", &s.InputType) + delete(rawMsg, key) + case "optionIds": + err = unpopulate(val, "OptionIDs", &s.OptionIDs) + delete(rawMsg, key) + case "questionId": + err = unpopulate(val, "QuestionID", &s.QuestionID) + delete(rawMsg, key) + case "rules": + err = unpopulate(val, "Rules", &s.Rules) + delete(rawMsg, key) + case "showSubQuestionsValue": + err = unpopulate(val, "ShowSubQuestionsValue", &s.ShowSubQuestionsValue) + delete(rawMsg, key) + case "superiorQuestionId": + err = unpopulate(val, "SuperiorQuestionID", &s.SuperiorQuestionID) + 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 ScopingQuestions. +func (s ScopingQuestions) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "questions", s.Questions) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ScopingQuestions. +func (s *ScopingQuestions) 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 "questions": + err = unpopulate(val, "Questions", &s.Questions) + 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 SnapshotDownloadRequest. +func (s SnapshotDownloadRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "downloadType", s.DownloadType) + populate(objectMap, "offerGuid", s.OfferGUID) + populate(objectMap, "reportCreatorTenantId", s.ReportCreatorTenantID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SnapshotDownloadRequest. +func (s *SnapshotDownloadRequest) 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 "downloadType": + err = unpopulate(val, "DownloadType", &s.DownloadType) delete(rawMsg, key) case "offerGuid": - err = unpopulate(val, "OfferGUID", &r.OfferGUID) + err = unpopulate(val, "OfferGUID", &s.OfferGUID) + delete(rawMsg, key) + case "reportCreatorTenantId": + err = unpopulate(val, "ReportCreatorTenantID", &s.ReportCreatorTenantID) + 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 SnapshotProperties. +func (s SnapshotProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "complianceResults", s.ComplianceResults) + populateDateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "provisioningState", s.ProvisioningState) + populate(objectMap, "reportProperties", s.ReportProperties) + populate(objectMap, "reportSystemData", s.ReportSystemData) + populate(objectMap, "snapshotName", s.SnapshotName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SnapshotProperties. +func (s *SnapshotProperties) 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 "complianceResults": + err = unpopulate(val, "ComplianceResults", &s.ComplianceResults) + delete(rawMsg, key) + case "createdAt": + err = unpopulateDateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) delete(rawMsg, key) case "provisioningState": - err = unpopulate(val, "ProvisioningState", &r.ProvisioningState) + err = unpopulate(val, "ProvisioningState", &s.ProvisioningState) delete(rawMsg, key) - case "reportName": - err = unpopulate(val, "ReportName", &r.ReportName) + case "reportProperties": + err = unpopulate(val, "ReportProperties", &s.ReportProperties) delete(rawMsg, key) - case "resources": - err = unpopulate(val, "Resources", &r.Resources) + case "reportSystemData": + err = unpopulate(val, "ReportSystemData", &s.ReportSystemData) delete(rawMsg, key) - case "status": - err = unpopulate(val, "Status", &r.Status) + case "snapshotName": + err = unpopulate(val, "SnapshotName", &s.SnapshotName) delete(rawMsg, key) - case "subscriptions": - err = unpopulate(val, "Subscriptions", &r.Subscriptions) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SnapshotResource. +func (s SnapshotResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", s.ID) + populate(objectMap, "name", s.Name) + populate(objectMap, "properties", s.Properties) + populate(objectMap, "systemData", s.SystemData) + populate(objectMap, "type", s.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SnapshotResource. +func (s *SnapshotResource) 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 "id": + err = unpopulate(val, "ID", &s.ID) delete(rawMsg, key) - case "tenantId": - err = unpopulate(val, "TenantID", &r.TenantID) + case "name": + err = unpopulate(val, "Name", &s.Name) delete(rawMsg, key) - case "timeZone": - err = unpopulate(val, "TimeZone", &r.TimeZone) + case "properties": + err = unpopulate(val, "Properties", &s.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &s.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &s.Type) + 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 SnapshotResourceListResult. +func (s SnapshotResourceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", s.NextLink) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SnapshotResourceListResult. +func (s *SnapshotResourceListResult) 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 "nextLink": + err = unpopulate(val, "NextLink", &s.NextLink) delete(rawMsg, key) - case "triggerTime": - err = unpopulateDateTimeRFC3339(val, "TriggerTime", &r.TriggerTime) + case "value": + err = unpopulate(val, "Value", &s.Value) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) + return fmt.Errorf("unmarshalling type %T: %v", s, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type ReportResource. -func (r ReportResource) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type StatusItem. +func (s StatusItem) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "id", r.ID) - populate(objectMap, "name", r.Name) - populate(objectMap, "properties", r.Properties) - populate(objectMap, "systemData", r.SystemData) - populate(objectMap, "type", r.Type) + populate(objectMap, "statusName", s.StatusName) + populate(objectMap, "statusValue", s.StatusValue) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ReportResource. -func (r *ReportResource) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type StatusItem. +func (s *StatusItem) 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) + return fmt.Errorf("unmarshalling type %T: %v", s, err) } for key, val := range rawMsg { var err error switch key { - case "id": - err = unpopulate(val, "ID", &r.ID) + case "statusName": + err = unpopulate(val, "StatusName", &s.StatusName) delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &r.Name) + case "statusValue": + err = unpopulate(val, "StatusValue", &s.StatusValue) delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &r.Properties) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type StorageInfo. +func (s StorageInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "accountName", s.AccountName) + populate(objectMap, "location", s.Location) + populate(objectMap, "resourceGroup", s.ResourceGroup) + populate(objectMap, "subscriptionId", s.SubscriptionID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StorageInfo. +func (s *StorageInfo) 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 "accountName": + err = unpopulate(val, "AccountName", &s.AccountName) delete(rawMsg, key) - case "systemData": - err = unpopulate(val, "SystemData", &r.SystemData) + case "location": + err = unpopulate(val, "Location", &s.Location) delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &r.Type) + case "resourceGroup": + err = unpopulate(val, "ResourceGroup", &s.ResourceGroup) + delete(rawMsg, key) + case "subscriptionId": + err = unpopulate(val, "SubscriptionID", &s.SubscriptionID) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) + return fmt.Errorf("unmarshalling type %T: %v", s, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type ReportResourceList. -func (r ReportResourceList) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type SyncCertRecordRequest. +func (s SyncCertRecordRequest) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "nextLink", r.NextLink) - populate(objectMap, "value", r.Value) + populate(objectMap, "certRecord", s.CertRecord) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ReportResourceList. -func (r *ReportResourceList) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type SyncCertRecordRequest. +func (s *SyncCertRecordRequest) 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) + return fmt.Errorf("unmarshalling type %T: %v", s, err) } for key, val := range rawMsg { var err error switch key { - case "nextLink": - err = unpopulate(val, "NextLink", &r.NextLink) - delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &r.Value) + case "certRecord": + err = unpopulate(val, "CertRecord", &s.CertRecord) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) + return fmt.Errorf("unmarshalling type %T: %v", s, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type ReportResourcePatch. -func (r ReportResourcePatch) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type SyncCertRecordResponse. +func (s SyncCertRecordResponse) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "properties", r.Properties) + populate(objectMap, "certRecord", s.CertRecord) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ReportResourcePatch. -func (r *ReportResourcePatch) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type SyncCertRecordResponse. +func (s *SyncCertRecordResponse) 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) + return fmt.Errorf("unmarshalling type %T: %v", s, err) } for key, val := range rawMsg { var err error switch key { - case "properties": - err = unpopulate(val, "Properties", &r.Properties) + case "certRecord": + err = unpopulate(val, "CertRecord", &s.CertRecord) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) + return fmt.Errorf("unmarshalling type %T: %v", s, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type ResourceItem. -func (r ResourceItem) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "resourceGroup", r.ResourceGroup) - populate(objectMap, "resourceId", r.ResourceID) - populate(objectMap, "resourceType", r.ResourceType) - populate(objectMap, "subscriptionId", r.SubscriptionID) + populateDateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateDateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populate(objectMap, "lastModifiedBy", s.LastModifiedBy) + populate(objectMap, "lastModifiedByType", s.LastModifiedByType) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceItem. -func (r *ResourceItem) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. +func (s *SystemData) 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) + return fmt.Errorf("unmarshalling type %T: %v", s, err) } for key, val := range rawMsg { var err error switch key { - case "resourceGroup": - err = unpopulate(val, "ResourceGroup", &r.ResourceGroup) + case "createdAt": + err = unpopulateDateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) delete(rawMsg, key) - case "resourceId": - err = unpopulate(val, "ResourceID", &r.ResourceID) + case "createdBy": + err = unpopulate(val, "CreatedBy", &s.CreatedBy) delete(rawMsg, key) - case "resourceType": - err = unpopulate(val, "ResourceType", &r.ResourceType) + case "createdByType": + err = unpopulate(val, "CreatedByType", &s.CreatedByType) delete(rawMsg, key) - case "subscriptionId": - err = unpopulate(val, "SubscriptionID", &r.SubscriptionID) + case "lastModifiedAt": + err = unpopulateDateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) + return fmt.Errorf("unmarshalling type %T: %v", s, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type ResourceMetadata. -func (r ResourceMetadata) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type TriggerEvaluationProperty. +func (t TriggerEvaluationProperty) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "resourceId", r.ResourceID) - populate(objectMap, "resourceKind", r.ResourceKind) - populate(objectMap, "resourceName", r.ResourceName) - populate(objectMap, "resourceType", r.ResourceType) - populate(objectMap, "tags", r.Tags) + populateDateTimeRFC3339(objectMap, "evaluationEndTime", t.EvaluationEndTime) + populate(objectMap, "quickAssessments", t.QuickAssessments) + populate(objectMap, "resourceIds", t.ResourceIDs) + populateDateTimeRFC3339(objectMap, "triggerTime", t.TriggerTime) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceMetadata. -func (r *ResourceMetadata) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type TriggerEvaluationProperty. +func (t *TriggerEvaluationProperty) 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) + return fmt.Errorf("unmarshalling type %T: %v", t, err) } for key, val := range rawMsg { var err error switch key { - case "resourceId": - err = unpopulate(val, "ResourceID", &r.ResourceID) - delete(rawMsg, key) - case "resourceKind": - err = unpopulate(val, "ResourceKind", &r.ResourceKind) + case "evaluationEndTime": + err = unpopulateDateTimeRFC3339(val, "EvaluationEndTime", &t.EvaluationEndTime) delete(rawMsg, key) - case "resourceName": - err = unpopulate(val, "ResourceName", &r.ResourceName) + case "quickAssessments": + err = unpopulate(val, "QuickAssessments", &t.QuickAssessments) delete(rawMsg, key) - case "resourceType": - err = unpopulate(val, "ResourceType", &r.ResourceType) + case "resourceIds": + err = unpopulate(val, "ResourceIDs", &t.ResourceIDs) delete(rawMsg, key) - case "tags": - err = unpopulate(val, "Tags", &r.Tags) + case "triggerTime": + err = unpopulateDateTimeRFC3339(val, "TriggerTime", &t.TriggerTime) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) + return fmt.Errorf("unmarshalling type %T: %v", t, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type SnapshotDownloadRequest. -func (s SnapshotDownloadRequest) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type TriggerEvaluationRequest. +func (t TriggerEvaluationRequest) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "downloadType", s.DownloadType) - populate(objectMap, "offerGuid", s.OfferGUID) - populate(objectMap, "reportCreatorTenantId", s.ReportCreatorTenantID) + populate(objectMap, "resourceIds", t.ResourceIDs) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type SnapshotDownloadRequest. -func (s *SnapshotDownloadRequest) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type TriggerEvaluationRequest. +func (t *TriggerEvaluationRequest) 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) + return fmt.Errorf("unmarshalling type %T: %v", t, err) } for key, val := range rawMsg { var err error switch key { - case "downloadType": - err = unpopulate(val, "DownloadType", &s.DownloadType) - delete(rawMsg, key) - case "offerGuid": - err = unpopulate(val, "OfferGUID", &s.OfferGUID) + case "resourceIds": + err = unpopulate(val, "ResourceIDs", &t.ResourceIDs) delete(rawMsg, key) - case "reportCreatorTenantId": - err = unpopulate(val, "ReportCreatorTenantID", &s.ReportCreatorTenantID) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TriggerEvaluationResponse. +func (t TriggerEvaluationResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", t.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TriggerEvaluationResponse. +func (t *TriggerEvaluationResponse) 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", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &t.Properties) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) + return fmt.Errorf("unmarshalling type %T: %v", t, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type SnapshotProperties. -func (s SnapshotProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type WebhookProperties. +func (w WebhookProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "complianceResults", s.ComplianceResults) - populateDateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) - populate(objectMap, "id", s.ID) - populate(objectMap, "provisioningState", s.ProvisioningState) - populate(objectMap, "reportProperties", s.ReportProperties) - populate(objectMap, "reportSystemData", s.ReportSystemData) - populate(objectMap, "snapshotName", s.SnapshotName) + populate(objectMap, "contentType", w.ContentType) + populate(objectMap, "deliveryStatus", w.DeliveryStatus) + populate(objectMap, "enableSslVerification", w.EnableSSLVerification) + populate(objectMap, "events", w.Events) + populate(objectMap, "payloadUrl", w.PayloadURL) + populate(objectMap, "provisioningState", w.ProvisioningState) + populate(objectMap, "sendAllEvents", w.SendAllEvents) + populate(objectMap, "status", w.Status) + populate(objectMap, "tenantId", w.TenantID) + populate(objectMap, "updateWebhookKey", w.UpdateWebhookKey) + populate(objectMap, "webhookId", w.WebhookID) + populate(objectMap, "webhookKey", w.WebhookKey) + populate(objectMap, "webhookKeyEnabled", w.WebhookKeyEnabled) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type SnapshotProperties. -func (s *SnapshotProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type WebhookProperties. +func (w *WebhookProperties) 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) + return fmt.Errorf("unmarshalling type %T: %v", w, err) } for key, val := range rawMsg { var err error switch key { - case "complianceResults": - err = unpopulate(val, "ComplianceResults", &s.ComplianceResults) + case "contentType": + err = unpopulate(val, "ContentType", &w.ContentType) delete(rawMsg, key) - case "createdAt": - err = unpopulateDateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) + case "deliveryStatus": + err = unpopulate(val, "DeliveryStatus", &w.DeliveryStatus) delete(rawMsg, key) - case "id": - err = unpopulate(val, "ID", &s.ID) + case "enableSslVerification": + err = unpopulate(val, "EnableSSLVerification", &w.EnableSSLVerification) + delete(rawMsg, key) + case "events": + err = unpopulate(val, "Events", &w.Events) + delete(rawMsg, key) + case "payloadUrl": + err = unpopulate(val, "PayloadURL", &w.PayloadURL) delete(rawMsg, key) case "provisioningState": - err = unpopulate(val, "ProvisioningState", &s.ProvisioningState) + err = unpopulate(val, "ProvisioningState", &w.ProvisioningState) delete(rawMsg, key) - case "reportProperties": - err = unpopulate(val, "ReportProperties", &s.ReportProperties) + case "sendAllEvents": + err = unpopulate(val, "SendAllEvents", &w.SendAllEvents) delete(rawMsg, key) - case "reportSystemData": - err = unpopulate(val, "ReportSystemData", &s.ReportSystemData) + case "status": + err = unpopulate(val, "Status", &w.Status) delete(rawMsg, key) - case "snapshotName": - err = unpopulate(val, "SnapshotName", &s.SnapshotName) + case "tenantId": + err = unpopulate(val, "TenantID", &w.TenantID) + delete(rawMsg, key) + case "updateWebhookKey": + err = unpopulate(val, "UpdateWebhookKey", &w.UpdateWebhookKey) + delete(rawMsg, key) + case "webhookId": + err = unpopulate(val, "WebhookID", &w.WebhookID) + delete(rawMsg, key) + case "webhookKey": + err = unpopulate(val, "WebhookKey", &w.WebhookKey) + delete(rawMsg, key) + case "webhookKeyEnabled": + err = unpopulate(val, "WebhookKeyEnabled", &w.WebhookKeyEnabled) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) + return fmt.Errorf("unmarshalling type %T: %v", w, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type SnapshotResource. -func (s SnapshotResource) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type WebhookResource. +func (w WebhookResource) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "id", s.ID) - populate(objectMap, "name", s.Name) - populate(objectMap, "properties", s.Properties) - populate(objectMap, "systemData", s.SystemData) - populate(objectMap, "type", s.Type) + populate(objectMap, "id", w.ID) + populate(objectMap, "name", w.Name) + populate(objectMap, "properties", w.Properties) + populate(objectMap, "systemData", w.SystemData) + populate(objectMap, "type", w.Type) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type SnapshotResource. -func (s *SnapshotResource) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type WebhookResource. +func (w *WebhookResource) 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) + return fmt.Errorf("unmarshalling type %T: %v", w, err) } for key, val := range rawMsg { var err error switch key { case "id": - err = unpopulate(val, "ID", &s.ID) + err = unpopulate(val, "ID", &w.ID) delete(rawMsg, key) case "name": - err = unpopulate(val, "Name", &s.Name) + err = unpopulate(val, "Name", &w.Name) delete(rawMsg, key) case "properties": - err = unpopulate(val, "Properties", &s.Properties) + err = unpopulate(val, "Properties", &w.Properties) delete(rawMsg, key) case "systemData": - err = unpopulate(val, "SystemData", &s.SystemData) + err = unpopulate(val, "SystemData", &w.SystemData) delete(rawMsg, key) case "type": - err = unpopulate(val, "Type", &s.Type) + err = unpopulate(val, "Type", &w.Type) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) + return fmt.Errorf("unmarshalling type %T: %v", w, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type SnapshotResourceList. -func (s SnapshotResourceList) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type WebhookResourceListResult. +func (w WebhookResourceListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "nextLink", s.NextLink) - populate(objectMap, "value", s.Value) + populate(objectMap, "nextLink", w.NextLink) + populate(objectMap, "value", w.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type SnapshotResourceList. -func (s *SnapshotResourceList) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type WebhookResourceListResult. +func (w *WebhookResourceListResult) 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) + return fmt.Errorf("unmarshalling type %T: %v", w, err) } for key, val := range rawMsg { var err error switch key { case "nextLink": - err = unpopulate(val, "NextLink", &s.NextLink) + err = unpopulate(val, "NextLink", &w.NextLink) delete(rawMsg, key) case "value": - err = unpopulate(val, "Value", &s.Value) + err = unpopulate(val, "Value", &w.Value) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) + return fmt.Errorf("unmarshalling type %T: %v", w, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type SystemData. -func (s SystemData) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type WebhookResourcePatch. +func (w WebhookResourcePatch) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populateDateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) - populate(objectMap, "createdBy", s.CreatedBy) - populate(objectMap, "createdByType", s.CreatedByType) - populateDateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) - populate(objectMap, "lastModifiedBy", s.LastModifiedBy) - populate(objectMap, "lastModifiedByType", s.LastModifiedByType) + populate(objectMap, "properties", w.Properties) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. -func (s *SystemData) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type WebhookResourcePatch. +func (w *WebhookResourcePatch) 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) + return fmt.Errorf("unmarshalling type %T: %v", w, err) } for key, val := range rawMsg { var err error switch key { - case "createdAt": - err = unpopulateDateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) - delete(rawMsg, key) - case "createdBy": - err = unpopulate(val, "CreatedBy", &s.CreatedBy) - delete(rawMsg, key) - case "createdByType": - err = unpopulate(val, "CreatedByType", &s.CreatedByType) - delete(rawMsg, key) - case "lastModifiedAt": - err = unpopulateDateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) - delete(rawMsg, key) - case "lastModifiedBy": - err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) - delete(rawMsg, key) - case "lastModifiedByType": - err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) + case "properties": + err = unpopulate(val, "Properties", &w.Properties) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) + return fmt.Errorf("unmarshalling type %T: %v", w, err) } } return nil @@ -1088,7 +2543,7 @@ func populate(m map[string]any, k string, v any) { } func unpopulate(data json.RawMessage, fn string, v any) error { - if data == nil { + if data == nil || string(data) == "null" { return nil } if err := json.Unmarshal(data, v); err != nil { diff --git a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/operations_client.go b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/operations_client.go index e51a471d438c..4679cac31243 100644 --- a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/operations_client.go +++ b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/operations_client.go @@ -37,9 +37,9 @@ func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientO return client, nil } -// NewListPager - Lists all of the available REST API operations of the Microsoft.AppComplianceAutomation provider. +// NewListPager - List the operations for the provider // -// Generated from API version 2022-11-16-preview +// Generated from API version 2024-06-27 // - 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]{ @@ -72,7 +72,7 @@ func (client *OperationsClient) listCreateRequest(ctx context.Context, options * return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-11-16-preview") + reqQP.Set("api-version", "2024-06-27") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/operations_client_example_test.go b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/operations_client_example_test.go deleted file mode 100644 index cbd1e6760818..000000000000 --- a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/operations_client_example_test.go +++ /dev/null @@ -1,56 +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 armappcomplianceautomation_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/82ea406b73d671269217053d7ef336450d860345/specification/appcomplianceautomation/resource-manager/Microsoft.AppComplianceAutomation/preview/2022-11-16-preview/examples/Operations_List.json -func ExampleOperationsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armappcomplianceautomation.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewOperationsClient().NewListPager(nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.OperationListResult = armappcomplianceautomation.OperationListResult{ - // Value: []*armappcomplianceautomation.Operation{ - // { - // Name: to.Ptr("Microsoft.AppComplianceAutomation/reports/write"), - // Display: &armappcomplianceautomation.OperationDisplay{ - // Description: to.Ptr("Create new reports."), - // Operation: to.Ptr("Microsoft.AppComplianceAutomation/reports/write"), - // Provider: to.Ptr("Microsoft AppComplianceAutomation"), - // Resource: to.Ptr("Microsoft.AppComplianceAutomation/reports"), - // }, - // IsDataAction: to.Ptr(false), - // }}, - // } - } -} diff --git a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/options.go b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/options.go index 83b2d22cd309..9822e7e3f8f1 100644 --- a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/options.go +++ b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/options.go @@ -8,39 +8,148 @@ package armappcomplianceautomation +// EvidencesClientCreateOrUpdateOptions contains the optional parameters for the EvidencesClient.CreateOrUpdate method. +type EvidencesClientCreateOrUpdateOptions struct { + // The offerGuid which mapping to the reports. + OfferGUID *string + + // The tenant id of the report creator. + ReportCreatorTenantID *string +} + +// EvidencesClientDeleteOptions contains the optional parameters for the EvidencesClient.Delete method. +type EvidencesClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// EvidencesClientDownloadOptions contains the optional parameters for the EvidencesClient.Download method. +type EvidencesClientDownloadOptions struct { + // placeholder for future optional parameters +} + +// EvidencesClientGetOptions contains the optional parameters for the EvidencesClient.Get method. +type EvidencesClientGetOptions struct { + // placeholder for future optional parameters +} + +// EvidencesClientListByReportOptions contains the optional parameters for the EvidencesClient.NewListByReportPager method. +type EvidencesClientListByReportOptions struct { + // The filter to apply on the operation. + Filter *string + + // The offerGuid which mapping to the reports. + OfferGUID *string + + // OData order by query option. + Orderby *string + + // The tenant id of the report creator. + ReportCreatorTenantID *string + + // OData Select statement. Limits the properties on each entry to just those requested, e.g. ?$select=reportName,id. + Select *string + + // Skip over when retrieving results. + SkipToken *string + + // Number of elements to return when retrieving results. + Top *int32 +} + // OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. type OperationsClientListOptions struct { // placeholder for future optional parameters } -// ReportClientBeginCreateOrUpdateOptions contains the optional parameters for the ReportClient.BeginCreateOrUpdate method. -type ReportClientBeginCreateOrUpdateOptions struct { +// ProviderActionsClientBeginOnboardOptions contains the optional parameters for the ProviderActionsClient.BeginOnboard method. +type ProviderActionsClientBeginOnboardOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// ProviderActionsClientBeginTriggerEvaluationOptions contains the optional parameters for the ProviderActionsClient.BeginTriggerEvaluation +// method. +type ProviderActionsClientBeginTriggerEvaluationOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// ProviderActionsClientCheckNameAvailabilityOptions contains the optional parameters for the ProviderActionsClient.CheckNameAvailability +// method. +type ProviderActionsClientCheckNameAvailabilityOptions struct { + // placeholder for future optional parameters +} + +// ProviderActionsClientGetCollectionCountOptions contains the optional parameters for the ProviderActionsClient.GetCollectionCount +// method. +type ProviderActionsClientGetCollectionCountOptions struct { + // placeholder for future optional parameters +} + +// ProviderActionsClientGetOverviewStatusOptions contains the optional parameters for the ProviderActionsClient.GetOverviewStatus +// method. +type ProviderActionsClientGetOverviewStatusOptions struct { + // placeholder for future optional parameters +} + +// ProviderActionsClientListInUseStorageAccountsOptions contains the optional parameters for the ProviderActionsClient.ListInUseStorageAccounts +// method. +type ProviderActionsClientListInUseStorageAccountsOptions struct { + // placeholder for future optional parameters +} + +// ReportClientBeginVerifyOptions contains the optional parameters for the ReportClient.BeginVerify method. +type ReportClientBeginVerifyOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// ReportsClientBeginCreateOrUpdateOptions contains the optional parameters for the ReportsClient.BeginCreateOrUpdate method. +type ReportsClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// ReportsClientBeginDeleteOptions contains the optional parameters for the ReportsClient.BeginDelete method. +type ReportsClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// ReportsClientBeginFixOptions contains the optional parameters for the ReportsClient.BeginFix method. +type ReportsClientBeginFixOptions struct { // Resumes the LRO from the provided token. ResumeToken string } -// ReportClientBeginDeleteOptions contains the optional parameters for the ReportClient.BeginDelete method. -type ReportClientBeginDeleteOptions struct { +// ReportsClientBeginSyncCertRecordOptions contains the optional parameters for the ReportsClient.BeginSyncCertRecord method. +type ReportsClientBeginSyncCertRecordOptions struct { // Resumes the LRO from the provided token. ResumeToken string } -// ReportClientBeginUpdateOptions contains the optional parameters for the ReportClient.BeginUpdate method. -type ReportClientBeginUpdateOptions struct { +// ReportsClientBeginUpdateOptions contains the optional parameters for the ReportsClient.BeginUpdate method. +type ReportsClientBeginUpdateOptions struct { // Resumes the LRO from the provided token. ResumeToken string } -// ReportClientGetOptions contains the optional parameters for the ReportClient.Get method. -type ReportClientGetOptions struct { +// ReportsClientGetOptions contains the optional parameters for the ReportsClient.Get method. +type ReportsClientGetOptions struct { // placeholder for future optional parameters } // ReportsClientListOptions contains the optional parameters for the ReportsClient.NewListPager method. type ReportsClientListOptions struct { + // The filter to apply on the operation. + Filter *string + // The offerGuid which mapping to the reports. OfferGUID *string + // OData order by query option. + Orderby *string + // The tenant id of the report creator. ReportCreatorTenantID *string @@ -54,22 +163,56 @@ type ReportsClientListOptions struct { Top *int32 } -// SnapshotClientBeginDownloadOptions contains the optional parameters for the SnapshotClient.BeginDownload method. -type SnapshotClientBeginDownloadOptions struct { +// ReportsClientNestedResourceCheckNameAvailabilityOptions contains the optional parameters for the ReportsClient.NestedResourceCheckNameAvailability +// method. +type ReportsClientNestedResourceCheckNameAvailabilityOptions struct { + // placeholder for future optional parameters +} + +// ScopingConfigurationClientCreateOrUpdateOptions contains the optional parameters for the ScopingConfigurationClient.CreateOrUpdate +// method. +type ScopingConfigurationClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// ScopingConfigurationClientDeleteOptions contains the optional parameters for the ScopingConfigurationClient.Delete method. +type ScopingConfigurationClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// ScopingConfigurationClientGetOptions contains the optional parameters for the ScopingConfigurationClient.Get method. +type ScopingConfigurationClientGetOptions struct { + // placeholder for future optional parameters +} + +// ScopingConfigurationsClientListOptions contains the optional parameters for the ScopingConfigurationsClient.NewListPager +// method. +type ScopingConfigurationsClientListOptions struct { + // placeholder for future optional parameters +} + +// SnapshotsClientBeginDownloadOptions contains the optional parameters for the SnapshotsClient.BeginDownload method. +type SnapshotsClientBeginDownloadOptions struct { // Resumes the LRO from the provided token. ResumeToken string } -// SnapshotClientGetOptions contains the optional parameters for the SnapshotClient.Get method. -type SnapshotClientGetOptions struct { +// SnapshotsClientGetOptions contains the optional parameters for the SnapshotsClient.Get method. +type SnapshotsClientGetOptions struct { // placeholder for future optional parameters } // SnapshotsClientListOptions contains the optional parameters for the SnapshotsClient.NewListPager method. type SnapshotsClientListOptions struct { + // The filter to apply on the operation. + Filter *string + // The offerGuid which mapping to the reports. OfferGUID *string + // OData order by query option. + Orderby *string + // The tenant id of the report creator. ReportCreatorTenantID *string @@ -82,3 +225,53 @@ type SnapshotsClientListOptions struct { // Number of elements to return when retrieving results. Top *int32 } + +// ToolForMicrosoft365ClientGetScopingQuestionsOptions contains the optional parameters for the ToolForMicrosoft365Client.GetScopingQuestions +// method. +type ToolForMicrosoft365ClientGetScopingQuestionsOptions struct { + // placeholder for future optional parameters +} + +// WebhooksClientCreateOrUpdateOptions contains the optional parameters for the WebhooksClient.CreateOrUpdate method. +type WebhooksClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// WebhooksClientDeleteOptions contains the optional parameters for the WebhooksClient.Delete method. +type WebhooksClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// WebhooksClientGetOptions contains the optional parameters for the WebhooksClient.Get method. +type WebhooksClientGetOptions struct { + // placeholder for future optional parameters +} + +// WebhooksClientListOptions contains the optional parameters for the WebhooksClient.NewListPager method. +type WebhooksClientListOptions struct { + // The filter to apply on the operation. + Filter *string + + // The offerGuid which mapping to the reports. + OfferGUID *string + + // OData order by query option. + Orderby *string + + // The tenant id of the report creator. + ReportCreatorTenantID *string + + // OData Select statement. Limits the properties on each entry to just those requested, e.g. ?$select=reportName,id. + Select *string + + // Skip over when retrieving results. + SkipToken *string + + // Number of elements to return when retrieving results. + Top *int32 +} + +// WebhooksClientUpdateOptions contains the optional parameters for the WebhooksClient.Update method. +type WebhooksClientUpdateOptions struct { + // placeholder for future optional parameters +} diff --git a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/provideractions_client.go b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/provideractions_client.go new file mode 100644 index 000000000000..ebd97e380b72 --- /dev/null +++ b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/provideractions_client.go @@ -0,0 +1,392 @@ +//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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armappcomplianceautomation + +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" +) + +// ProviderActionsClient contains the methods for the ProviderActions group. +// Don't use this type directly, use NewProviderActionsClient() instead. +type ProviderActionsClient struct { + internal *arm.Client +} + +// NewProviderActionsClient creates a new instance of ProviderActionsClient with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewProviderActionsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*ProviderActionsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &ProviderActionsClient{ + internal: cl, + } + return client, nil +} + +// CheckNameAvailability - Check if the given name is available for a report. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-06-27 +// - body - The content of the action request +// - options - ProviderActionsClientCheckNameAvailabilityOptions contains the optional parameters for the ProviderActionsClient.CheckNameAvailability +// method. +func (client *ProviderActionsClient) CheckNameAvailability(ctx context.Context, body CheckNameAvailabilityRequest, options *ProviderActionsClientCheckNameAvailabilityOptions) (ProviderActionsClientCheckNameAvailabilityResponse, error) { + var err error + const operationName = "ProviderActionsClient.CheckNameAvailability" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.checkNameAvailabilityCreateRequest(ctx, body, options) + if err != nil { + return ProviderActionsClientCheckNameAvailabilityResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ProviderActionsClientCheckNameAvailabilityResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ProviderActionsClientCheckNameAvailabilityResponse{}, err + } + resp, err := client.checkNameAvailabilityHandleResponse(httpResp) + return resp, err +} + +// checkNameAvailabilityCreateRequest creates the CheckNameAvailability request. +func (client *ProviderActionsClient) checkNameAvailabilityCreateRequest(ctx context.Context, body CheckNameAvailabilityRequest, options *ProviderActionsClientCheckNameAvailabilityOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.AppComplianceAutomation/checkNameAvailability" + 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", "2024-06-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} + +// checkNameAvailabilityHandleResponse handles the CheckNameAvailability response. +func (client *ProviderActionsClient) checkNameAvailabilityHandleResponse(resp *http.Response) (ProviderActionsClientCheckNameAvailabilityResponse, error) { + result := ProviderActionsClientCheckNameAvailabilityResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CheckNameAvailabilityResponse); err != nil { + return ProviderActionsClientCheckNameAvailabilityResponse{}, err + } + return result, nil +} + +// GetCollectionCount - Get the count of reports. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-06-27 +// - body - The content of the action request +// - options - ProviderActionsClientGetCollectionCountOptions contains the optional parameters for the ProviderActionsClient.GetCollectionCount +// method. +func (client *ProviderActionsClient) GetCollectionCount(ctx context.Context, body GetCollectionCountRequest, options *ProviderActionsClientGetCollectionCountOptions) (ProviderActionsClientGetCollectionCountResponse, error) { + var err error + const operationName = "ProviderActionsClient.GetCollectionCount" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCollectionCountCreateRequest(ctx, body, options) + if err != nil { + return ProviderActionsClientGetCollectionCountResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ProviderActionsClientGetCollectionCountResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ProviderActionsClientGetCollectionCountResponse{}, err + } + resp, err := client.getCollectionCountHandleResponse(httpResp) + return resp, err +} + +// getCollectionCountCreateRequest creates the GetCollectionCount request. +func (client *ProviderActionsClient) getCollectionCountCreateRequest(ctx context.Context, body GetCollectionCountRequest, options *ProviderActionsClientGetCollectionCountOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.AppComplianceAutomation/getCollectionCount" + 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", "2024-06-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} + +// getCollectionCountHandleResponse handles the GetCollectionCount response. +func (client *ProviderActionsClient) getCollectionCountHandleResponse(resp *http.Response) (ProviderActionsClientGetCollectionCountResponse, error) { + result := ProviderActionsClientGetCollectionCountResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.GetCollectionCountResponse); err != nil { + return ProviderActionsClientGetCollectionCountResponse{}, err + } + return result, nil +} + +// GetOverviewStatus - Get the resource overview status. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-06-27 +// - body - The content of the action request +// - options - ProviderActionsClientGetOverviewStatusOptions contains the optional parameters for the ProviderActionsClient.GetOverviewStatus +// method. +func (client *ProviderActionsClient) GetOverviewStatus(ctx context.Context, body GetOverviewStatusRequest, options *ProviderActionsClientGetOverviewStatusOptions) (ProviderActionsClientGetOverviewStatusResponse, error) { + var err error + const operationName = "ProviderActionsClient.GetOverviewStatus" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getOverviewStatusCreateRequest(ctx, body, options) + if err != nil { + return ProviderActionsClientGetOverviewStatusResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ProviderActionsClientGetOverviewStatusResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ProviderActionsClientGetOverviewStatusResponse{}, err + } + resp, err := client.getOverviewStatusHandleResponse(httpResp) + return resp, err +} + +// getOverviewStatusCreateRequest creates the GetOverviewStatus request. +func (client *ProviderActionsClient) getOverviewStatusCreateRequest(ctx context.Context, body GetOverviewStatusRequest, options *ProviderActionsClientGetOverviewStatusOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.AppComplianceAutomation/getOverviewStatus" + 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", "2024-06-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} + +// getOverviewStatusHandleResponse handles the GetOverviewStatus response. +func (client *ProviderActionsClient) getOverviewStatusHandleResponse(resp *http.Response) (ProviderActionsClientGetOverviewStatusResponse, error) { + result := ProviderActionsClientGetOverviewStatusResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.GetOverviewStatusResponse); err != nil { + return ProviderActionsClientGetOverviewStatusResponse{}, err + } + return result, nil +} + +// ListInUseStorageAccounts - List the storage accounts which are in use by related reports +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-06-27 +// - body - The content of the action request +// - options - ProviderActionsClientListInUseStorageAccountsOptions contains the optional parameters for the ProviderActionsClient.ListInUseStorageAccounts +// method. +func (client *ProviderActionsClient) ListInUseStorageAccounts(ctx context.Context, body ListInUseStorageAccountsRequest, options *ProviderActionsClientListInUseStorageAccountsOptions) (ProviderActionsClientListInUseStorageAccountsResponse, error) { + var err error + const operationName = "ProviderActionsClient.ListInUseStorageAccounts" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.listInUseStorageAccountsCreateRequest(ctx, body, options) + if err != nil { + return ProviderActionsClientListInUseStorageAccountsResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ProviderActionsClientListInUseStorageAccountsResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ProviderActionsClientListInUseStorageAccountsResponse{}, err + } + resp, err := client.listInUseStorageAccountsHandleResponse(httpResp) + return resp, err +} + +// listInUseStorageAccountsCreateRequest creates the ListInUseStorageAccounts request. +func (client *ProviderActionsClient) listInUseStorageAccountsCreateRequest(ctx context.Context, body ListInUseStorageAccountsRequest, options *ProviderActionsClientListInUseStorageAccountsOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.AppComplianceAutomation/listInUseStorageAccounts" + 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", "2024-06-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} + +// listInUseStorageAccountsHandleResponse handles the ListInUseStorageAccounts response. +func (client *ProviderActionsClient) listInUseStorageAccountsHandleResponse(resp *http.Response) (ProviderActionsClientListInUseStorageAccountsResponse, error) { + result := ProviderActionsClientListInUseStorageAccountsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ListInUseStorageAccountsResponse); err != nil { + return ProviderActionsClientListInUseStorageAccountsResponse{}, err + } + return result, nil +} + +// BeginOnboard - Onboard given subscriptions to Microsoft.AppComplianceAutomation provider. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-06-27 +// - body - The content of the action request +// - options - ProviderActionsClientBeginOnboardOptions contains the optional parameters for the ProviderActionsClient.BeginOnboard +// method. +func (client *ProviderActionsClient) BeginOnboard(ctx context.Context, body OnboardRequest, options *ProviderActionsClientBeginOnboardOptions) (*runtime.Poller[ProviderActionsClientOnboardResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.onboard(ctx, body, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ProviderActionsClientOnboardResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ProviderActionsClientOnboardResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Onboard - Onboard given subscriptions to Microsoft.AppComplianceAutomation provider. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-06-27 +func (client *ProviderActionsClient) onboard(ctx context.Context, body OnboardRequest, options *ProviderActionsClientBeginOnboardOptions) (*http.Response, error) { + var err error + const operationName = "ProviderActionsClient.BeginOnboard" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.onboardCreateRequest(ctx, body, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// onboardCreateRequest creates the Onboard request. +func (client *ProviderActionsClient) onboardCreateRequest(ctx context.Context, body OnboardRequest, options *ProviderActionsClientBeginOnboardOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.AppComplianceAutomation/onboard" + 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", "2024-06-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} + +// BeginTriggerEvaluation - Trigger quick evaluation for the given subscriptions. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-06-27 +// - body - The content of the action request +// - options - ProviderActionsClientBeginTriggerEvaluationOptions contains the optional parameters for the ProviderActionsClient.BeginTriggerEvaluation +// method. +func (client *ProviderActionsClient) BeginTriggerEvaluation(ctx context.Context, body TriggerEvaluationRequest, options *ProviderActionsClientBeginTriggerEvaluationOptions) (*runtime.Poller[ProviderActionsClientTriggerEvaluationResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.triggerEvaluation(ctx, body, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ProviderActionsClientTriggerEvaluationResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ProviderActionsClientTriggerEvaluationResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// TriggerEvaluation - Trigger quick evaluation for the given subscriptions. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-06-27 +func (client *ProviderActionsClient) triggerEvaluation(ctx context.Context, body TriggerEvaluationRequest, options *ProviderActionsClientBeginTriggerEvaluationOptions) (*http.Response, error) { + var err error + const operationName = "ProviderActionsClient.BeginTriggerEvaluation" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.triggerEvaluationCreateRequest(ctx, body, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// triggerEvaluationCreateRequest creates the TriggerEvaluation request. +func (client *ProviderActionsClient) triggerEvaluationCreateRequest(ctx context.Context, body TriggerEvaluationRequest, options *ProviderActionsClientBeginTriggerEvaluationOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.AppComplianceAutomation/triggerEvaluation" + 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", "2024-06-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} diff --git a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/report_client.go b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/report_client.go index d6676a46a339..785e51ef1afd 100644 --- a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/report_client.go +++ b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/report_client.go @@ -40,43 +40,41 @@ func NewReportClient(credential azcore.TokenCredential, options *arm.ClientOptio return client, nil } -// BeginCreateOrUpdate - Create a new AppComplianceAutomation report or update an exiting AppComplianceAutomation report. +// BeginVerify - Verify the AppComplianceAutomation report health status. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-16-preview +// Generated from API version 2024-06-27 // - reportName - Report Name. -// - parameters - Parameters for the create or update operation -// - options - ReportClientBeginCreateOrUpdateOptions contains the optional parameters for the ReportClient.BeginCreateOrUpdate -// method. -func (client *ReportClient) BeginCreateOrUpdate(ctx context.Context, reportName string, parameters ReportResource, options *ReportClientBeginCreateOrUpdateOptions) (*runtime.Poller[ReportClientCreateOrUpdateResponse], error) { +// - options - ReportClientBeginVerifyOptions contains the optional parameters for the ReportClient.BeginVerify method. +func (client *ReportClient) BeginVerify(ctx context.Context, reportName string, options *ReportClientBeginVerifyOptions) (*runtime.Poller[ReportClientVerifyResponse], error) { if options == nil || options.ResumeToken == "" { - resp, err := client.createOrUpdate(ctx, reportName, parameters, options) + resp, err := client.verify(ctx, reportName, options) if err != nil { return nil, err } - poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ReportClientCreateOrUpdateResponse]{ - FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ReportClientVerifyResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, Tracer: client.internal.Tracer(), }) return poller, err } else { - return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ReportClientCreateOrUpdateResponse]{ + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ReportClientVerifyResponse]{ Tracer: client.internal.Tracer(), }) } } -// CreateOrUpdate - Create a new AppComplianceAutomation report or update an exiting AppComplianceAutomation report. +// Verify - Verify the AppComplianceAutomation report health status. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-16-preview -func (client *ReportClient) createOrUpdate(ctx context.Context, reportName string, parameters ReportResource, options *ReportClientBeginCreateOrUpdateOptions) (*http.Response, error) { +// Generated from API version 2024-06-27 +func (client *ReportClient) verify(ctx context.Context, reportName string, options *ReportClientBeginVerifyOptions) (*http.Response, error) { var err error - const operationName = "ReportClient.BeginCreateOrUpdate" + const operationName = "ReportClient.BeginVerify" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.createOrUpdateCreateRequest(ctx, reportName, parameters, options) + req, err := client.verifyCreateRequest(ctx, reportName, options) if err != nil { return nil, err } @@ -84,223 +82,27 @@ func (client *ReportClient) createOrUpdate(ctx context.Context, reportName strin if err != nil { return nil, err } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { err = runtime.NewResponseError(httpResp) return nil, err } return httpResp, nil } -// createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *ReportClient) createOrUpdateCreateRequest(ctx context.Context, reportName string, parameters ReportResource, options *ReportClientBeginCreateOrUpdateOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.AppComplianceAutomation/reports/{reportName}" +// verifyCreateRequest creates the Verify request. +func (client *ReportClient) verifyCreateRequest(ctx context.Context, reportName string, options *ReportClientBeginVerifyOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.AppComplianceAutomation/reports/{reportName}/verify" if reportName == "" { return nil, errors.New("parameter reportName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{reportName}", url.PathEscape(reportName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), 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("api-version", "2022-11-16-preview") + reqQP.Set("api-version", "2024-06-27") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, parameters); err != nil { - return nil, err - } - return req, nil -} - -// BeginDelete - Delete an AppComplianceAutomation report. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-11-16-preview -// - reportName - Report Name. -// - options - ReportClientBeginDeleteOptions contains the optional parameters for the ReportClient.BeginDelete method. -func (client *ReportClient) BeginDelete(ctx context.Context, reportName string, options *ReportClientBeginDeleteOptions) (*runtime.Poller[ReportClientDeleteResponse], error) { - if options == nil || options.ResumeToken == "" { - resp, err := client.deleteOperation(ctx, reportName, options) - if err != nil { - return nil, err - } - poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ReportClientDeleteResponse]{ - FinalStateVia: runtime.FinalStateViaAzureAsyncOp, - Tracer: client.internal.Tracer(), - }) - return poller, err - } else { - return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ReportClientDeleteResponse]{ - Tracer: client.internal.Tracer(), - }) - } -} - -// Delete - Delete an AppComplianceAutomation report. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-11-16-preview -func (client *ReportClient) deleteOperation(ctx context.Context, reportName string, options *ReportClientBeginDeleteOptions) (*http.Response, error) { - var err error - const operationName = "ReportClient.BeginDelete" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.deleteCreateRequest(ctx, reportName, options) - if err != nil { - return nil, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return nil, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { - err = runtime.NewResponseError(httpResp) - return nil, err - } - return httpResp, nil -} - -// deleteCreateRequest creates the Delete request. -func (client *ReportClient) deleteCreateRequest(ctx context.Context, reportName string, options *ReportClientBeginDeleteOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.AppComplianceAutomation/reports/{reportName}" - if reportName == "" { - return nil, errors.New("parameter reportName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{reportName}", url.PathEscape(reportName)) - 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-16-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// Get - Get the AppComplianceAutomation report and its properties. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-11-16-preview -// - reportName - Report Name. -// - options - ReportClientGetOptions contains the optional parameters for the ReportClient.Get method. -func (client *ReportClient) Get(ctx context.Context, reportName string, options *ReportClientGetOptions) (ReportClientGetResponse, error) { - var err error - const operationName = "ReportClient.Get" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.getCreateRequest(ctx, reportName, options) - if err != nil { - return ReportClientGetResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return ReportClientGetResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return ReportClientGetResponse{}, err - } - resp, err := client.getHandleResponse(httpResp) - return resp, err -} - -// getCreateRequest creates the Get request. -func (client *ReportClient) getCreateRequest(ctx context.Context, reportName string, options *ReportClientGetOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.AppComplianceAutomation/reports/{reportName}" - if reportName == "" { - return nil, errors.New("parameter reportName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{reportName}", url.PathEscape(reportName)) - 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-16-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// getHandleResponse handles the Get response. -func (client *ReportClient) getHandleResponse(resp *http.Response) (ReportClientGetResponse, error) { - result := ReportClientGetResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.ReportResource); err != nil { - return ReportClientGetResponse{}, err - } - return result, nil -} - -// BeginUpdate - Update an exiting AppComplianceAutomation report. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-11-16-preview -// - reportName - Report Name. -// - parameters - Parameters for the create or update operation -// - options - ReportClientBeginUpdateOptions contains the optional parameters for the ReportClient.BeginUpdate method. -func (client *ReportClient) BeginUpdate(ctx context.Context, reportName string, parameters ReportResourcePatch, options *ReportClientBeginUpdateOptions) (*runtime.Poller[ReportClientUpdateResponse], error) { - if options == nil || options.ResumeToken == "" { - resp, err := client.update(ctx, reportName, parameters, options) - if err != nil { - return nil, err - } - poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ReportClientUpdateResponse]{ - FinalStateVia: runtime.FinalStateViaAzureAsyncOp, - Tracer: client.internal.Tracer(), - }) - return poller, err - } else { - return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ReportClientUpdateResponse]{ - Tracer: client.internal.Tracer(), - }) - } -} - -// Update - Update an exiting AppComplianceAutomation report. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-11-16-preview -func (client *ReportClient) update(ctx context.Context, reportName string, parameters ReportResourcePatch, options *ReportClientBeginUpdateOptions) (*http.Response, error) { - var err error - const operationName = "ReportClient.BeginUpdate" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.updateCreateRequest(ctx, reportName, parameters, options) - if err != nil { - return nil, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return nil, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated, http.StatusAccepted) { - err = runtime.NewResponseError(httpResp) - return nil, err - } - return httpResp, nil -} - -// updateCreateRequest creates the Update request. -func (client *ReportClient) updateCreateRequest(ctx context.Context, reportName string, parameters ReportResourcePatch, options *ReportClientBeginUpdateOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.AppComplianceAutomation/reports/{reportName}" - if reportName == "" { - return nil, errors.New("parameter reportName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{reportName}", url.PathEscape(reportName)) - 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-11-16-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, parameters); err != nil { - return nil, err - } return req, nil } diff --git a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/report_client_example_test.go b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/report_client_example_test.go deleted file mode 100644 index 644dc732a4a6..000000000000 --- a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/report_client_example_test.go +++ /dev/null @@ -1,259 +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 armappcomplianceautomation_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/appcomplianceautomation/armappcomplianceautomation" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/82ea406b73d671269217053d7ef336450d860345/specification/appcomplianceautomation/resource-manager/Microsoft.AppComplianceAutomation/preview/2022-11-16-preview/examples/Report_Get.json -func ExampleReportClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armappcomplianceautomation.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewReportClient().Get(ctx, "testReport", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ReportResource = armappcomplianceautomation.ReportResource{ - // Name: to.Ptr("testReportName"), - // Type: to.Ptr("Microsfot.AppComplianceAutomation/reports"), - // ID: to.Ptr("/provider/Microsfot.AppComplianceAutomation/reports/testReportName"), - // SystemData: &armappcomplianceautomation.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-14T22:34:55.449Z"); return t}()), - // CreatedBy: to.Ptr("00000000-0000-0000-0000-000000000000"), - // CreatedByType: to.Ptr(armappcomplianceautomation.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-14T22:34:55.449Z"); return t}()), - // LastModifiedBy: to.Ptr("00000000-0000-0000-0000-000000000000"), - // LastModifiedByType: to.Ptr(armappcomplianceautomation.CreatedByTypeUser), - // }, - // Properties: &armappcomplianceautomation.ReportProperties{ - // ComplianceStatus: &armappcomplianceautomation.ReportComplianceStatus{ - // M365: &armappcomplianceautomation.OverviewStatus{ - // FailedCount: to.Ptr[int32](0), - // ManualCount: to.Ptr[int32](0), - // PassedCount: to.Ptr[int32](0), - // }, - // }, - // ID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // LastTriggerTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-02T05:17:23.922Z"); return t}()), - // NextTriggerTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-02T05:17:23.922Z"); return t}()), - // OfferGUID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // ProvisioningState: to.Ptr(armappcomplianceautomation.ProvisioningStateSucceeded), - // ReportName: to.Ptr("testReportName"), - // Resources: []*armappcomplianceautomation.ResourceMetadata{ - // { - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/Microsoft.SignalRService/SignalR/mySignalRService"), - // Tags: map[string]*string{ - // "key1": to.Ptr("value1"), - // }, - // }}, - // Status: to.Ptr(armappcomplianceautomation.ReportStatusActive), - // Subscriptions: []*string{ - // to.Ptr("00000000-0000-0000-0000-000000000000")}, - // TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // TimeZone: to.Ptr("GMT Standard Time"), - // TriggerTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-02T05:17:23.922Z"); return t}()), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/82ea406b73d671269217053d7ef336450d860345/specification/appcomplianceautomation/resource-manager/Microsoft.AppComplianceAutomation/preview/2022-11-16-preview/examples/Report_CreateOrUpdate.json -func ExampleReportClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armappcomplianceautomation.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewReportClient().BeginCreateOrUpdate(ctx, "testReportName", armappcomplianceautomation.ReportResource{ - Properties: &armappcomplianceautomation.ReportProperties{ - OfferGUID: to.Ptr("0000"), - Resources: []*armappcomplianceautomation.ResourceMetadata{ - { - ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/Microsoft.Network/privateEndpoints/myPrivateEndpoint"), - Tags: map[string]*string{ - "key1": to.Ptr("value1"), - }, - }}, - TimeZone: to.Ptr("GMT Standard Time"), - TriggerTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-04T05:11:56.197Z"); return t }()), - }, - }, 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) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ReportResource = armappcomplianceautomation.ReportResource{ - // Name: to.Ptr("testReportName"), - // Type: to.Ptr("Microsfot.AppComplianceAutomation/reports"), - // ID: to.Ptr("/provider/Microsfot.AppComplianceAutomation/reports/testReportName"), - // SystemData: &armappcomplianceautomation.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-14T22:34:55.449Z"); return t}()), - // CreatedBy: to.Ptr("00000000-0000-0000-0000-000000000000"), - // CreatedByType: to.Ptr(armappcomplianceautomation.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-14T22:34:55.449Z"); return t}()), - // LastModifiedBy: to.Ptr("00000000-0000-0000-0000-000000000000"), - // LastModifiedByType: to.Ptr(armappcomplianceautomation.CreatedByTypeUser), - // }, - // Properties: &armappcomplianceautomation.ReportProperties{ - // ComplianceStatus: &armappcomplianceautomation.ReportComplianceStatus{ - // M365: &armappcomplianceautomation.OverviewStatus{ - // FailedCount: to.Ptr[int32](0), - // ManualCount: to.Ptr[int32](0), - // PassedCount: to.Ptr[int32](0), - // }, - // }, - // ID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // LastTriggerTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-02T05:17:23.922Z"); return t}()), - // NextTriggerTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-02T05:17:23.922Z"); return t}()), - // OfferGUID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // ProvisioningState: to.Ptr(armappcomplianceautomation.ProvisioningStateSucceeded), - // ReportName: to.Ptr("testReportName"), - // Resources: []*armappcomplianceautomation.ResourceMetadata{ - // { - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/Microsoft.SignalRService/SignalR/mySignalRService"), - // Tags: map[string]*string{ - // "key1": to.Ptr("value1"), - // }, - // }}, - // Status: to.Ptr(armappcomplianceautomation.ReportStatusActive), - // Subscriptions: []*string{ - // to.Ptr("00000000-0000-0000-0000-000000000000")}, - // TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // TimeZone: to.Ptr("GMT Standard Time"), - // TriggerTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-02T05:17:23.922Z"); return t}()), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/82ea406b73d671269217053d7ef336450d860345/specification/appcomplianceautomation/resource-manager/Microsoft.AppComplianceAutomation/preview/2022-11-16-preview/examples/Report_Update.json -func ExampleReportClient_BeginUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armappcomplianceautomation.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewReportClient().BeginUpdate(ctx, "testReportName", armappcomplianceautomation.ReportResourcePatch{ - Properties: &armappcomplianceautomation.ReportProperties{ - OfferGUID: to.Ptr("0000"), - Resources: []*armappcomplianceautomation.ResourceMetadata{ - { - ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/Microsoft.Network/privateEndpoints/myPrivateEndpoint"), - Tags: map[string]*string{ - "key1": to.Ptr("value1"), - }, - }}, - TimeZone: to.Ptr("GMT Standard Time"), - TriggerTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-04T05:11:56.197Z"); return t }()), - }, - }, 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) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ReportResource = armappcomplianceautomation.ReportResource{ - // Name: to.Ptr("testReportName"), - // Type: to.Ptr("Microsfot.AppComplianceAutomation/reports"), - // ID: to.Ptr("/provider/Microsfot.AppComplianceAutomation/reports/testReportName"), - // SystemData: &armappcomplianceautomation.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-14T22:34:55.449Z"); return t}()), - // CreatedBy: to.Ptr("00000000-0000-0000-0000-000000000000"), - // CreatedByType: to.Ptr(armappcomplianceautomation.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-14T22:34:55.449Z"); return t}()), - // LastModifiedBy: to.Ptr("00000000-0000-0000-0000-000000000000"), - // LastModifiedByType: to.Ptr(armappcomplianceautomation.CreatedByTypeUser), - // }, - // Properties: &armappcomplianceautomation.ReportProperties{ - // ComplianceStatus: &armappcomplianceautomation.ReportComplianceStatus{ - // M365: &armappcomplianceautomation.OverviewStatus{ - // FailedCount: to.Ptr[int32](0), - // ManualCount: to.Ptr[int32](0), - // PassedCount: to.Ptr[int32](0), - // }, - // }, - // ID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // LastTriggerTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-02T05:17:23.922Z"); return t}()), - // NextTriggerTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-02T05:17:23.922Z"); return t}()), - // OfferGUID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // ProvisioningState: to.Ptr(armappcomplianceautomation.ProvisioningStateSucceeded), - // ReportName: to.Ptr("testReportName"), - // Resources: []*armappcomplianceautomation.ResourceMetadata{ - // { - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/Microsoft.SignalRService/SignalR/mySignalRService"), - // Tags: map[string]*string{ - // "key1": to.Ptr("value1"), - // }, - // }}, - // Status: to.Ptr(armappcomplianceautomation.ReportStatusActive), - // Subscriptions: []*string{ - // to.Ptr("00000000-0000-0000-0000-000000000000")}, - // TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // TimeZone: to.Ptr("GMT Standard Time"), - // TriggerTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-02T05:17:23.922Z"); return t}()), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/82ea406b73d671269217053d7ef336450d860345/specification/appcomplianceautomation/resource-manager/Microsoft.AppComplianceAutomation/preview/2022-11-16-preview/examples/Report_Delete.json -func ExampleReportClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armappcomplianceautomation.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewReportClient().BeginDelete(ctx, "testReportName", 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/appcomplianceautomation/armappcomplianceautomation/reports_client.go b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/reports_client.go index f12c081fa922..7431f0515155 100644 --- a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/reports_client.go +++ b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/reports_client.go @@ -10,12 +10,15 @@ package armappcomplianceautomation 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" "strconv" + "strings" ) // ReportsClient contains the methods for the Reports group. @@ -38,9 +41,272 @@ func NewReportsClient(credential azcore.TokenCredential, options *arm.ClientOpti return client, nil } +// BeginCreateOrUpdate - Create a new AppComplianceAutomation report or update an exiting AppComplianceAutomation report. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-06-27 +// - reportName - Report Name. +// - parameters - Parameters for the create or update operation +// - options - ReportsClientBeginCreateOrUpdateOptions contains the optional parameters for the ReportsClient.BeginCreateOrUpdate +// method. +func (client *ReportsClient) BeginCreateOrUpdate(ctx context.Context, reportName string, parameters ReportResource, options *ReportsClientBeginCreateOrUpdateOptions) (*runtime.Poller[ReportsClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, reportName, parameters, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ReportsClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ReportsClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// CreateOrUpdate - Create a new AppComplianceAutomation report or update an exiting AppComplianceAutomation report. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-06-27 +func (client *ReportsClient) createOrUpdate(ctx context.Context, reportName string, parameters ReportResource, options *ReportsClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + const operationName = "ReportsClient.BeginCreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, reportName, parameters, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *ReportsClient) createOrUpdateCreateRequest(ctx context.Context, reportName string, parameters ReportResource, options *ReportsClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.AppComplianceAutomation/reports/{reportName}" + if reportName == "" { + return nil, errors.New("parameter reportName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reportName}", url.PathEscape(reportName)) + 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", "2024-06-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// BeginDelete - Delete an AppComplianceAutomation report. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-06-27 +// - reportName - Report Name. +// - options - ReportsClientBeginDeleteOptions contains the optional parameters for the ReportsClient.BeginDelete method. +func (client *ReportsClient) BeginDelete(ctx context.Context, reportName string, options *ReportsClientBeginDeleteOptions) (*runtime.Poller[ReportsClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, reportName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ReportsClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ReportsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Delete - Delete an AppComplianceAutomation report. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-06-27 +func (client *ReportsClient) deleteOperation(ctx context.Context, reportName string, options *ReportsClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "ReportsClient.BeginDelete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, reportName, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *ReportsClient) deleteCreateRequest(ctx context.Context, reportName string, options *ReportsClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.AppComplianceAutomation/reports/{reportName}" + if reportName == "" { + return nil, errors.New("parameter reportName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reportName}", url.PathEscape(reportName)) + 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", "2024-06-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// BeginFix - Fix the AppComplianceAutomation report error. e.g: App Compliance Automation Tool service unregistered, automation +// removed. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-06-27 +// - reportName - Report Name. +// - options - ReportsClientBeginFixOptions contains the optional parameters for the ReportsClient.BeginFix method. +func (client *ReportsClient) BeginFix(ctx context.Context, reportName string, options *ReportsClientBeginFixOptions) (*runtime.Poller[ReportsClientFixResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.fix(ctx, reportName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ReportsClientFixResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ReportsClientFixResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Fix - Fix the AppComplianceAutomation report error. e.g: App Compliance Automation Tool service unregistered, automation +// removed. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-06-27 +func (client *ReportsClient) fix(ctx context.Context, reportName string, options *ReportsClientBeginFixOptions) (*http.Response, error) { + var err error + const operationName = "ReportsClient.BeginFix" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.fixCreateRequest(ctx, reportName, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// fixCreateRequest creates the Fix request. +func (client *ReportsClient) fixCreateRequest(ctx context.Context, reportName string, options *ReportsClientBeginFixOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.AppComplianceAutomation/reports/{reportName}/fix" + if reportName == "" { + return nil, errors.New("parameter reportName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reportName}", url.PathEscape(reportName)) + 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", "2024-06-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Get the AppComplianceAutomation report and its properties. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-06-27 +// - reportName - Report Name. +// - options - ReportsClientGetOptions contains the optional parameters for the ReportsClient.Get method. +func (client *ReportsClient) Get(ctx context.Context, reportName string, options *ReportsClientGetOptions) (ReportsClientGetResponse, error) { + var err error + const operationName = "ReportsClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, reportName, options) + if err != nil { + return ReportsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ReportsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ReportsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *ReportsClient) getCreateRequest(ctx context.Context, reportName string, options *ReportsClientGetOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.AppComplianceAutomation/reports/{reportName}" + if reportName == "" { + return nil, errors.New("parameter reportName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reportName}", url.PathEscape(reportName)) + 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", "2024-06-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ReportsClient) getHandleResponse(resp *http.Response) (ReportsClientGetResponse, error) { + result := ReportsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ReportResource); err != nil { + return ReportsClientGetResponse{}, err + } + return result, nil +} + // NewListPager - Get the AppComplianceAutomation report list for the tenant. // -// Generated from API version 2022-11-16-preview +// Generated from API version 2024-06-27 // - options - ReportsClientListOptions contains the optional parameters for the ReportsClient.NewListPager method. func (client *ReportsClient) NewListPager(options *ReportsClientListOptions) *runtime.Pager[ReportsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[ReportsClientListResponse]{ @@ -73,16 +339,22 @@ func (client *ReportsClient) listCreateRequest(ctx context.Context, options *Rep return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-11-16-preview") + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Orderby != nil { + reqQP.Set("$orderby", *options.Orderby) + } + if options != nil && options.Select != nil { + reqQP.Set("$select", *options.Select) + } if options != nil && options.SkipToken != nil { reqQP.Set("$skipToken", *options.SkipToken) } if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - if options != nil && options.Select != nil { - reqQP.Set("$select", *options.Select) - } + reqQP.Set("api-version", "2024-06-27") if options != nil && options.OfferGUID != nil { reqQP.Set("offerGuid", *options.OfferGUID) } @@ -97,8 +369,212 @@ func (client *ReportsClient) listCreateRequest(ctx context.Context, options *Rep // listHandleResponse handles the List response. func (client *ReportsClient) listHandleResponse(resp *http.Response) (ReportsClientListResponse, error) { result := ReportsClientListResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.ReportResourceList); err != nil { + if err := runtime.UnmarshalAsJSON(resp, &result.ReportResourceListResult); err != nil { return ReportsClientListResponse{}, err } return result, nil } + +// NestedResourceCheckNameAvailability - Checks the report's nested resource name availability, e.g: Webhooks, Evidences, +// Snapshots. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-06-27 +// - reportName - Report Name. +// - body - NameAvailabilityRequest object. +// - options - ReportsClientNestedResourceCheckNameAvailabilityOptions contains the optional parameters for the ReportsClient.NestedResourceCheckNameAvailability +// method. +func (client *ReportsClient) NestedResourceCheckNameAvailability(ctx context.Context, reportName string, body CheckNameAvailabilityRequest, options *ReportsClientNestedResourceCheckNameAvailabilityOptions) (ReportsClientNestedResourceCheckNameAvailabilityResponse, error) { + var err error + const operationName = "ReportsClient.NestedResourceCheckNameAvailability" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.nestedResourceCheckNameAvailabilityCreateRequest(ctx, reportName, body, options) + if err != nil { + return ReportsClientNestedResourceCheckNameAvailabilityResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ReportsClientNestedResourceCheckNameAvailabilityResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ReportsClientNestedResourceCheckNameAvailabilityResponse{}, err + } + resp, err := client.nestedResourceCheckNameAvailabilityHandleResponse(httpResp) + return resp, err +} + +// nestedResourceCheckNameAvailabilityCreateRequest creates the NestedResourceCheckNameAvailability request. +func (client *ReportsClient) nestedResourceCheckNameAvailabilityCreateRequest(ctx context.Context, reportName string, body CheckNameAvailabilityRequest, options *ReportsClientNestedResourceCheckNameAvailabilityOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.AppComplianceAutomation/reports/{reportName}/checkNameAvailability" + if reportName == "" { + return nil, errors.New("parameter reportName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reportName}", url.PathEscape(reportName)) + 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", "2024-06-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} + +// nestedResourceCheckNameAvailabilityHandleResponse handles the NestedResourceCheckNameAvailability response. +func (client *ReportsClient) nestedResourceCheckNameAvailabilityHandleResponse(resp *http.Response) (ReportsClientNestedResourceCheckNameAvailabilityResponse, error) { + result := ReportsClientNestedResourceCheckNameAvailabilityResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CheckNameAvailabilityResponse); err != nil { + return ReportsClientNestedResourceCheckNameAvailabilityResponse{}, err + } + return result, nil +} + +// BeginSyncCertRecord - Synchronize attestation record from app compliance. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-06-27 +// - reportName - Report Name. +// - body - Parameters for synchronize certification record operation +// - options - ReportsClientBeginSyncCertRecordOptions contains the optional parameters for the ReportsClient.BeginSyncCertRecord +// method. +func (client *ReportsClient) BeginSyncCertRecord(ctx context.Context, reportName string, body SyncCertRecordRequest, options *ReportsClientBeginSyncCertRecordOptions) (*runtime.Poller[ReportsClientSyncCertRecordResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.syncCertRecord(ctx, reportName, body, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ReportsClientSyncCertRecordResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ReportsClientSyncCertRecordResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// SyncCertRecord - Synchronize attestation record from app compliance. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-06-27 +func (client *ReportsClient) syncCertRecord(ctx context.Context, reportName string, body SyncCertRecordRequest, options *ReportsClientBeginSyncCertRecordOptions) (*http.Response, error) { + var err error + const operationName = "ReportsClient.BeginSyncCertRecord" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.syncCertRecordCreateRequest(ctx, reportName, body, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// syncCertRecordCreateRequest creates the SyncCertRecord request. +func (client *ReportsClient) syncCertRecordCreateRequest(ctx context.Context, reportName string, body SyncCertRecordRequest, options *ReportsClientBeginSyncCertRecordOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.AppComplianceAutomation/reports/{reportName}/syncCertRecord" + if reportName == "" { + return nil, errors.New("parameter reportName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reportName}", url.PathEscape(reportName)) + 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", "2024-06-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} + +// BeginUpdate - Update an exiting AppComplianceAutomation report. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-06-27 +// - reportName - Report Name. +// - properties - Parameters for the create or update operation +// - options - ReportsClientBeginUpdateOptions contains the optional parameters for the ReportsClient.BeginUpdate method. +func (client *ReportsClient) BeginUpdate(ctx context.Context, reportName string, properties ReportResourcePatch, options *ReportsClientBeginUpdateOptions) (*runtime.Poller[ReportsClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, reportName, properties, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ReportsClientUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ReportsClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Update - Update an exiting AppComplianceAutomation report. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-06-27 +func (client *ReportsClient) update(ctx context.Context, reportName string, properties ReportResourcePatch, options *ReportsClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "ReportsClient.BeginUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateCreateRequest(ctx, reportName, properties, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// updateCreateRequest creates the Update request. +func (client *ReportsClient) updateCreateRequest(ctx context.Context, reportName string, properties ReportResourcePatch, options *ReportsClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.AppComplianceAutomation/reports/{reportName}" + if reportName == "" { + return nil, errors.New("parameter reportName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reportName}", url.PathEscape(reportName)) + 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", "2024-06-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, properties); err != nil { + return nil, err + } + return req, nil +} diff --git a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/reports_client_example_test.go b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/reports_client_example_test.go deleted file mode 100644 index 5f4bfeeaa1fa..000000000000 --- a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/reports_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. -// DO NOT EDIT. - -package armappcomplianceautomation_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/appcomplianceautomation/armappcomplianceautomation" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/82ea406b73d671269217053d7ef336450d860345/specification/appcomplianceautomation/resource-manager/Microsoft.AppComplianceAutomation/preview/2022-11-16-preview/examples/Reports_List.json -func ExampleReportsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armappcomplianceautomation.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewReportsClient().NewListPager(&armappcomplianceautomation.ReportsClientListOptions{SkipToken: to.Ptr("1"), - Top: to.Ptr[int32](100), - Select: nil, - OfferGUID: to.Ptr("00000000-0000-0000-0000-000000000000"), - ReportCreatorTenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ReportResourceList = armappcomplianceautomation.ReportResourceList{ - // Value: []*armappcomplianceautomation.ReportResource{ - // { - // Name: to.Ptr("testReportName"), - // Type: to.Ptr("Microsfot.AppComplianceAutomation/reports"), - // ID: to.Ptr("/provider/Microsfot.AppComplianceAutomation/reports/testReportName"), - // SystemData: &armappcomplianceautomation.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-14T22:34:55.449Z"); return t}()), - // CreatedBy: to.Ptr("00000000-0000-0000-0000-000000000000"), - // CreatedByType: to.Ptr(armappcomplianceautomation.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-14T22:34:55.449Z"); return t}()), - // LastModifiedBy: to.Ptr("00000000-0000-0000-0000-000000000000"), - // LastModifiedByType: to.Ptr(armappcomplianceautomation.CreatedByTypeUser), - // }, - // Properties: &armappcomplianceautomation.ReportProperties{ - // ComplianceStatus: &armappcomplianceautomation.ReportComplianceStatus{ - // M365: &armappcomplianceautomation.OverviewStatus{ - // FailedCount: to.Ptr[int32](0), - // ManualCount: to.Ptr[int32](0), - // PassedCount: to.Ptr[int32](0), - // }, - // }, - // ID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // LastTriggerTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-02T05:17:23.922Z"); return t}()), - // NextTriggerTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-02T05:17:23.922Z"); return t}()), - // OfferGUID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // ProvisioningState: to.Ptr(armappcomplianceautomation.ProvisioningStateSucceeded), - // ReportName: to.Ptr("testReportName"), - // Resources: []*armappcomplianceautomation.ResourceMetadata{ - // { - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/Microsoft.SignalRService/SignalR/mySignalRService"), - // Tags: map[string]*string{ - // "key1": to.Ptr("value1"), - // }, - // }}, - // Status: to.Ptr(armappcomplianceautomation.ReportStatusActive), - // Subscriptions: []*string{ - // to.Ptr("00000000-0000-0000-0000-000000000000")}, - // TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // TimeZone: to.Ptr("GMT Standard Time"), - // TriggerTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-02T05:17:23.922Z"); return t}()), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/response_types.go b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/response_types.go deleted file mode 100644 index 32dece5a6c90..000000000000 --- a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/response_types.go +++ /dev/null @@ -1,62 +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. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armappcomplianceautomation - -// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. -type OperationsClientListResponse struct { - // A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. - OperationListResult -} - -// ReportClientCreateOrUpdateResponse contains the response from method ReportClient.BeginCreateOrUpdate. -type ReportClientCreateOrUpdateResponse struct { - // A class represent an AppComplianceAutomation report resource. - ReportResource -} - -// ReportClientDeleteResponse contains the response from method ReportClient.BeginDelete. -type ReportClientDeleteResponse struct { - // placeholder for future response values -} - -// ReportClientGetResponse contains the response from method ReportClient.Get. -type ReportClientGetResponse struct { - // A class represent an AppComplianceAutomation report resource. - ReportResource -} - -// ReportClientUpdateResponse contains the response from method ReportClient.BeginUpdate. -type ReportClientUpdateResponse struct { - // A class represent an AppComplianceAutomation report resource. - ReportResource -} - -// ReportsClientListResponse contains the response from method ReportsClient.NewListPager. -type ReportsClientListResponse struct { - // Object that includes an array of resources and a possible link for next set. - ReportResourceList -} - -// SnapshotClientDownloadResponse contains the response from method SnapshotClient.BeginDownload. -type SnapshotClientDownloadResponse struct { - // Object that includes all the possible response for the download operation. - DownloadResponse -} - -// SnapshotClientGetResponse contains the response from method SnapshotClient.Get. -type SnapshotClientGetResponse struct { - // A class represent a AppComplianceAutomation snapshot resource. - SnapshotResource -} - -// SnapshotsClientListResponse contains the response from method SnapshotsClient.NewListPager. -type SnapshotsClientListResponse struct { - // Object that includes an array of resources and a possible link for next set. - SnapshotResourceList -} diff --git a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/responses.go b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/responses.go new file mode 100644 index 000000000000..5b1bcfcb32eb --- /dev/null +++ b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/responses.go @@ -0,0 +1,209 @@ +//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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armappcomplianceautomation + +// EvidencesClientCreateOrUpdateResponse contains the response from method EvidencesClient.CreateOrUpdate. +type EvidencesClientCreateOrUpdateResponse struct { + // A class represent an AppComplianceAutomation evidence resource. + EvidenceResource +} + +// EvidencesClientDeleteResponse contains the response from method EvidencesClient.Delete. +type EvidencesClientDeleteResponse struct { + // placeholder for future response values +} + +// EvidencesClientDownloadResponse contains the response from method EvidencesClient.Download. +type EvidencesClientDownloadResponse struct { + // Object that includes all the possible response for the evidence file download operation. + EvidenceFileDownloadResponse +} + +// EvidencesClientGetResponse contains the response from method EvidencesClient.Get. +type EvidencesClientGetResponse struct { + // A class represent an AppComplianceAutomation evidence resource. + EvidenceResource +} + +// EvidencesClientListByReportResponse contains the response from method EvidencesClient.NewListByReportPager. +type EvidencesClientListByReportResponse struct { + // The response of a EvidenceResource list operation. + EvidenceResourceListResult +} + +// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. +type OperationsClientListResponse struct { + // A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. + OperationListResult +} + +// ProviderActionsClientCheckNameAvailabilityResponse contains the response from method ProviderActionsClient.CheckNameAvailability. +type ProviderActionsClientCheckNameAvailabilityResponse struct { + // The check availability result. + CheckNameAvailabilityResponse +} + +// ProviderActionsClientGetCollectionCountResponse contains the response from method ProviderActionsClient.GetCollectionCount. +type ProviderActionsClientGetCollectionCountResponse struct { + // The get collection count response. + GetCollectionCountResponse +} + +// ProviderActionsClientGetOverviewStatusResponse contains the response from method ProviderActionsClient.GetOverviewStatus. +type ProviderActionsClientGetOverviewStatusResponse struct { + // The get overview status response. + GetOverviewStatusResponse +} + +// ProviderActionsClientListInUseStorageAccountsResponse contains the response from method ProviderActionsClient.ListInUseStorageAccounts. +type ProviderActionsClientListInUseStorageAccountsResponse struct { + // Parameters for listing in use storage accounts operation. If subscription list is null, it will check the user's all subscriptions. + ListInUseStorageAccountsResponse +} + +// ProviderActionsClientOnboardResponse contains the response from method ProviderActionsClient.BeginOnboard. +type ProviderActionsClientOnboardResponse struct { + // Success. The response indicates given subscriptions has been onboarded. + OnboardResponse +} + +// ProviderActionsClientTriggerEvaluationResponse contains the response from method ProviderActionsClient.BeginTriggerEvaluation. +type ProviderActionsClientTriggerEvaluationResponse struct { + // Trigger evaluation response. + TriggerEvaluationResponse +} + +// ReportClientVerifyResponse contains the response from method ReportClient.BeginVerify. +type ReportClientVerifyResponse struct { + // Report health status verification result. + ReportVerificationResult +} + +// ReportsClientCreateOrUpdateResponse contains the response from method ReportsClient.BeginCreateOrUpdate. +type ReportsClientCreateOrUpdateResponse struct { + // A class represent an AppComplianceAutomation report resource. + ReportResource +} + +// ReportsClientDeleteResponse contains the response from method ReportsClient.BeginDelete. +type ReportsClientDeleteResponse struct { + // placeholder for future response values +} + +// ReportsClientFixResponse contains the response from method ReportsClient.BeginFix. +type ReportsClientFixResponse struct { + // Report fix result. + ReportFixResult +} + +// ReportsClientGetResponse contains the response from method ReportsClient.Get. +type ReportsClientGetResponse struct { + // A class represent an AppComplianceAutomation report resource. + ReportResource +} + +// ReportsClientListResponse contains the response from method ReportsClient.NewListPager. +type ReportsClientListResponse struct { + // The response of a ReportResource list operation. + ReportResourceListResult +} + +// ReportsClientNestedResourceCheckNameAvailabilityResponse contains the response from method ReportsClient.NestedResourceCheckNameAvailability. +type ReportsClientNestedResourceCheckNameAvailabilityResponse struct { + // The check availability result. + CheckNameAvailabilityResponse +} + +// ReportsClientSyncCertRecordResponse contains the response from method ReportsClient.BeginSyncCertRecord. +type ReportsClientSyncCertRecordResponse struct { + // Synchronize certification record response. + SyncCertRecordResponse +} + +// ReportsClientUpdateResponse contains the response from method ReportsClient.BeginUpdate. +type ReportsClientUpdateResponse struct { + // A class represent an AppComplianceAutomation report resource. + ReportResource +} + +// ScopingConfigurationClientCreateOrUpdateResponse contains the response from method ScopingConfigurationClient.CreateOrUpdate. +type ScopingConfigurationClientCreateOrUpdateResponse struct { + // A class represent an AppComplianceAutomation scoping configuration resource. + ScopingConfigurationResource +} + +// ScopingConfigurationClientDeleteResponse contains the response from method ScopingConfigurationClient.Delete. +type ScopingConfigurationClientDeleteResponse struct { + // placeholder for future response values +} + +// ScopingConfigurationClientGetResponse contains the response from method ScopingConfigurationClient.Get. +type ScopingConfigurationClientGetResponse struct { + // A class represent an AppComplianceAutomation scoping configuration resource. + ScopingConfigurationResource +} + +// ScopingConfigurationsClientListResponse contains the response from method ScopingConfigurationsClient.NewListPager. +type ScopingConfigurationsClientListResponse struct { + // The response of a ScopingConfigurationResource list operation. + ScopingConfigurationResourceListResult +} + +// SnapshotsClientDownloadResponse contains the response from method SnapshotsClient.BeginDownload. +type SnapshotsClientDownloadResponse struct { + // Object that includes all the possible response for the download operation. + DownloadResponse +} + +// SnapshotsClientGetResponse contains the response from method SnapshotsClient.Get. +type SnapshotsClientGetResponse struct { + // A class represent a AppComplianceAutomation snapshot resource. + SnapshotResource +} + +// SnapshotsClientListResponse contains the response from method SnapshotsClient.NewListPager. +type SnapshotsClientListResponse struct { + // The response of a SnapshotResource list operation. + SnapshotResourceListResult +} + +// ToolForMicrosoft365ClientGetScopingQuestionsResponse contains the response from method ToolForMicrosoft365Client.GetScopingQuestions. +type ToolForMicrosoft365ClientGetScopingQuestionsResponse struct { + // Scoping question list. + ScopingQuestions +} + +// WebhooksClientCreateOrUpdateResponse contains the response from method WebhooksClient.CreateOrUpdate. +type WebhooksClientCreateOrUpdateResponse struct { + // A class represent an AppComplianceAutomation webhook resource. + WebhookResource +} + +// WebhooksClientDeleteResponse contains the response from method WebhooksClient.Delete. +type WebhooksClientDeleteResponse struct { + // placeholder for future response values +} + +// WebhooksClientGetResponse contains the response from method WebhooksClient.Get. +type WebhooksClientGetResponse struct { + // A class represent an AppComplianceAutomation webhook resource. + WebhookResource +} + +// WebhooksClientListResponse contains the response from method WebhooksClient.NewListPager. +type WebhooksClientListResponse struct { + // The response of a WebhookResource list operation. + WebhookResourceListResult +} + +// WebhooksClientUpdateResponse contains the response from method WebhooksClient.Update. +type WebhooksClientUpdateResponse struct { + // A class represent an AppComplianceAutomation webhook resource. + WebhookResource +} diff --git a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/scopingconfiguration_client.go b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/scopingconfiguration_client.go new file mode 100644 index 000000000000..d15f371cafc6 --- /dev/null +++ b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/scopingconfiguration_client.go @@ -0,0 +1,219 @@ +//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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armappcomplianceautomation + +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" +) + +// ScopingConfigurationClient contains the methods for the ScopingConfiguration group. +// Don't use this type directly, use NewScopingConfigurationClient() instead. +type ScopingConfigurationClient struct { + internal *arm.Client +} + +// NewScopingConfigurationClient creates a new instance of ScopingConfigurationClient with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewScopingConfigurationClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*ScopingConfigurationClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &ScopingConfigurationClient{ + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Get the AppComplianceAutomation scoping configuration of the specific report. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-06-27 +// - reportName - Report Name. +// - scopingConfigurationName - The scoping configuration of the specific report. +// - parameters - Parameters for the create or update operation, this is a singleton resource, so please make sure you're using +// 'default' as the name. +// - options - ScopingConfigurationClientCreateOrUpdateOptions contains the optional parameters for the ScopingConfigurationClient.CreateOrUpdate +// method. +func (client *ScopingConfigurationClient) CreateOrUpdate(ctx context.Context, reportName string, scopingConfigurationName string, parameters ScopingConfigurationResource, options *ScopingConfigurationClientCreateOrUpdateOptions) (ScopingConfigurationClientCreateOrUpdateResponse, error) { + var err error + const operationName = "ScopingConfigurationClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, reportName, scopingConfigurationName, parameters, options) + if err != nil { + return ScopingConfigurationClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ScopingConfigurationClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return ScopingConfigurationClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *ScopingConfigurationClient) createOrUpdateCreateRequest(ctx context.Context, reportName string, scopingConfigurationName string, parameters ScopingConfigurationResource, options *ScopingConfigurationClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.AppComplianceAutomation/reports/{reportName}/scopingConfigurations/{scopingConfigurationName}" + if reportName == "" { + return nil, errors.New("parameter reportName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reportName}", url.PathEscape(reportName)) + if scopingConfigurationName == "" { + return nil, errors.New("parameter scopingConfigurationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scopingConfigurationName}", url.PathEscape(scopingConfigurationName)) + 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", "2024-06-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *ScopingConfigurationClient) createOrUpdateHandleResponse(resp *http.Response) (ScopingConfigurationClientCreateOrUpdateResponse, error) { + result := ScopingConfigurationClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ScopingConfigurationResource); err != nil { + return ScopingConfigurationClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Clean the AppComplianceAutomation scoping configuration of the specific report. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-06-27 +// - reportName - Report Name. +// - scopingConfigurationName - The scoping configuration of the specific report. +// - options - ScopingConfigurationClientDeleteOptions contains the optional parameters for the ScopingConfigurationClient.Delete +// method. +func (client *ScopingConfigurationClient) Delete(ctx context.Context, reportName string, scopingConfigurationName string, options *ScopingConfigurationClientDeleteOptions) (ScopingConfigurationClientDeleteResponse, error) { + var err error + const operationName = "ScopingConfigurationClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, reportName, scopingConfigurationName, options) + if err != nil { + return ScopingConfigurationClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ScopingConfigurationClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return ScopingConfigurationClientDeleteResponse{}, err + } + return ScopingConfigurationClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *ScopingConfigurationClient) deleteCreateRequest(ctx context.Context, reportName string, scopingConfigurationName string, options *ScopingConfigurationClientDeleteOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.AppComplianceAutomation/reports/{reportName}/scopingConfigurations/{scopingConfigurationName}" + if reportName == "" { + return nil, errors.New("parameter reportName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reportName}", url.PathEscape(reportName)) + if scopingConfigurationName == "" { + return nil, errors.New("parameter scopingConfigurationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scopingConfigurationName}", url.PathEscape(scopingConfigurationName)) + 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", "2024-06-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Get the AppComplianceAutomation scoping configuration of the specific report. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-06-27 +// - reportName - Report Name. +// - scopingConfigurationName - The scoping configuration of the specific report. +// - options - ScopingConfigurationClientGetOptions contains the optional parameters for the ScopingConfigurationClient.Get +// method. +func (client *ScopingConfigurationClient) Get(ctx context.Context, reportName string, scopingConfigurationName string, options *ScopingConfigurationClientGetOptions) (ScopingConfigurationClientGetResponse, error) { + var err error + const operationName = "ScopingConfigurationClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, reportName, scopingConfigurationName, options) + if err != nil { + return ScopingConfigurationClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ScopingConfigurationClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ScopingConfigurationClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *ScopingConfigurationClient) getCreateRequest(ctx context.Context, reportName string, scopingConfigurationName string, options *ScopingConfigurationClientGetOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.AppComplianceAutomation/reports/{reportName}/scopingConfigurations/{scopingConfigurationName}" + if reportName == "" { + return nil, errors.New("parameter reportName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reportName}", url.PathEscape(reportName)) + if scopingConfigurationName == "" { + return nil, errors.New("parameter scopingConfigurationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scopingConfigurationName}", url.PathEscape(scopingConfigurationName)) + 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", "2024-06-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ScopingConfigurationClient) getHandleResponse(resp *http.Response) (ScopingConfigurationClientGetResponse, error) { + result := ScopingConfigurationClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ScopingConfigurationResource); err != nil { + return ScopingConfigurationClientGetResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/scopingconfigurations_client.go b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/scopingconfigurations_client.go new file mode 100644 index 000000000000..f0f3a757ae87 --- /dev/null +++ b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/scopingconfigurations_client.go @@ -0,0 +1,97 @@ +//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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armappcomplianceautomation + +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" +) + +// ScopingConfigurationsClient contains the methods for the ScopingConfigurations group. +// Don't use this type directly, use NewScopingConfigurationsClient() instead. +type ScopingConfigurationsClient struct { + internal *arm.Client +} + +// NewScopingConfigurationsClient creates a new instance of ScopingConfigurationsClient with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewScopingConfigurationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*ScopingConfigurationsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &ScopingConfigurationsClient{ + internal: cl, + } + return client, nil +} + +// NewListPager - Returns a list format of the singleton scopingConfiguration for a specified report. +// +// Generated from API version 2024-06-27 +// - reportName - Report Name. +// - options - ScopingConfigurationsClientListOptions contains the optional parameters for the ScopingConfigurationsClient.NewListPager +// method. +func (client *ScopingConfigurationsClient) NewListPager(reportName string, options *ScopingConfigurationsClientListOptions) *runtime.Pager[ScopingConfigurationsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[ScopingConfigurationsClientListResponse]{ + More: func(page ScopingConfigurationsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ScopingConfigurationsClientListResponse) (ScopingConfigurationsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ScopingConfigurationsClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, reportName, options) + }, nil) + if err != nil { + return ScopingConfigurationsClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *ScopingConfigurationsClient) listCreateRequest(ctx context.Context, reportName string, options *ScopingConfigurationsClientListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.AppComplianceAutomation/reports/{reportName}/scopingConfigurations" + if reportName == "" { + return nil, errors.New("parameter reportName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reportName}", url.PathEscape(reportName)) + 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", "2024-06-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *ScopingConfigurationsClient) listHandleResponse(resp *http.Response) (ScopingConfigurationsClientListResponse, error) { + result := ScopingConfigurationsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ScopingConfigurationResourceListResult); err != nil { + return ScopingConfigurationsClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/snapshot_client.go b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/snapshot_client.go deleted file mode 100644 index 2962582f79c6..000000000000 --- a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/snapshot_client.go +++ /dev/null @@ -1,177 +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. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armappcomplianceautomation - -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" -) - -// SnapshotClient contains the methods for the Snapshot group. -// Don't use this type directly, use NewSnapshotClient() instead. -type SnapshotClient struct { - internal *arm.Client -} - -// NewSnapshotClient creates a new instance of SnapshotClient with the specified values. -// - credential - used to authorize requests. Usually a credential from azidentity. -// - options - pass nil to accept the default values. -func NewSnapshotClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*SnapshotClient, error) { - cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) - if err != nil { - return nil, err - } - client := &SnapshotClient{ - internal: cl, - } - return client, nil -} - -// BeginDownload - Download compliance needs from snapshot, like: Compliance Report, Resource List. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-11-16-preview -// - reportName - Report Name. -// - snapshotName - Snapshot Name. -// - parameters - Parameters for the query operation -// - options - SnapshotClientBeginDownloadOptions contains the optional parameters for the SnapshotClient.BeginDownload method. -func (client *SnapshotClient) BeginDownload(ctx context.Context, reportName string, snapshotName string, parameters SnapshotDownloadRequest, options *SnapshotClientBeginDownloadOptions) (*runtime.Poller[SnapshotClientDownloadResponse], error) { - if options == nil || options.ResumeToken == "" { - resp, err := client.download(ctx, reportName, snapshotName, parameters, options) - if err != nil { - return nil, err - } - poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SnapshotClientDownloadResponse]{ - FinalStateVia: runtime.FinalStateViaAzureAsyncOp, - Tracer: client.internal.Tracer(), - }) - return poller, err - } else { - return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[SnapshotClientDownloadResponse]{ - Tracer: client.internal.Tracer(), - }) - } -} - -// Download - Download compliance needs from snapshot, like: Compliance Report, Resource List. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-11-16-preview -func (client *SnapshotClient) download(ctx context.Context, reportName string, snapshotName string, parameters SnapshotDownloadRequest, options *SnapshotClientBeginDownloadOptions) (*http.Response, error) { - var err error - const operationName = "SnapshotClient.BeginDownload" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.downloadCreateRequest(ctx, reportName, snapshotName, parameters, options) - if err != nil { - return nil, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return nil, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { - err = runtime.NewResponseError(httpResp) - return nil, err - } - return httpResp, nil -} - -// downloadCreateRequest creates the Download request. -func (client *SnapshotClient) downloadCreateRequest(ctx context.Context, reportName string, snapshotName string, parameters SnapshotDownloadRequest, options *SnapshotClientBeginDownloadOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.AppComplianceAutomation/reports/{reportName}/snapshots/{snapshotName}/download" - if reportName == "" { - return nil, errors.New("parameter reportName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{reportName}", url.PathEscape(reportName)) - if snapshotName == "" { - return nil, errors.New("parameter snapshotName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{snapshotName}", url.PathEscape(snapshotName)) - 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-11-16-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, parameters); err != nil { - return nil, err - } - return req, nil -} - -// Get - Get the AppComplianceAutomation snapshot and its properties. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-11-16-preview -// - reportName - Report Name. -// - snapshotName - Snapshot Name. -// - options - SnapshotClientGetOptions contains the optional parameters for the SnapshotClient.Get method. -func (client *SnapshotClient) Get(ctx context.Context, reportName string, snapshotName string, options *SnapshotClientGetOptions) (SnapshotClientGetResponse, error) { - var err error - const operationName = "SnapshotClient.Get" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.getCreateRequest(ctx, reportName, snapshotName, options) - if err != nil { - return SnapshotClientGetResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return SnapshotClientGetResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return SnapshotClientGetResponse{}, err - } - resp, err := client.getHandleResponse(httpResp) - return resp, err -} - -// getCreateRequest creates the Get request. -func (client *SnapshotClient) getCreateRequest(ctx context.Context, reportName string, snapshotName string, options *SnapshotClientGetOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.AppComplianceAutomation/reports/{reportName}/snapshots/{snapshotName}" - if reportName == "" { - return nil, errors.New("parameter reportName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{reportName}", url.PathEscape(reportName)) - if snapshotName == "" { - return nil, errors.New("parameter snapshotName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{snapshotName}", url.PathEscape(snapshotName)) - 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-16-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// getHandleResponse handles the Get response. -func (client *SnapshotClient) getHandleResponse(resp *http.Response) (SnapshotClientGetResponse, error) { - result := SnapshotClientGetResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.SnapshotResource); err != nil { - return SnapshotClientGetResponse{}, err - } - return result, nil -} diff --git a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/snapshot_client_example_test.go b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/snapshot_client_example_test.go deleted file mode 100644 index 224148d47c8f..000000000000 --- a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/snapshot_client_example_test.go +++ /dev/null @@ -1,285 +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 armappcomplianceautomation_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/appcomplianceautomation/armappcomplianceautomation" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/82ea406b73d671269217053d7ef336450d860345/specification/appcomplianceautomation/resource-manager/Microsoft.AppComplianceAutomation/preview/2022-11-16-preview/examples/Snapshot_Get.json -func ExampleSnapshotClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armappcomplianceautomation.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewSnapshotClient().Get(ctx, "testReportName", "testSnapshot", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.SnapshotResource = armappcomplianceautomation.SnapshotResource{ - // Name: to.Ptr("testSnapshot"), - // Type: to.Ptr("Microsfot.AppComplianceAutomation/reports/snapshots"), - // ID: to.Ptr("/provider/Microsfot.AppComplianceAutomation/reports/testReportName/snapshots/testSnapshot"), - // SystemData: &armappcomplianceautomation.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-14T22:34:55.449Z"); return t}()), - // CreatedBy: to.Ptr("00000000-0000-0000-0000-000000000000"), - // CreatedByType: to.Ptr(armappcomplianceautomation.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-14T22:34:55.449Z"); return t}()), - // LastModifiedBy: to.Ptr("00000000-0000-0000-0000-000000000000"), - // LastModifiedByType: to.Ptr(armappcomplianceautomation.CreatedByTypeUser), - // }, - // Properties: &armappcomplianceautomation.SnapshotProperties{ - // ComplianceResults: []*armappcomplianceautomation.ComplianceResult{ - // { - // Categories: []*armappcomplianceautomation.Category{ - // { - // CategoryName: to.Ptr("Operational Security"), - // CategoryStatus: to.Ptr(armappcomplianceautomation.CategoryStatusHealthy), - // CategoryType: to.Ptr(armappcomplianceautomation.CategoryTypePartiallyAutomated), - // ControlFamilies: []*armappcomplianceautomation.ControlFamily{ - // { - // Controls: []*armappcomplianceautomation.Control{ - // { - // Assessments: []*armappcomplianceautomation.Assessment{ - // { - // Name: to.Ptr("AssessmentName"), - // Description: to.Ptr("Assessment Description"), - // IsPass: to.Ptr(armappcomplianceautomation.IsPassTrue), - // PolicyID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Remediation: to.Ptr("Remediation"), - // ResourceList: []*armappcomplianceautomation.AssessmentResource{ - // { - // Reason: to.Ptr("N/A"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/Microsoft.SignalRService/SignalR/mySignalRService"), - // ResourceStatus: to.Ptr(armappcomplianceautomation.ResourceStatusHealthy), - // StatusChangeDate: to.Ptr("2022-03-04"), - // }}, - // Severity: to.Ptr(armappcomplianceautomation.AssessmentSeverityHigh), - // }}, - // ControlDescription: to.Ptr("Provide demonstrable evidence that all member of the incident response team have completed annual training or a table top exercise"), - // ControlDescriptionHyperLink: to.Ptr("https://doc.microsoft.com"), - // ControlFullName: to.Ptr("Provide demonstrable evidence that all member of the incident response team have completed annual training or a table top exercise"), - // ControlID: to.Ptr("Operational Security#75"), - // ControlShortName: to.Ptr("Provide demonstrable evidence that all member of the incident response team have completed annual training or a table top exercise"), - // ControlStatus: to.Ptr(armappcomplianceautomation.ControlStatusPassed), - // ControlType: to.Ptr(armappcomplianceautomation.ControlTypeManual), - // }}, - // FamilyName: to.Ptr("Incident Response"), - // FamilyStatus: to.Ptr(armappcomplianceautomation.ControlFamilyStatusHealthy), - // FamilyType: to.Ptr(armappcomplianceautomation.ControlFamilyTypePartiallyAutomated), - // }}, - // }}, - // ComplianceName: to.Ptr("M365"), - // }}, - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-04T15:33:59.160Z"); return t}()), - // ID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // ProvisioningState: to.Ptr(armappcomplianceautomation.ProvisioningStateSucceeded), - // ReportProperties: &armappcomplianceautomation.ReportProperties{ - // ComplianceStatus: &armappcomplianceautomation.ReportComplianceStatus{ - // M365: &armappcomplianceautomation.OverviewStatus{ - // FailedCount: to.Ptr[int32](0), - // ManualCount: to.Ptr[int32](0), - // PassedCount: to.Ptr[int32](0), - // }, - // }, - // ID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // LastTriggerTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-04T15:33:59.160Z"); return t}()), - // NextTriggerTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-04T15:33:59.160Z"); return t}()), - // OfferGUID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // ProvisioningState: to.Ptr(armappcomplianceautomation.ProvisioningStateSucceeded), - // ReportName: to.Ptr("testReportName"), - // Resources: []*armappcomplianceautomation.ResourceMetadata{ - // { - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/Microsoft.SignalRService/SignalR/mySignalRService"), - // Tags: map[string]*string{ - // "key1": to.Ptr("value1"), - // }, - // }}, - // Status: to.Ptr(armappcomplianceautomation.ReportStatusActive), - // Subscriptions: []*string{ - // to.Ptr("00000000-0000-0000-0000-000000000000")}, - // TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // TimeZone: to.Ptr("GMT Standard Time"), - // TriggerTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-04T15:33:59.160Z"); return t}()), - // }, - // ReportSystemData: &armappcomplianceautomation.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-14T22:34:55.449Z"); return t}()), - // CreatedBy: to.Ptr("00000000-0000-0000-0000-000000000000"), - // CreatedByType: to.Ptr(armappcomplianceautomation.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-14T22:34:55.449Z"); return t}()), - // LastModifiedBy: to.Ptr("00000000-0000-0000-0000-000000000000"), - // LastModifiedByType: to.Ptr(armappcomplianceautomation.CreatedByTypeUser), - // }, - // SnapshotName: to.Ptr("testSnapshot"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/82ea406b73d671269217053d7ef336450d860345/specification/appcomplianceautomation/resource-manager/Microsoft.AppComplianceAutomation/preview/2022-11-16-preview/examples/Snapshot_ComplianceDetailedPdfReport_Download.json -func ExampleSnapshotClient_BeginDownload_snapshotDownloadComplianceDetailedPdfReport() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armappcomplianceautomation.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewSnapshotClient().BeginDownload(ctx, "testReportName", "testSnapshotName", armappcomplianceautomation.SnapshotDownloadRequest{ - DownloadType: to.Ptr(armappcomplianceautomation.DownloadTypeComplianceDetailedPDFReport), - OfferGUID: to.Ptr("00000000-0000-0000-0000-000000000000"), - ReportCreatorTenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), - }, 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) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.DownloadResponse = armappcomplianceautomation.DownloadResponse{ - // ComplianceDetailedPDFReport: &armappcomplianceautomation.DownloadResponseComplianceDetailedPDFReport{ - // SasURI: to.Ptr("this is a uri"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/82ea406b73d671269217053d7ef336450d860345/specification/appcomplianceautomation/resource-manager/Microsoft.AppComplianceAutomation/preview/2022-11-16-preview/examples/Snapshot_CompliancePdfReport_Download.json -func ExampleSnapshotClient_BeginDownload_snapshotDownloadCompliancePdfReport() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armappcomplianceautomation.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewSnapshotClient().BeginDownload(ctx, "testReportName", "testSnapshotName", armappcomplianceautomation.SnapshotDownloadRequest{ - DownloadType: to.Ptr(armappcomplianceautomation.DownloadTypeCompliancePDFReport), - OfferGUID: to.Ptr("00000000-0000-0000-0000-000000000000"), - ReportCreatorTenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), - }, 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) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.DownloadResponse = armappcomplianceautomation.DownloadResponse{ - // CompliancePDFReport: &armappcomplianceautomation.DownloadResponseCompliancePDFReport{ - // SasURI: to.Ptr("this is uri of report"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/82ea406b73d671269217053d7ef336450d860345/specification/appcomplianceautomation/resource-manager/Microsoft.AppComplianceAutomation/preview/2022-11-16-preview/examples/Snapshot_ComplianceReport_Download.json -func ExampleSnapshotClient_BeginDownload_snapshotDownloadComplianceReport() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armappcomplianceautomation.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewSnapshotClient().BeginDownload(ctx, "testReportName", "testSnapshotName", armappcomplianceautomation.SnapshotDownloadRequest{ - DownloadType: to.Ptr(armappcomplianceautomation.DownloadTypeComplianceReport), - OfferGUID: to.Ptr("00000000-0000-0000-0000-000000000000"), - ReportCreatorTenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), - }, 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) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.DownloadResponse = armappcomplianceautomation.DownloadResponse{ - // ComplianceReport: []*armappcomplianceautomation.ComplianceReportItem{ - // { - // CategoryName: to.Ptr("Data Security & Privacy"), - // ComplianceState: to.Ptr(armappcomplianceautomation.ComplianceStateHealthy), - // ControlID: to.Ptr("1"), - // ControlName: to.Ptr("Validate that TLS Configuration meets or exceeds the TLS Profile Configuration Requirements"), - // ControlType: to.Ptr(armappcomplianceautomation.ControlTypeFullyAutomated), - // PolicyDescription: to.Ptr("policy description"), - // PolicyDisplayName: to.Ptr("policy name"), - // PolicyID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // ResourceGroup: to.Ptr("testGroup"), - // ResourceID: to.Ptr("testResourceId"), - // ResourceType: to.Ptr("storageaccounts"), - // StatusChangeDate: to.Ptr("2021-09-01T17:26:57.4971616Z"), - // SubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/82ea406b73d671269217053d7ef336450d860345/specification/appcomplianceautomation/resource-manager/Microsoft.AppComplianceAutomation/preview/2022-11-16-preview/examples/Snapshot_ResourceList_Download.json -func ExampleSnapshotClient_BeginDownload_snapshotDownloadResourceList() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armappcomplianceautomation.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewSnapshotClient().BeginDownload(ctx, "testReportName", "testSnapshotName", armappcomplianceautomation.SnapshotDownloadRequest{ - DownloadType: to.Ptr(armappcomplianceautomation.DownloadTypeResourceList), - OfferGUID: to.Ptr("00000000-0000-0000-0000-000000000000"), - ReportCreatorTenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), - }, 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) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.DownloadResponse = armappcomplianceautomation.DownloadResponse{ - // ResourceList: []*armappcomplianceautomation.ResourceItem{ - // { - // ResourceGroup: to.Ptr("myResourceGroup"), - // ResourceID: to.Ptr("mySignalRService"), - // ResourceType: to.Ptr("SignalR"), - // SubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // }}, - // } -} diff --git a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/snapshots_client.go b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/snapshots_client.go index 6de95508cd93..02e24807a299 100644 --- a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/snapshots_client.go +++ b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/snapshots_client.go @@ -41,9 +41,145 @@ func NewSnapshotsClient(credential azcore.TokenCredential, options *arm.ClientOp return client, nil } +// BeginDownload - Download compliance needs from snapshot, like: Compliance Report, Resource List. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-06-27 +// - reportName - Report Name. +// - snapshotName - Snapshot Name. +// - body - Parameters for the query operation +// - options - SnapshotsClientBeginDownloadOptions contains the optional parameters for the SnapshotsClient.BeginDownload method. +func (client *SnapshotsClient) BeginDownload(ctx context.Context, reportName string, snapshotName string, body SnapshotDownloadRequest, options *SnapshotsClientBeginDownloadOptions) (*runtime.Poller[SnapshotsClientDownloadResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.download(ctx, reportName, snapshotName, body, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SnapshotsClientDownloadResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[SnapshotsClientDownloadResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Download - Download compliance needs from snapshot, like: Compliance Report, Resource List. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-06-27 +func (client *SnapshotsClient) download(ctx context.Context, reportName string, snapshotName string, body SnapshotDownloadRequest, options *SnapshotsClientBeginDownloadOptions) (*http.Response, error) { + var err error + const operationName = "SnapshotsClient.BeginDownload" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.downloadCreateRequest(ctx, reportName, snapshotName, body, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// downloadCreateRequest creates the Download request. +func (client *SnapshotsClient) downloadCreateRequest(ctx context.Context, reportName string, snapshotName string, body SnapshotDownloadRequest, options *SnapshotsClientBeginDownloadOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.AppComplianceAutomation/reports/{reportName}/snapshots/{snapshotName}/download" + if reportName == "" { + return nil, errors.New("parameter reportName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reportName}", url.PathEscape(reportName)) + if snapshotName == "" { + return nil, errors.New("parameter snapshotName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{snapshotName}", url.PathEscape(snapshotName)) + 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", "2024-06-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} + +// Get - Get the AppComplianceAutomation snapshot and its properties. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-06-27 +// - reportName - Report Name. +// - snapshotName - Snapshot Name. +// - options - SnapshotsClientGetOptions contains the optional parameters for the SnapshotsClient.Get method. +func (client *SnapshotsClient) Get(ctx context.Context, reportName string, snapshotName string, options *SnapshotsClientGetOptions) (SnapshotsClientGetResponse, error) { + var err error + const operationName = "SnapshotsClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, reportName, snapshotName, options) + if err != nil { + return SnapshotsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return SnapshotsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return SnapshotsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *SnapshotsClient) getCreateRequest(ctx context.Context, reportName string, snapshotName string, options *SnapshotsClientGetOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.AppComplianceAutomation/reports/{reportName}/snapshots/{snapshotName}" + if reportName == "" { + return nil, errors.New("parameter reportName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reportName}", url.PathEscape(reportName)) + if snapshotName == "" { + return nil, errors.New("parameter snapshotName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{snapshotName}", url.PathEscape(snapshotName)) + 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", "2024-06-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *SnapshotsClient) getHandleResponse(resp *http.Response) (SnapshotsClientGetResponse, error) { + result := SnapshotsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SnapshotResource); err != nil { + return SnapshotsClientGetResponse{}, err + } + return result, nil +} + // NewListPager - Get the AppComplianceAutomation snapshot list. // -// Generated from API version 2022-11-16-preview +// Generated from API version 2024-06-27 // - reportName - Report Name. // - options - SnapshotsClientListOptions contains the optional parameters for the SnapshotsClient.NewListPager method. func (client *SnapshotsClient) NewListPager(reportName string, options *SnapshotsClientListOptions) *runtime.Pager[SnapshotsClientListResponse] { @@ -81,22 +217,28 @@ func (client *SnapshotsClient) listCreateRequest(ctx context.Context, reportName return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-11-16-preview") + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Orderby != nil { + reqQP.Set("$orderby", *options.Orderby) + } + if options != nil && options.Select != nil { + reqQP.Set("$select", *options.Select) + } if options != nil && options.SkipToken != nil { reqQP.Set("$skipToken", *options.SkipToken) } if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - if options != nil && options.Select != nil { - reqQP.Set("$select", *options.Select) + reqQP.Set("api-version", "2024-06-27") + if options != nil && options.OfferGUID != nil { + reqQP.Set("offerGuid", *options.OfferGUID) } if options != nil && options.ReportCreatorTenantID != nil { reqQP.Set("reportCreatorTenantId", *options.ReportCreatorTenantID) } - if options != nil && options.OfferGUID != nil { - reqQP.Set("offerGuid", *options.OfferGUID) - } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -105,7 +247,7 @@ func (client *SnapshotsClient) listCreateRequest(ctx context.Context, reportName // listHandleResponse handles the List response. func (client *SnapshotsClient) listHandleResponse(resp *http.Response) (SnapshotsClientListResponse, error) { result := SnapshotsClientListResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.SnapshotResourceList); err != nil { + if err := runtime.UnmarshalAsJSON(resp, &result.SnapshotResourceListResult); err != nil { return SnapshotsClientListResponse{}, err } return result, nil diff --git a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/snapshots_client_example_test.go b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/snapshots_client_example_test.go deleted file mode 100644 index 87bebfc52674..000000000000 --- a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/snapshots_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. -// DO NOT EDIT. - -package armappcomplianceautomation_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/appcomplianceautomation/armappcomplianceautomation" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/82ea406b73d671269217053d7ef336450d860345/specification/appcomplianceautomation/resource-manager/Microsoft.AppComplianceAutomation/preview/2022-11-16-preview/examples/Snapshots_List.json -func ExampleSnapshotsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armappcomplianceautomation.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewSnapshotsClient().NewListPager("testReportName", &armappcomplianceautomation.SnapshotsClientListOptions{SkipToken: to.Ptr("1"), - Top: to.Ptr[int32](100), - Select: nil, - ReportCreatorTenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), - OfferGUID: to.Ptr("00000000-0000-0000-0000-000000000000"), - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.SnapshotResourceList = armappcomplianceautomation.SnapshotResourceList{ - // Value: []*armappcomplianceautomation.SnapshotResource{ - // { - // Name: to.Ptr("testSnapshot"), - // Type: to.Ptr("Microsfot.AppComplianceAutomation/reports/snapshots"), - // ID: to.Ptr("/provider/Microsfot.AppComplianceAutomation/reports/testReportName/snapshots/testSnapshot"), - // SystemData: &armappcomplianceautomation.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-14T22:34:55.449Z"); return t}()), - // CreatedBy: to.Ptr("00000000-0000-0000-0000-000000000000"), - // CreatedByType: to.Ptr(armappcomplianceautomation.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-14T22:34:55.449Z"); return t}()), - // LastModifiedBy: to.Ptr("00000000-0000-0000-0000-000000000000"), - // LastModifiedByType: to.Ptr(armappcomplianceautomation.CreatedByTypeUser), - // }, - // Properties: &armappcomplianceautomation.SnapshotProperties{ - // ComplianceResults: []*armappcomplianceautomation.ComplianceResult{ - // { - // Categories: []*armappcomplianceautomation.Category{ - // { - // CategoryName: to.Ptr("Operational Security"), - // CategoryStatus: to.Ptr(armappcomplianceautomation.CategoryStatusHealthy), - // CategoryType: to.Ptr(armappcomplianceautomation.CategoryTypePartiallyAutomated), - // ControlFamilies: []*armappcomplianceautomation.ControlFamily{ - // { - // Controls: []*armappcomplianceautomation.Control{ - // { - // Assessments: []*armappcomplianceautomation.Assessment{ - // { - // Name: to.Ptr("AssessmentName"), - // Description: to.Ptr("Assessment Description"), - // IsPass: to.Ptr(armappcomplianceautomation.IsPassTrue), - // PolicyID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Remediation: to.Ptr("Remediation"), - // ResourceList: []*armappcomplianceautomation.AssessmentResource{ - // { - // Reason: to.Ptr("N/A"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/Microsoft.SignalRService/SignalR/mySignalRService"), - // ResourceStatus: to.Ptr(armappcomplianceautomation.ResourceStatusHealthy), - // StatusChangeDate: to.Ptr("2022-03-04"), - // }}, - // Severity: to.Ptr(armappcomplianceautomation.AssessmentSeverityHigh), - // }}, - // ControlDescription: to.Ptr("Provide demonstrable evidence that all member of the incident response team have completed annual training or a table top exercise"), - // ControlDescriptionHyperLink: to.Ptr("https://doc.microsoft.com"), - // ControlFullName: to.Ptr("Provide demonstrable evidence that all member of the incident response team have completed annual training or a table top exercise"), - // ControlID: to.Ptr("Operational Security#75"), - // ControlShortName: to.Ptr("Provide demonstrable evidence that all member of the incident response team have completed annual training or a table top exercise"), - // ControlStatus: to.Ptr(armappcomplianceautomation.ControlStatusPassed), - // ControlType: to.Ptr(armappcomplianceautomation.ControlTypeManual), - // }}, - // FamilyName: to.Ptr("Incident Response"), - // FamilyStatus: to.Ptr(armappcomplianceautomation.ControlFamilyStatusHealthy), - // FamilyType: to.Ptr(armappcomplianceautomation.ControlFamilyTypePartiallyAutomated), - // }}, - // }}, - // ComplianceName: to.Ptr("M365"), - // }}, - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-04T15:33:59.160Z"); return t}()), - // ID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // ProvisioningState: to.Ptr(armappcomplianceautomation.ProvisioningStateSucceeded), - // ReportProperties: &armappcomplianceautomation.ReportProperties{ - // ComplianceStatus: &armappcomplianceautomation.ReportComplianceStatus{ - // M365: &armappcomplianceautomation.OverviewStatus{ - // FailedCount: to.Ptr[int32](0), - // ManualCount: to.Ptr[int32](0), - // PassedCount: to.Ptr[int32](0), - // }, - // }, - // ID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // LastTriggerTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-04T15:33:59.160Z"); return t}()), - // NextTriggerTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-04T15:33:59.160Z"); return t}()), - // OfferGUID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // ProvisioningState: to.Ptr(armappcomplianceautomation.ProvisioningStateSucceeded), - // ReportName: to.Ptr("testReportName"), - // Resources: []*armappcomplianceautomation.ResourceMetadata{ - // { - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/Microsoft.SignalRService/SignalR/mySignalRService"), - // Tags: map[string]*string{ - // "key1": to.Ptr("value1"), - // }, - // }}, - // Status: to.Ptr(armappcomplianceautomation.ReportStatusActive), - // Subscriptions: []*string{ - // to.Ptr("00000000-0000-0000-0000-000000000000")}, - // TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // TimeZone: to.Ptr("GMT Standard Time"), - // TriggerTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-04T15:33:59.160Z"); return t}()), - // }, - // ReportSystemData: &armappcomplianceautomation.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-14T22:34:55.449Z"); return t}()), - // CreatedBy: to.Ptr("00000000-0000-0000-0000-000000000000"), - // CreatedByType: to.Ptr(armappcomplianceautomation.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-14T22:34:55.449Z"); return t}()), - // LastModifiedBy: to.Ptr("00000000-0000-0000-0000-000000000000"), - // LastModifiedByType: to.Ptr(armappcomplianceautomation.CreatedByTypeUser), - // }, - // SnapshotName: to.Ptr("testSnapshot"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/time_rfc3339.go b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/time_rfc3339.go index 19a2f3155fb7..78c8149b8e4f 100644 --- a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/time_rfc3339.go +++ b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/time_rfc3339.go @@ -19,12 +19,16 @@ import ( ) // Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. -var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) +var tzOffsetRegex = regexp.MustCompile(`(?:Z|z|\+|-)(?:\d+:\d+)*"*$`) const ( - utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` - utcDateTime = "2006-01-02T15:04:05.999999999" - dateTimeJSON = `"` + time.RFC3339Nano + `"` + utcDateTime = "2006-01-02T15:04:05.999999999" + utcDateTimeJSON = `"` + utcDateTime + `"` + utcDateTimeNoT = "2006-01-02 15:04:05.999999999" + utcDateTimeJSONNoT = `"` + utcDateTimeNoT + `"` + dateTimeNoT = `2006-01-02 15:04:05.999999999Z07:00` + dateTimeJSON = `"` + time.RFC3339Nano + `"` + dateTimeJSONNoT = `"` + dateTimeNoT + `"` ) type dateTimeRFC3339 time.Time @@ -40,17 +44,33 @@ func (t dateTimeRFC3339) MarshalText() ([]byte, error) { } func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { - layout := utcDateTimeJSON - if tzOffsetRegex.Match(data) { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { layout = dateTimeJSON + } else if tzOffset { + layout = dateTimeJSONNoT + } else if hasT { + layout = utcDateTimeJSON + } else { + layout = utcDateTimeJSONNoT } return t.Parse(layout, string(data)) } func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { - layout := utcDateTime - if tzOffsetRegex.Match(data) { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { layout = time.RFC3339Nano + } else if tzOffset { + layout = dateTimeNoT + } else if hasT { + layout = utcDateTime + } else { + layout = utcDateTimeNoT } return t.Parse(layout, string(data)) } @@ -61,6 +81,10 @@ func (t *dateTimeRFC3339) Parse(layout, value string) error { return err } +func (t dateTimeRFC3339) String() string { + return time.Time(t).Format(time.RFC3339Nano) +} + func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return @@ -74,7 +98,7 @@ func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { } func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { - if data == nil || strings.EqualFold(string(data), "null") { + if data == nil || string(data) == "null" { return nil } var aux dateTimeRFC3339 diff --git a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/toolformicrosoft365_client.go b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/toolformicrosoft365_client.go new file mode 100644 index 000000000000..7b00c0da34c1 --- /dev/null +++ b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/toolformicrosoft365_client.go @@ -0,0 +1,98 @@ +//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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armappcomplianceautomation + +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" +) + +// ToolForMicrosoft365Client contains the methods for the AppComplianceAutomationToolForMicrosoft365 group. +// Don't use this type directly, use NewToolForMicrosoft365Client() instead. +type ToolForMicrosoft365Client struct { + internal *arm.Client +} + +// NewToolForMicrosoft365Client creates a new instance of ToolForMicrosoft365Client with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewToolForMicrosoft365Client(credential azcore.TokenCredential, options *arm.ClientOptions) (*ToolForMicrosoft365Client, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &ToolForMicrosoft365Client{ + internal: cl, + } + return client, nil +} + +// GetScopingQuestions - Fix the AppComplianceAutomation report error. e.g: App Compliance Automation Tool service unregistered, +// automation removed. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-06-27 +// - reportName - Report Name. +// - options - ToolForMicrosoft365ClientGetScopingQuestionsOptions contains the optional parameters for the ToolForMicrosoft365Client.GetScopingQuestions +// method. +func (client *ToolForMicrosoft365Client) GetScopingQuestions(ctx context.Context, reportName string, options *ToolForMicrosoft365ClientGetScopingQuestionsOptions) (ToolForMicrosoft365ClientGetScopingQuestionsResponse, error) { + var err error + const operationName = "ToolForMicrosoft365Client.GetScopingQuestions" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getScopingQuestionsCreateRequest(ctx, reportName, options) + if err != nil { + return ToolForMicrosoft365ClientGetScopingQuestionsResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ToolForMicrosoft365ClientGetScopingQuestionsResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ToolForMicrosoft365ClientGetScopingQuestionsResponse{}, err + } + resp, err := client.getScopingQuestionsHandleResponse(httpResp) + return resp, err +} + +// getScopingQuestionsCreateRequest creates the GetScopingQuestions request. +func (client *ToolForMicrosoft365Client) getScopingQuestionsCreateRequest(ctx context.Context, reportName string, options *ToolForMicrosoft365ClientGetScopingQuestionsOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.AppComplianceAutomation/reports/{reportName}/getScopingQuestions" + if reportName == "" { + return nil, errors.New("parameter reportName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reportName}", url.PathEscape(reportName)) + 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", "2024-06-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getScopingQuestionsHandleResponse handles the GetScopingQuestions response. +func (client *ToolForMicrosoft365Client) getScopingQuestionsHandleResponse(resp *http.Response) (ToolForMicrosoft365ClientGetScopingQuestionsResponse, error) { + result := ToolForMicrosoft365ClientGetScopingQuestionsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ScopingQuestions); err != nil { + return ToolForMicrosoft365ClientGetScopingQuestionsResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/webhooks_client.go b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/webhooks_client.go new file mode 100644 index 000000000000..cc398856d054 --- /dev/null +++ b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/webhooks_client.go @@ -0,0 +1,356 @@ +//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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armappcomplianceautomation + +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" + "strconv" + "strings" +) + +// WebhooksClient contains the methods for the Webhooks group. +// Don't use this type directly, use NewWebhooksClient() instead. +type WebhooksClient struct { + internal *arm.Client +} + +// NewWebhooksClient creates a new instance of WebhooksClient with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewWebhooksClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*WebhooksClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &WebhooksClient{ + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Create a new AppComplianceAutomation webhook or update an exiting AppComplianceAutomation webhook. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-06-27 +// - reportName - Report Name. +// - webhookName - Webhook Name. +// - parameters - Parameters for the create or update operation +// - options - WebhooksClientCreateOrUpdateOptions contains the optional parameters for the WebhooksClient.CreateOrUpdate method. +func (client *WebhooksClient) CreateOrUpdate(ctx context.Context, reportName string, webhookName string, parameters WebhookResource, options *WebhooksClientCreateOrUpdateOptions) (WebhooksClientCreateOrUpdateResponse, error) { + var err error + const operationName = "WebhooksClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, reportName, webhookName, parameters, options) + if err != nil { + return WebhooksClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WebhooksClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return WebhooksClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *WebhooksClient) createOrUpdateCreateRequest(ctx context.Context, reportName string, webhookName string, parameters WebhookResource, options *WebhooksClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.AppComplianceAutomation/reports/{reportName}/webhooks/{webhookName}" + if reportName == "" { + return nil, errors.New("parameter reportName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reportName}", url.PathEscape(reportName)) + if webhookName == "" { + return nil, errors.New("parameter webhookName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{webhookName}", url.PathEscape(webhookName)) + 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", "2024-06-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *WebhooksClient) createOrUpdateHandleResponse(resp *http.Response) (WebhooksClientCreateOrUpdateResponse, error) { + result := WebhooksClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.WebhookResource); err != nil { + return WebhooksClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Delete an AppComplianceAutomation webhook. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-06-27 +// - reportName - Report Name. +// - webhookName - Webhook Name. +// - options - WebhooksClientDeleteOptions contains the optional parameters for the WebhooksClient.Delete method. +func (client *WebhooksClient) Delete(ctx context.Context, reportName string, webhookName string, options *WebhooksClientDeleteOptions) (WebhooksClientDeleteResponse, error) { + var err error + const operationName = "WebhooksClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, reportName, webhookName, options) + if err != nil { + return WebhooksClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WebhooksClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return WebhooksClientDeleteResponse{}, err + } + return WebhooksClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *WebhooksClient) deleteCreateRequest(ctx context.Context, reportName string, webhookName string, options *WebhooksClientDeleteOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.AppComplianceAutomation/reports/{reportName}/webhooks/{webhookName}" + if reportName == "" { + return nil, errors.New("parameter reportName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reportName}", url.PathEscape(reportName)) + if webhookName == "" { + return nil, errors.New("parameter webhookName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{webhookName}", url.PathEscape(webhookName)) + 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", "2024-06-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Get the AppComplianceAutomation webhook and its properties. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-06-27 +// - reportName - Report Name. +// - webhookName - Webhook Name. +// - options - WebhooksClientGetOptions contains the optional parameters for the WebhooksClient.Get method. +func (client *WebhooksClient) Get(ctx context.Context, reportName string, webhookName string, options *WebhooksClientGetOptions) (WebhooksClientGetResponse, error) { + var err error + const operationName = "WebhooksClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, reportName, webhookName, options) + if err != nil { + return WebhooksClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WebhooksClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WebhooksClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *WebhooksClient) getCreateRequest(ctx context.Context, reportName string, webhookName string, options *WebhooksClientGetOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.AppComplianceAutomation/reports/{reportName}/webhooks/{webhookName}" + if reportName == "" { + return nil, errors.New("parameter reportName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reportName}", url.PathEscape(reportName)) + if webhookName == "" { + return nil, errors.New("parameter webhookName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{webhookName}", url.PathEscape(webhookName)) + 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", "2024-06-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *WebhooksClient) getHandleResponse(resp *http.Response) (WebhooksClientGetResponse, error) { + result := WebhooksClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.WebhookResource); err != nil { + return WebhooksClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - Get the AppComplianceAutomation webhook list. +// +// Generated from API version 2024-06-27 +// - reportName - Report Name. +// - options - WebhooksClientListOptions contains the optional parameters for the WebhooksClient.NewListPager method. +func (client *WebhooksClient) NewListPager(reportName string, options *WebhooksClientListOptions) *runtime.Pager[WebhooksClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[WebhooksClientListResponse]{ + More: func(page WebhooksClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *WebhooksClientListResponse) (WebhooksClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "WebhooksClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, reportName, options) + }, nil) + if err != nil { + return WebhooksClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *WebhooksClient) listCreateRequest(ctx context.Context, reportName string, options *WebhooksClientListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.AppComplianceAutomation/reports/{reportName}/webhooks" + if reportName == "" { + return nil, errors.New("parameter reportName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reportName}", url.PathEscape(reportName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Orderby != nil { + reqQP.Set("$orderby", *options.Orderby) + } + if options != nil && options.Select != nil { + reqQP.Set("$select", *options.Select) + } + if options != nil && options.SkipToken != nil { + reqQP.Set("$skipToken", *options.SkipToken) + } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-06-27") + if options != nil && options.OfferGUID != nil { + reqQP.Set("offerGuid", *options.OfferGUID) + } + if options != nil && options.ReportCreatorTenantID != nil { + reqQP.Set("reportCreatorTenantId", *options.ReportCreatorTenantID) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *WebhooksClient) listHandleResponse(resp *http.Response) (WebhooksClientListResponse, error) { + result := WebhooksClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.WebhookResourceListResult); err != nil { + return WebhooksClientListResponse{}, err + } + return result, nil +} + +// Update - Update an exiting AppComplianceAutomation webhook. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-06-27 +// - reportName - Report Name. +// - webhookName - Webhook Name. +// - properties - Parameters for the create or update operation +// - options - WebhooksClientUpdateOptions contains the optional parameters for the WebhooksClient.Update method. +func (client *WebhooksClient) Update(ctx context.Context, reportName string, webhookName string, properties WebhookResourcePatch, options *WebhooksClientUpdateOptions) (WebhooksClientUpdateResponse, error) { + var err error + const operationName = "WebhooksClient.Update" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateCreateRequest(ctx, reportName, webhookName, properties, options) + if err != nil { + return WebhooksClientUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WebhooksClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WebhooksClientUpdateResponse{}, err + } + resp, err := client.updateHandleResponse(httpResp) + return resp, err +} + +// updateCreateRequest creates the Update request. +func (client *WebhooksClient) updateCreateRequest(ctx context.Context, reportName string, webhookName string, properties WebhookResourcePatch, options *WebhooksClientUpdateOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.AppComplianceAutomation/reports/{reportName}/webhooks/{webhookName}" + if reportName == "" { + return nil, errors.New("parameter reportName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reportName}", url.PathEscape(reportName)) + if webhookName == "" { + return nil, errors.New("parameter webhookName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{webhookName}", url.PathEscape(webhookName)) + 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", "2024-06-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, properties); err != nil { + return nil, err + } + return req, nil +} + +// updateHandleResponse handles the Update response. +func (client *WebhooksClient) updateHandleResponse(resp *http.Response) (WebhooksClientUpdateResponse, error) { + result := WebhooksClientUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.WebhookResource); err != nil { + return WebhooksClientUpdateResponse{}, err + } + return result, nil +}