diff --git a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/CHANGELOG.md b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/CHANGELOG.md index b76a640a4001..f9b129e8fa39 100644 --- a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/CHANGELOG.md +++ b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/CHANGELOG.md @@ -1,5 +1,150 @@ # Release History +## 1.0.0 (2024-06-03) +### 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.NewReportsClient` has been removed +- Function `*ClientFactory.NewSnapshotsClient` has been removed +- Function `NewReportsClient` has been removed +- Function `*ReportsClient.NewListPager` has been removed +- Function `NewSnapshotsClient` has been removed +- Function `*SnapshotsClient.NewListPager` 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 `ResourceName`, `Tags` of struct `ResourceMetadata` has been removed +- Field `ID` of struct `SnapshotProperties` 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.NewEvidenceClient() *EvidenceClient` +- New function `*ClientFactory.NewProviderActionsClient() *ProviderActionsClient` +- New function `*ClientFactory.NewScopingConfigurationClient() *ScopingConfigurationClient` +- New function `*ClientFactory.NewWebhookClient() *WebhookClient` +- New function `NewEvidenceClient(azcore.TokenCredential, *arm.ClientOptions) (*EvidenceClient, error)` +- New function `*EvidenceClient.CreateOrUpdate(context.Context, string, string, EvidenceResource, *EvidenceClientCreateOrUpdateOptions) (EvidenceClientCreateOrUpdateResponse, error)` +- New function `*EvidenceClient.Delete(context.Context, string, string, *EvidenceClientDeleteOptions) (EvidenceClientDeleteResponse, error)` +- New function `*EvidenceClient.Download(context.Context, string, string, EvidenceFileDownloadRequest, *EvidenceClientDownloadOptions) (EvidenceClientDownloadResponse, error)` +- New function `*EvidenceClient.Get(context.Context, string, string, *EvidenceClientGetOptions) (EvidenceClientGetResponse, error)` +- New function `*EvidenceClient.NewListByReportPager(string, *EvidenceClientListByReportOptions) *runtime.Pager[EvidenceClientListByReportResponse]` +- 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.BeginFix(context.Context, string, *ReportClientBeginFixOptions) (*runtime.Poller[ReportClientFixResponse], error)` +- New function `*ReportClient.GetScopingQuestions(context.Context, string, *ReportClientGetScopingQuestionsOptions) (ReportClientGetScopingQuestionsResponse, error)` +- New function `*ReportClient.NewListPager(*ReportClientListOptions) *runtime.Pager[ReportClientListResponse]` +- New function `*ReportClient.NestedResourceCheckNameAvailability(context.Context, string, CheckNameAvailabilityRequest, *ReportClientNestedResourceCheckNameAvailabilityOptions) (ReportClientNestedResourceCheckNameAvailabilityResponse, error)` +- New function `*ReportClient.BeginSyncCertRecord(context.Context, string, SyncCertRecordRequest, *ReportClientBeginSyncCertRecordOptions) (*runtime.Poller[ReportClientSyncCertRecordResponse], error)` +- New function `*ReportClient.BeginVerify(context.Context, string, *ReportClientBeginVerifyOptions) (*runtime.Poller[ReportClientVerifyResponse], 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 `*ScopingConfigurationClient.NewListPager(string, *ScopingConfigurationClientListOptions) *runtime.Pager[ScopingConfigurationClientListResponse]` +- New function `*SnapshotClient.NewListPager(string, *SnapshotClientListOptions) *runtime.Pager[SnapshotClientListResponse]` +- New function `NewWebhookClient(azcore.TokenCredential, *arm.ClientOptions) (*WebhookClient, error)` +- New function `*WebhookClient.CreateOrUpdate(context.Context, string, string, WebhookResource, *WebhookClientCreateOrUpdateOptions) (WebhookClientCreateOrUpdateResponse, error)` +- New function `*WebhookClient.Delete(context.Context, string, string, *WebhookClientDeleteOptions) (WebhookClientDeleteResponse, error)` +- New function `*WebhookClient.Get(context.Context, string, string, *WebhookClientGetOptions) (WebhookClientGetResponse, error)` +- New function `*WebhookClient.NewListPager(string, *WebhookClientListOptions) *runtime.Pager[WebhookClientListResponse]` +- New function `*WebhookClient.Update(context.Context, string, string, WebhookResourcePatch, *WebhookClientUpdateOptions) (WebhookClientUpdateResponse, 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 `AccountID`, `ResourceOrigin` in struct `ResourceMetadata` + + ## 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..0ff4db77815c 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,60 @@ 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 } +// NewEvidenceClient creates a new instance of EvidenceClient. +func (c *ClientFactory) NewEvidenceClient() *EvidenceClient { + return &EvidenceClient{ + 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 +// 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 + return &SnapshotClient{ + internal: c.internal, + } } -// NewSnapshotsClient creates a new instance of SnapshotsClient. -func (c *ClientFactory) NewSnapshotsClient() *SnapshotsClient { - subClient, _ := NewSnapshotsClient(c.credential, c.options) - return subClient +// NewWebhookClient creates a new instance of WebhookClient. +func (c *ClientFactory) NewWebhookClient() *WebhookClient { + return &WebhookClient{ + 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/evidence_client.go b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/evidence_client.go new file mode 100644 index 000000000000..071c14064d01 --- /dev/null +++ b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/evidence_client.go @@ -0,0 +1,363 @@ +//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" +) + +// EvidenceClient contains the methods for the Evidence group. +// Don't use this type directly, use NewEvidenceClient() instead. +type EvidenceClient struct { + internal *arm.Client +} + +// NewEvidenceClient creates a new instance of EvidenceClient with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewEvidenceClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*EvidenceClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &EvidenceClient{ + 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. +// - properties - Parameters for the create or update operation +// - options - EvidenceClientCreateOrUpdateOptions contains the optional parameters for the EvidenceClient.CreateOrUpdate method. +func (client *EvidenceClient) CreateOrUpdate(ctx context.Context, reportName string, evidenceName string, properties EvidenceResource, options *EvidenceClientCreateOrUpdateOptions) (EvidenceClientCreateOrUpdateResponse, error) { + var err error + const operationName = "EvidenceClient.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, properties, options) + if err != nil { + return EvidenceClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return EvidenceClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return EvidenceClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *EvidenceClient) createOrUpdateCreateRequest(ctx context.Context, reportName string, evidenceName string, properties EvidenceResource, options *EvidenceClientCreateOrUpdateOptions) (*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, properties); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *EvidenceClient) createOrUpdateHandleResponse(resp *http.Response) (EvidenceClientCreateOrUpdateResponse, error) { + result := EvidenceClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.EvidenceResource); err != nil { + return EvidenceClientCreateOrUpdateResponse{}, 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 - EvidenceClientDeleteOptions contains the optional parameters for the EvidenceClient.Delete method. +func (client *EvidenceClient) Delete(ctx context.Context, reportName string, evidenceName string, options *EvidenceClientDeleteOptions) (EvidenceClientDeleteResponse, error) { + var err error + const operationName = "EvidenceClient.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 EvidenceClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return EvidenceClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return EvidenceClientDeleteResponse{}, err + } + return EvidenceClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *EvidenceClient) deleteCreateRequest(ctx context.Context, reportName string, evidenceName string, options *EvidenceClientDeleteOptions) (*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 - EvidenceClientDownloadOptions contains the optional parameters for the EvidenceClient.Download method. +func (client *EvidenceClient) Download(ctx context.Context, reportName string, evidenceName string, body EvidenceFileDownloadRequest, options *EvidenceClientDownloadOptions) (EvidenceClientDownloadResponse, error) { + var err error + const operationName = "EvidenceClient.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 EvidenceClientDownloadResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return EvidenceClientDownloadResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return EvidenceClientDownloadResponse{}, err + } + resp, err := client.downloadHandleResponse(httpResp) + return resp, err +} + +// downloadCreateRequest creates the Download request. +func (client *EvidenceClient) downloadCreateRequest(ctx context.Context, reportName string, evidenceName string, body EvidenceFileDownloadRequest, options *EvidenceClientDownloadOptions) (*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 *EvidenceClient) downloadHandleResponse(resp *http.Response) (EvidenceClientDownloadResponse, error) { + result := EvidenceClientDownloadResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.EvidenceFileDownloadResponse); err != nil { + return EvidenceClientDownloadResponse{}, 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 - EvidenceClientGetOptions contains the optional parameters for the EvidenceClient.Get method. +func (client *EvidenceClient) Get(ctx context.Context, reportName string, evidenceName string, options *EvidenceClientGetOptions) (EvidenceClientGetResponse, error) { + var err error + const operationName = "EvidenceClient.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 EvidenceClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return EvidenceClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return EvidenceClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *EvidenceClient) getCreateRequest(ctx context.Context, reportName string, evidenceName string, options *EvidenceClientGetOptions) (*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 *EvidenceClient) getHandleResponse(resp *http.Response) (EvidenceClientGetResponse, error) { + result := EvidenceClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.EvidenceResource); err != nil { + return EvidenceClientGetResponse{}, 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 - EvidenceClientListByReportOptions contains the optional parameters for the EvidenceClient.NewListByReportPager +// method. +func (client *EvidenceClient) NewListByReportPager(reportName string, options *EvidenceClientListByReportOptions) *runtime.Pager[EvidenceClientListByReportResponse] { + return runtime.NewPager(runtime.PagingHandler[EvidenceClientListByReportResponse]{ + More: func(page EvidenceClientListByReportResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *EvidenceClientListByReportResponse) (EvidenceClientListByReportResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "EvidenceClient.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 EvidenceClientListByReportResponse{}, err + } + return client.listByReportHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByReportCreateRequest creates the ListByReport request. +func (client *EvidenceClient) listByReportCreateRequest(ctx context.Context, reportName string, options *EvidenceClientListByReportOptions) (*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 *EvidenceClient) listByReportHandleResponse(resp *http.Response) (EvidenceClientListByReportResponse, error) { + result := EvidenceClientListByReportResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.EvidenceResourceListResult); err != nil { + return EvidenceClientListByReportResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/fake/evidence_server.go b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/fake/evidence_server.go new file mode 100644 index 000000000000..5b394f0b994a --- /dev/null +++ b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/fake/evidence_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" +) + +// EvidenceServer is a fake server for instances of the armappcomplianceautomation.EvidenceClient type. +type EvidenceServer struct { + // CreateOrUpdate is the fake for method EvidenceClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, reportName string, evidenceName string, properties armappcomplianceautomation.EvidenceResource, options *armappcomplianceautomation.EvidenceClientCreateOrUpdateOptions) (resp azfake.Responder[armappcomplianceautomation.EvidenceClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method EvidenceClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, reportName string, evidenceName string, options *armappcomplianceautomation.EvidenceClientDeleteOptions) (resp azfake.Responder[armappcomplianceautomation.EvidenceClientDeleteResponse], errResp azfake.ErrorResponder) + + // Download is the fake for method EvidenceClient.Download + // HTTP status codes to indicate success: http.StatusOK + Download func(ctx context.Context, reportName string, evidenceName string, body armappcomplianceautomation.EvidenceFileDownloadRequest, options *armappcomplianceautomation.EvidenceClientDownloadOptions) (resp azfake.Responder[armappcomplianceautomation.EvidenceClientDownloadResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method EvidenceClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, reportName string, evidenceName string, options *armappcomplianceautomation.EvidenceClientGetOptions) (resp azfake.Responder[armappcomplianceautomation.EvidenceClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByReportPager is the fake for method EvidenceClient.NewListByReportPager + // HTTP status codes to indicate success: http.StatusOK + NewListByReportPager func(reportName string, options *armappcomplianceautomation.EvidenceClientListByReportOptions) (resp azfake.PagerResponder[armappcomplianceautomation.EvidenceClientListByReportResponse]) +} + +// NewEvidenceServerTransport creates a new instance of EvidenceServerTransport with the provided implementation. +// The returned EvidenceServerTransport instance is connected to an instance of armappcomplianceautomation.EvidenceClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewEvidenceServerTransport(srv *EvidenceServer) *EvidenceServerTransport { + return &EvidenceServerTransport{ + srv: srv, + newListByReportPager: newTracker[azfake.PagerResponder[armappcomplianceautomation.EvidenceClientListByReportResponse]](), + } +} + +// EvidenceServerTransport connects instances of armappcomplianceautomation.EvidenceClient to instances of EvidenceServer. +// Don't use this type directly, use NewEvidenceServerTransport instead. +type EvidenceServerTransport struct { + srv *EvidenceServer + newListByReportPager *tracker[azfake.PagerResponder[armappcomplianceautomation.EvidenceClientListByReportResponse]] +} + +// Do implements the policy.Transporter interface for EvidenceServerTransport. +func (e *EvidenceServerTransport) 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 "EvidenceClient.CreateOrUpdate": + resp, err = e.dispatchCreateOrUpdate(req) + case "EvidenceClient.Delete": + resp, err = e.dispatchDelete(req) + case "EvidenceClient.Download": + resp, err = e.dispatchDownload(req) + case "EvidenceClient.Get": + resp, err = e.dispatchGet(req) + case "EvidenceClient.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 *EvidenceServerTransport) 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.EvidenceClientCreateOrUpdateOptions + if offerGUIDParam != nil || reportCreatorTenantIDParam != nil { + options = &armappcomplianceautomation.EvidenceClientCreateOrUpdateOptions{ + 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 *EvidenceServerTransport) 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 *EvidenceServerTransport) 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 *EvidenceServerTransport) 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 *EvidenceServerTransport) 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.EvidenceClientListByReportOptions + if skipTokenParam != nil || topParam != nil || selectParam != nil || filterParam != nil || orderbyParam != nil || offerGUIDParam != nil || reportCreatorTenantIDParam != nil { + options = &armappcomplianceautomation.EvidenceClientListByReportOptions{ + 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.EvidenceClientListByReportResponse, 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..f627cbb0aa38 100644 --- a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/fake/report_server.go +++ b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/fake/report_server.go @@ -15,29 +15,55 @@ import ( 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" ) // 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) + BeginCreateOrUpdate func(ctx context.Context, reportName string, properties 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 + // HTTP status codes to indicate success: http.StatusAccepted, http.StatusNoContent BeginDelete func(ctx context.Context, reportName string, options *armappcomplianceautomation.ReportClientBeginDeleteOptions) (resp azfake.PollerResponder[armappcomplianceautomation.ReportClientDeleteResponse], errResp azfake.ErrorResponder) + // BeginFix is the fake for method ReportClient.BeginFix + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginFix func(ctx context.Context, reportName string, options *armappcomplianceautomation.ReportClientBeginFixOptions) (resp azfake.PollerResponder[armappcomplianceautomation.ReportClientFixResponse], 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) + // GetScopingQuestions is the fake for method ReportClient.GetScopingQuestions + // HTTP status codes to indicate success: http.StatusOK + GetScopingQuestions func(ctx context.Context, reportName string, options *armappcomplianceautomation.ReportClientGetScopingQuestionsOptions) (resp azfake.Responder[armappcomplianceautomation.ReportClientGetScopingQuestionsResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method ReportClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(options *armappcomplianceautomation.ReportClientListOptions) (resp azfake.PagerResponder[armappcomplianceautomation.ReportClientListResponse]) + + // NestedResourceCheckNameAvailability is the fake for method ReportClient.NestedResourceCheckNameAvailability + // HTTP status codes to indicate success: http.StatusOK + NestedResourceCheckNameAvailability func(ctx context.Context, reportName string, body armappcomplianceautomation.CheckNameAvailabilityRequest, options *armappcomplianceautomation.ReportClientNestedResourceCheckNameAvailabilityOptions) (resp azfake.Responder[armappcomplianceautomation.ReportClientNestedResourceCheckNameAvailabilityResponse], errResp azfake.ErrorResponder) + + // BeginSyncCertRecord is the fake for method ReportClient.BeginSyncCertRecord + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginSyncCertRecord func(ctx context.Context, reportName string, body armappcomplianceautomation.SyncCertRecordRequest, options *armappcomplianceautomation.ReportClientBeginSyncCertRecordOptions) (resp azfake.PollerResponder[armappcomplianceautomation.ReportClientSyncCertRecordResponse], 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) + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdate func(ctx context.Context, reportName string, properties 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. @@ -48,7 +74,11 @@ func NewReportServerTransport(srv *ReportServer) *ReportServerTransport { srv: srv, beginCreateOrUpdate: newTracker[azfake.PollerResponder[armappcomplianceautomation.ReportClientCreateOrUpdateResponse]](), beginDelete: newTracker[azfake.PollerResponder[armappcomplianceautomation.ReportClientDeleteResponse]](), + beginFix: newTracker[azfake.PollerResponder[armappcomplianceautomation.ReportClientFixResponse]](), + newListPager: newTracker[azfake.PagerResponder[armappcomplianceautomation.ReportClientListResponse]](), + beginSyncCertRecord: newTracker[azfake.PollerResponder[armappcomplianceautomation.ReportClientSyncCertRecordResponse]](), beginUpdate: newTracker[azfake.PollerResponder[armappcomplianceautomation.ReportClientUpdateResponse]](), + beginVerify: newTracker[azfake.PollerResponder[armappcomplianceautomation.ReportClientVerifyResponse]](), } } @@ -58,7 +88,11 @@ type ReportServerTransport struct { srv *ReportServer beginCreateOrUpdate *tracker[azfake.PollerResponder[armappcomplianceautomation.ReportClientCreateOrUpdateResponse]] beginDelete *tracker[azfake.PollerResponder[armappcomplianceautomation.ReportClientDeleteResponse]] + beginFix *tracker[azfake.PollerResponder[armappcomplianceautomation.ReportClientFixResponse]] + newListPager *tracker[azfake.PagerResponder[armappcomplianceautomation.ReportClientListResponse]] + beginSyncCertRecord *tracker[azfake.PollerResponder[armappcomplianceautomation.ReportClientSyncCertRecordResponse]] beginUpdate *tracker[azfake.PollerResponder[armappcomplianceautomation.ReportClientUpdateResponse]] + beginVerify *tracker[azfake.PollerResponder[armappcomplianceautomation.ReportClientVerifyResponse]] } // Do implements the policy.Transporter interface for ReportServerTransport. @@ -77,10 +111,22 @@ func (r *ReportServerTransport) Do(req *http.Request) (*http.Response, error) { resp, err = r.dispatchBeginCreateOrUpdate(req) case "ReportClient.BeginDelete": resp, err = r.dispatchBeginDelete(req) + case "ReportClient.BeginFix": + resp, err = r.dispatchBeginFix(req) case "ReportClient.Get": resp, err = r.dispatchGet(req) + case "ReportClient.GetScopingQuestions": + resp, err = r.dispatchGetScopingQuestions(req) + case "ReportClient.NewListPager": + resp, err = r.dispatchNewListPager(req) + case "ReportClient.NestedResourceCheckNameAvailability": + resp, err = r.dispatchNestedResourceCheckNameAvailability(req) + case "ReportClient.BeginSyncCertRecord": + resp, err = r.dispatchBeginSyncCertRecord(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) } @@ -165,9 +211,9 @@ func (r *ReportServerTransport) dispatchBeginDelete(req *http.Request) (*http.Re return nil, err } - if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + 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.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + 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) @@ -176,6 +222,46 @@ func (r *ReportServerTransport) dispatchBeginDelete(req *http.Request) (*http.Re return resp, nil } +func (r *ReportServerTransport) 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 *ReportServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { if r.srv.Get == nil { return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} @@ -205,6 +291,196 @@ func (r *ReportServerTransport) dispatchGet(req *http.Request) (*http.Response, return resp, nil } +func (r *ReportServerTransport) dispatchGetScopingQuestions(req *http.Request) (*http.Response, error) { + if r.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 := r.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 +} + +func (r *ReportServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if r.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := r.newListPager.get(req) + if newListPager == nil { + 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) + var options *armappcomplianceautomation.ReportClientListOptions + if skipTokenParam != nil || topParam != nil || selectParam != nil || filterParam != nil || orderbyParam != nil || offerGUIDParam != nil || reportCreatorTenantIDParam != nil { + options = &armappcomplianceautomation.ReportClientListOptions{ + SkipToken: skipTokenParam, + Top: topParam, + Select: selectParam, + Filter: filterParam, + Orderby: orderbyParam, + OfferGUID: offerGUIDParam, + ReportCreatorTenantID: reportCreatorTenantIDParam, + } + } + resp := r.srv.NewListPager(options) + newListPager = &resp + r.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armappcomplianceautomation.ReportClientListResponse, 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) { + r.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + r.newListPager.remove(req) + } + return resp, nil +} + +func (r *ReportServerTransport) 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 *ReportServerTransport) 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 *ReportServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { if r.srv.BeginUpdate == nil { return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} @@ -238,9 +514,9 @@ func (r *ReportServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Re return nil, err } - if !contains([]int{http.StatusOK, http.StatusCreated, http.StatusAccepted}, resp.StatusCode) { + 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.StatusCreated, http.StatusAccepted", resp.StatusCode)} + 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) @@ -248,3 +524,43 @@ func (r *ReportServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Re return resp, nil } + +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")} + } + 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) + } + reportNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("reportName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.BeginVerify(req.Context(), reportNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginVerify = &respr + r.beginVerify.add(req, beginVerify) + } + + resp, err := server.PollerResponderNext(beginVerify, req) + if err != nil { + return nil, err + } + + 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(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 deleted file mode 100644 index 6c143635c7ce..000000000000 --- a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/fake/reports_server.go +++ /dev/null @@ -1,143 +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 ( - "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" - "strconv" -) - -// ReportsServer is a fake server for instances of the armappcomplianceautomation.ReportsClient type. -type ReportsServer struct { - // 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]) -} - -// NewReportsServerTransport creates a new instance of ReportsServerTransport with the provided implementation. -// The returned ReportsServerTransport instance is connected to an instance of armappcomplianceautomation.ReportsClient via the -// 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]](), - } -} - -// 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]] -} - -// Do implements the policy.Transporter interface for ReportsServerTransport. -func (r *ReportsServerTransport) 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 "ReportsClient.NewListPager": - resp, err = r.dispatchNewListPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } - - 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")} - } - newListPager := r.newListPager.get(req) - if newListPager == nil { - 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) - 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) - var options *armappcomplianceautomation.ReportsClientListOptions - if skipTokenParam != nil || topParam != nil || selectParam != nil || offerGUIDParam != nil || reportCreatorTenantIDParam != nil { - options = &armappcomplianceautomation.ReportsClientListOptions{ - SkipToken: skipTokenParam, - Top: topParam, - Select: selectParam, - OfferGUID: offerGUIDParam, - ReportCreatorTenantID: reportCreatorTenantIDParam, - } - } - resp := r.srv.NewListPager(options) - newListPager = &resp - r.newListPager.add(req, newListPager) - server.PagerResponderInjectNextLinks(newListPager, req, func(page *armappcomplianceautomation.ReportsClientListResponse, 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) { - r.newListPager.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} - } - if !server.PagerResponderMore(newListPager) { - r.newListPager.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..becf220e9b5f --- /dev/null +++ b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/fake/scopingconfiguration_server.go @@ -0,0 +1,230 @@ +//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" +) + +// 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, properties 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) + + // NewListPager is the fake for method ScopingConfigurationClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(reportName string, options *armappcomplianceautomation.ScopingConfigurationClientListOptions) (resp azfake.PagerResponder[armappcomplianceautomation.ScopingConfigurationClientListResponse]) +} + +// 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, + newListPager: newTracker[azfake.PagerResponder[armappcomplianceautomation.ScopingConfigurationClientListResponse]](), + } +} + +// ScopingConfigurationServerTransport connects instances of armappcomplianceautomation.ScopingConfigurationClient to instances of ScopingConfigurationServer. +// Don't use this type directly, use NewScopingConfigurationServerTransport instead. +type ScopingConfigurationServerTransport struct { + srv *ScopingConfigurationServer + newListPager *tracker[azfake.PagerResponder[armappcomplianceautomation.ScopingConfigurationClientListResponse]] +} + +// 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) + case "ScopingConfigurationClient.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 *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 +} + +func (s *ScopingConfigurationServerTransport) 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.ScopingConfigurationClientListResponse, 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..3dbbf57b95b2 100644 --- a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/fake/server_factory.go +++ b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/fake/server_factory.go @@ -19,11 +19,13 @@ 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 + EvidenceServer EvidenceServer + OperationsServer OperationsServer + ProviderActionsServer ProviderActionsServer + ReportServer ReportServer + ScopingConfigurationServer ScopingConfigurationServer + SnapshotServer SnapshotServer + WebhookServer WebhookServer } // NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. @@ -38,13 +40,15 @@ 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 + trEvidenceServer *EvidenceServerTransport + trOperationsServer *OperationsServerTransport + trProviderActionsServer *ProviderActionsServerTransport + trReportServer *ReportServerTransport + trScopingConfigurationServer *ScopingConfigurationServerTransport + trSnapshotServer *SnapshotServerTransport + trWebhookServer *WebhookServerTransport } // Do implements the policy.Transporter interface for ServerFactoryTransport. @@ -60,21 +64,31 @@ func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { var err error switch client { + case "EvidenceClient": + initServer(s, &s.trEvidenceServer, func() *EvidenceServerTransport { return NewEvidenceServerTransport(&s.srv.EvidenceServer) }) + resp, err = s.trEvidenceServer.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 "ScopingConfigurationClient": + initServer(s, &s.trScopingConfigurationServer, func() *ScopingConfigurationServerTransport { + return NewScopingConfigurationServerTransport(&s.srv.ScopingConfigurationServer) + }) + resp, err = s.trScopingConfigurationServer.Do(req) case "SnapshotClient": initServer(s, &s.trSnapshotServer, func() *SnapshotServerTransport { return NewSnapshotServerTransport(&s.srv.SnapshotServer) }) resp, err = s.trSnapshotServer.Do(req) - case "SnapshotsClient": - initServer(s, &s.trSnapshotsServer, func() *SnapshotsServerTransport { return NewSnapshotsServerTransport(&s.srv.SnapshotsServer) }) - resp, err = s.trSnapshotsServer.Do(req) + case "WebhookClient": + initServer(s, &s.trWebhookServer, func() *WebhookServerTransport { return NewWebhookServerTransport(&s.srv.WebhookServer) }) + resp, err = s.trWebhookServer.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 index 7c8f4e75da0f..7fa6cfb2a3dd 100644 --- a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/fake/snapshot_server.go +++ b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/fake/snapshot_server.go @@ -15,21 +15,27 @@ import ( 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" ) // 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) + BeginDownload func(ctx context.Context, reportName string, snapshotName string, body 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) + + // NewListPager is the fake for method SnapshotClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(reportName string, options *armappcomplianceautomation.SnapshotClientListOptions) (resp azfake.PagerResponder[armappcomplianceautomation.SnapshotClientListResponse]) } // NewSnapshotServerTransport creates a new instance of SnapshotServerTransport with the provided implementation. @@ -39,6 +45,7 @@ func NewSnapshotServerTransport(srv *SnapshotServer) *SnapshotServerTransport { return &SnapshotServerTransport{ srv: srv, beginDownload: newTracker[azfake.PollerResponder[armappcomplianceautomation.SnapshotClientDownloadResponse]](), + newListPager: newTracker[azfake.PagerResponder[armappcomplianceautomation.SnapshotClientListResponse]](), } } @@ -47,6 +54,7 @@ func NewSnapshotServerTransport(srv *SnapshotServer) *SnapshotServerTransport { type SnapshotServerTransport struct { srv *SnapshotServer beginDownload *tracker[azfake.PollerResponder[armappcomplianceautomation.SnapshotClientDownloadResponse]] + newListPager *tracker[azfake.PagerResponder[armappcomplianceautomation.SnapshotClientListResponse]] } // Do implements the policy.Transporter interface for SnapshotServerTransport. @@ -65,6 +73,8 @@ func (s *SnapshotServerTransport) Do(req *http.Request) (*http.Response, error) resp, err = s.dispatchBeginDownload(req) case "SnapshotClient.Get": resp, err = s.dispatchGet(req) + case "SnapshotClient.NewListPager": + resp, err = s.dispatchNewListPager(req) default: err = fmt.Errorf("unhandled API %s", method) } @@ -156,3 +166,97 @@ func (s *SnapshotServerTransport) dispatchGet(req *http.Request) (*http.Response } return resp, nil } + +func (s *SnapshotServerTransport) 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~%@]+)/snapshots` + 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.SnapshotClientListOptions + if skipTokenParam != nil || topParam != nil || selectParam != nil || filterParam != nil || orderbyParam != nil || offerGUIDParam != nil || reportCreatorTenantIDParam != nil { + options = &armappcomplianceautomation.SnapshotClientListOptions{ + SkipToken: skipTokenParam, + Top: topParam, + Select: selectParam, + Filter: filterParam, + Orderby: orderbyParam, + OfferGUID: offerGUIDParam, + ReportCreatorTenantID: reportCreatorTenantIDParam, + } + } + resp := s.srv.NewListPager(reportNameParam, options) + newListPager = &resp + s.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armappcomplianceautomation.SnapshotClientListResponse, 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/snapshots_server.go b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/fake/snapshots_server.go deleted file mode 100644 index e26176f3af96..000000000000 --- a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/fake/snapshots_server.go +++ /dev/null @@ -1,154 +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 ( - "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" -) - -// SnapshotsServer is a fake server for instances of the armappcomplianceautomation.SnapshotsClient type. -type SnapshotsServer struct { - // 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]) -} - -// NewSnapshotsServerTransport creates a new instance of SnapshotsServerTransport with the provided implementation. -// The returned SnapshotsServerTransport instance is connected to an instance of armappcomplianceautomation.SnapshotsClient via the -// 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]](), - } -} - -// 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]] -} - -// Do implements the policy.Transporter interface for SnapshotsServerTransport. -func (s *SnapshotsServerTransport) 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 "SnapshotsClient.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 *SnapshotsServerTransport) 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~%@]+)/snapshots` - 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() - 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 - } - 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) - reportCreatorTenantIDUnescaped, err := url.QueryUnescape(qp.Get("reportCreatorTenantId")) - if err != nil { - return nil, err - } - reportCreatorTenantIDParam := getOptional(reportCreatorTenantIDUnescaped) - offerGUIDUnescaped, err := url.QueryUnescape(qp.Get("offerGuid")) - if err != nil { - return nil, err - } - offerGUIDParam := getOptional(offerGUIDUnescaped) - var options *armappcomplianceautomation.SnapshotsClientListOptions - if skipTokenParam != nil || topParam != nil || selectParam != nil || reportCreatorTenantIDParam != nil || offerGUIDParam != nil { - options = &armappcomplianceautomation.SnapshotsClientListOptions{ - SkipToken: skipTokenParam, - Top: topParam, - Select: selectParam, - ReportCreatorTenantID: reportCreatorTenantIDParam, - OfferGUID: offerGUIDParam, - } - } - resp := s.srv.NewListPager(reportNameParam, options) - newListPager = &resp - s.newListPager.add(req, newListPager) - server.PagerResponderInjectNextLinks(newListPager, req, func(page *armappcomplianceautomation.SnapshotsClientListResponse, 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/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/webhook_server.go b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/fake/webhook_server.go new file mode 100644 index 000000000000..b6af80746b44 --- /dev/null +++ b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/fake/webhook_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" +) + +// WebhookServer is a fake server for instances of the armappcomplianceautomation.WebhookClient type. +type WebhookServer struct { + // CreateOrUpdate is the fake for method WebhookClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, reportName string, webhookName string, properties armappcomplianceautomation.WebhookResource, options *armappcomplianceautomation.WebhookClientCreateOrUpdateOptions) (resp azfake.Responder[armappcomplianceautomation.WebhookClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method WebhookClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, reportName string, webhookName string, options *armappcomplianceautomation.WebhookClientDeleteOptions) (resp azfake.Responder[armappcomplianceautomation.WebhookClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method WebhookClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, reportName string, webhookName string, options *armappcomplianceautomation.WebhookClientGetOptions) (resp azfake.Responder[armappcomplianceautomation.WebhookClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method WebhookClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(reportName string, options *armappcomplianceautomation.WebhookClientListOptions) (resp azfake.PagerResponder[armappcomplianceautomation.WebhookClientListResponse]) + + // Update is the fake for method WebhookClient.Update + // HTTP status codes to indicate success: http.StatusOK + Update func(ctx context.Context, reportName string, webhookName string, properties armappcomplianceautomation.WebhookResourcePatch, options *armappcomplianceautomation.WebhookClientUpdateOptions) (resp azfake.Responder[armappcomplianceautomation.WebhookClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewWebhookServerTransport creates a new instance of WebhookServerTransport with the provided implementation. +// The returned WebhookServerTransport instance is connected to an instance of armappcomplianceautomation.WebhookClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewWebhookServerTransport(srv *WebhookServer) *WebhookServerTransport { + return &WebhookServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armappcomplianceautomation.WebhookClientListResponse]](), + } +} + +// WebhookServerTransport connects instances of armappcomplianceautomation.WebhookClient to instances of WebhookServer. +// Don't use this type directly, use NewWebhookServerTransport instead. +type WebhookServerTransport struct { + srv *WebhookServer + newListPager *tracker[azfake.PagerResponder[armappcomplianceautomation.WebhookClientListResponse]] +} + +// Do implements the policy.Transporter interface for WebhookServerTransport. +func (w *WebhookServerTransport) 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 "WebhookClient.CreateOrUpdate": + resp, err = w.dispatchCreateOrUpdate(req) + case "WebhookClient.Delete": + resp, err = w.dispatchDelete(req) + case "WebhookClient.Get": + resp, err = w.dispatchGet(req) + case "WebhookClient.NewListPager": + resp, err = w.dispatchNewListPager(req) + case "WebhookClient.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 *WebhookServerTransport) 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 *WebhookServerTransport) 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 *WebhookServerTransport) 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 *WebhookServerTransport) 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.WebhookClientListOptions + if skipTokenParam != nil || topParam != nil || selectParam != nil || filterParam != nil || orderbyParam != nil || offerGUIDParam != nil || reportCreatorTenantIDParam != nil { + options = &armappcomplianceautomation.WebhookClientListOptions{ + 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.WebhookClientListResponse, 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 *WebhookServerTransport) 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..607d9f17961d 100644 --- a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/options.go +++ b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/options.go @@ -8,11 +8,96 @@ package armappcomplianceautomation +// EvidenceClientCreateOrUpdateOptions contains the optional parameters for the EvidenceClient.CreateOrUpdate method. +type EvidenceClientCreateOrUpdateOptions struct { + // The offerGuid which mapping to the reports. + OfferGUID *string + + // The tenant id of the report creator. + ReportCreatorTenantID *string +} + +// EvidenceClientDeleteOptions contains the optional parameters for the EvidenceClient.Delete method. +type EvidenceClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// EvidenceClientDownloadOptions contains the optional parameters for the EvidenceClient.Download method. +type EvidenceClientDownloadOptions struct { + // placeholder for future optional parameters +} + +// EvidenceClientGetOptions contains the optional parameters for the EvidenceClient.Get method. +type EvidenceClientGetOptions struct { + // placeholder for future optional parameters +} + +// EvidenceClientListByReportOptions contains the optional parameters for the EvidenceClient.NewListByReportPager method. +type EvidenceClientListByReportOptions 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 } +// 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 +} + // ReportClientBeginCreateOrUpdateOptions contains the optional parameters for the ReportClient.BeginCreateOrUpdate method. type ReportClientBeginCreateOrUpdateOptions struct { // Resumes the LRO from the provided token. @@ -25,22 +110,51 @@ type ReportClientBeginDeleteOptions struct { ResumeToken string } +// ReportClientBeginFixOptions contains the optional parameters for the ReportClient.BeginFix method. +type ReportClientBeginFixOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// ReportClientBeginSyncCertRecordOptions contains the optional parameters for the ReportClient.BeginSyncCertRecord method. +type ReportClientBeginSyncCertRecordOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + // ReportClientBeginUpdateOptions contains the optional parameters for the ReportClient.BeginUpdate method. type ReportClientBeginUpdateOptions struct { // Resumes the LRO from the provided token. ResumeToken string } +// ReportClientBeginVerifyOptions contains the optional parameters for the ReportClient.BeginVerify method. +type ReportClientBeginVerifyOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + // ReportClientGetOptions contains the optional parameters for the ReportClient.Get method. type ReportClientGetOptions struct { // placeholder for future optional parameters } -// ReportsClientListOptions contains the optional parameters for the ReportsClient.NewListPager method. -type ReportsClientListOptions struct { +// ReportClientGetScopingQuestionsOptions contains the optional parameters for the ReportClient.GetScopingQuestions method. +type ReportClientGetScopingQuestionsOptions struct { + // placeholder for future optional parameters +} + +// ReportClientListOptions contains the optional parameters for the ReportClient.NewListPager method. +type ReportClientListOptions 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,6 +168,34 @@ type ReportsClientListOptions struct { Top *int32 } +// ReportClientNestedResourceCheckNameAvailabilityOptions contains the optional parameters for the ReportClient.NestedResourceCheckNameAvailability +// method. +type ReportClientNestedResourceCheckNameAvailabilityOptions 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 +} + +// ScopingConfigurationClientListOptions contains the optional parameters for the ScopingConfigurationClient.NewListPager +// method. +type ScopingConfigurationClientListOptions struct { + // placeholder for future optional parameters +} + // SnapshotClientBeginDownloadOptions contains the optional parameters for the SnapshotClient.BeginDownload method. type SnapshotClientBeginDownloadOptions struct { // Resumes the LRO from the provided token. @@ -65,11 +207,17 @@ type SnapshotClientGetOptions struct { // placeholder for future optional parameters } -// SnapshotsClientListOptions contains the optional parameters for the SnapshotsClient.NewListPager method. -type SnapshotsClientListOptions struct { +// SnapshotClientListOptions contains the optional parameters for the SnapshotClient.NewListPager method. +type SnapshotClientListOptions 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 +230,47 @@ type SnapshotsClientListOptions struct { // Number of elements to return when retrieving results. Top *int32 } + +// WebhookClientCreateOrUpdateOptions contains the optional parameters for the WebhookClient.CreateOrUpdate method. +type WebhookClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// WebhookClientDeleteOptions contains the optional parameters for the WebhookClient.Delete method. +type WebhookClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// WebhookClientGetOptions contains the optional parameters for the WebhookClient.Get method. +type WebhookClientGetOptions struct { + // placeholder for future optional parameters +} + +// WebhookClientListOptions contains the optional parameters for the WebhookClient.NewListPager method. +type WebhookClientListOptions 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 +} + +// WebhookClientUpdateOptions contains the optional parameters for the WebhookClient.Update method. +type WebhookClientUpdateOptions 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..7c2a58ddb745 100644 --- a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/report_client.go +++ b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/report_client.go @@ -17,6 +17,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" "net/url" + "strconv" "strings" ) @@ -43,14 +44,14 @@ func NewReportClient(credential azcore.TokenCredential, options *arm.ClientOptio // 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 2022-11-16-preview +// Generated from API version 2024-06-27 // - reportName - Report Name. -// - parameters - Parameters for the create or update operation +// - properties - 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) { +func (client *ReportClient) BeginCreateOrUpdate(ctx context.Context, reportName string, properties ReportResource, options *ReportClientBeginCreateOrUpdateOptions) (*runtime.Poller[ReportClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { - resp, err := client.createOrUpdate(ctx, reportName, parameters, options) + resp, err := client.createOrUpdate(ctx, reportName, properties, options) if err != nil { return nil, err } @@ -69,14 +70,14 @@ func (client *ReportClient) BeginCreateOrUpdate(ctx context.Context, reportName // 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 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) createOrUpdate(ctx context.Context, reportName string, properties ReportResource, options *ReportClientBeginCreateOrUpdateOptions) (*http.Response, error) { var err error const operationName = "ReportClient.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) + req, err := client.createOrUpdateCreateRequest(ctx, reportName, properties, options) if err != nil { return nil, err } @@ -92,7 +93,7 @@ func (client *ReportClient) createOrUpdate(ctx context.Context, reportName strin } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *ReportClient) createOrUpdateCreateRequest(ctx context.Context, reportName string, parameters ReportResource, options *ReportClientBeginCreateOrUpdateOptions) (*policy.Request, error) { +func (client *ReportClient) createOrUpdateCreateRequest(ctx context.Context, reportName string, properties ReportResource, options *ReportClientBeginCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.AppComplianceAutomation/reports/{reportName}" if reportName == "" { return nil, errors.New("parameter reportName cannot be empty") @@ -103,10 +104,10 @@ func (client *ReportClient) createOrUpdateCreateRequest(ctx context.Context, rep 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 { + if err := runtime.MarshalAsJSON(req, properties); err != nil { return nil, err } return req, nil @@ -115,7 +116,7 @@ func (client *ReportClient) createOrUpdateCreateRequest(ctx context.Context, rep // BeginDelete - Delete an AppComplianceAutomation report. // 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. // - 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) { @@ -125,7 +126,7 @@ func (client *ReportClient) BeginDelete(ctx context.Context, reportName string, return nil, err } poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ReportClientDeleteResponse]{ - FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + FinalStateVia: runtime.FinalStateViaLocation, Tracer: client.internal.Tracer(), }) return poller, err @@ -139,7 +140,7 @@ func (client *ReportClient) BeginDelete(ctx context.Context, reportName string, // Delete - Delete an AppComplianceAutomation report. // 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 func (client *ReportClient) deleteOperation(ctx context.Context, reportName string, options *ReportClientBeginDeleteOptions) (*http.Response, error) { var err error const operationName = "ReportClient.BeginDelete" @@ -154,7 +155,7 @@ func (client *ReportClient) deleteOperation(ctx context.Context, reportName stri if err != nil { return nil, err } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + if !runtime.HasStatusCode(httpResp, http.StatusAccepted, http.StatusNoContent) { err = runtime.NewResponseError(httpResp) return nil, err } @@ -173,7 +174,76 @@ func (client *ReportClient) deleteCreateRequest(ctx context.Context, reportName 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 +} + +// 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 - ReportClientBeginFixOptions contains the optional parameters for the ReportClient.BeginFix method. +func (client *ReportClient) BeginFix(ctx context.Context, reportName string, options *ReportClientBeginFixOptions) (*runtime.Poller[ReportClientFixResponse], 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[ReportClientFixResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ReportClientFixResponse]{ + 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 *ReportClient) fix(ctx context.Context, reportName string, options *ReportClientBeginFixOptions) (*http.Response, error) { + var err error + const operationName = "ReportClient.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 *ReportClient) fixCreateRequest(ctx context.Context, reportName string, options *ReportClientBeginFixOptions) (*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 @@ -182,7 +252,7 @@ func (client *ReportClient) deleteCreateRequest(ctx context.Context, reportName // 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 +// Generated from API version 2024-06-27 // - 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) { @@ -219,7 +289,7 @@ func (client *ReportClient) getCreateRequest(ctx context.Context, reportName str 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 @@ -234,21 +304,282 @@ func (client *ReportClient) getHandleResponse(resp *http.Response) (ReportClient return result, 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 - ReportClientGetScopingQuestionsOptions contains the optional parameters for the ReportClient.GetScopingQuestions +// method. +func (client *ReportClient) GetScopingQuestions(ctx context.Context, reportName string, options *ReportClientGetScopingQuestionsOptions) (ReportClientGetScopingQuestionsResponse, error) { + var err error + const operationName = "ReportClient.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 ReportClientGetScopingQuestionsResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ReportClientGetScopingQuestionsResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ReportClientGetScopingQuestionsResponse{}, err + } + resp, err := client.getScopingQuestionsHandleResponse(httpResp) + return resp, err +} + +// getScopingQuestionsCreateRequest creates the GetScopingQuestions request. +func (client *ReportClient) getScopingQuestionsCreateRequest(ctx context.Context, reportName string, options *ReportClientGetScopingQuestionsOptions) (*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 *ReportClient) getScopingQuestionsHandleResponse(resp *http.Response) (ReportClientGetScopingQuestionsResponse, error) { + result := ReportClientGetScopingQuestionsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ScopingQuestions); err != nil { + return ReportClientGetScopingQuestionsResponse{}, err + } + return result, nil +} + +// NewListPager - Get the AppComplianceAutomation report list for the tenant. +// +// Generated from API version 2024-06-27 +// - options - ReportClientListOptions contains the optional parameters for the ReportClient.NewListPager method. +func (client *ReportClient) NewListPager(options *ReportClientListOptions) *runtime.Pager[ReportClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[ReportClientListResponse]{ + More: func(page ReportClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ReportClientListResponse) (ReportClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ReportClient.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, options) + }, nil) + if err != nil { + return ReportClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *ReportClient) listCreateRequest(ctx context.Context, options *ReportClientListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.AppComplianceAutomation/reports" + 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 *ReportClient) listHandleResponse(resp *http.Response) (ReportClientListResponse, error) { + result := ReportClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ReportResourceListResult); err != nil { + return ReportClientListResponse{}, 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 - ReportClientNestedResourceCheckNameAvailabilityOptions contains the optional parameters for the ReportClient.NestedResourceCheckNameAvailability +// method. +func (client *ReportClient) NestedResourceCheckNameAvailability(ctx context.Context, reportName string, body CheckNameAvailabilityRequest, options *ReportClientNestedResourceCheckNameAvailabilityOptions) (ReportClientNestedResourceCheckNameAvailabilityResponse, error) { + var err error + const operationName = "ReportClient.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 ReportClientNestedResourceCheckNameAvailabilityResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ReportClientNestedResourceCheckNameAvailabilityResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ReportClientNestedResourceCheckNameAvailabilityResponse{}, err + } + resp, err := client.nestedResourceCheckNameAvailabilityHandleResponse(httpResp) + return resp, err +} + +// nestedResourceCheckNameAvailabilityCreateRequest creates the NestedResourceCheckNameAvailability request. +func (client *ReportClient) nestedResourceCheckNameAvailabilityCreateRequest(ctx context.Context, reportName string, body CheckNameAvailabilityRequest, options *ReportClientNestedResourceCheckNameAvailabilityOptions) (*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 *ReportClient) nestedResourceCheckNameAvailabilityHandleResponse(resp *http.Response) (ReportClientNestedResourceCheckNameAvailabilityResponse, error) { + result := ReportClientNestedResourceCheckNameAvailabilityResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CheckNameAvailabilityResponse); err != nil { + return ReportClientNestedResourceCheckNameAvailabilityResponse{}, 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 - ReportClientBeginSyncCertRecordOptions contains the optional parameters for the ReportClient.BeginSyncCertRecord +// method. +func (client *ReportClient) BeginSyncCertRecord(ctx context.Context, reportName string, body SyncCertRecordRequest, options *ReportClientBeginSyncCertRecordOptions) (*runtime.Poller[ReportClientSyncCertRecordResponse], 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[ReportClientSyncCertRecordResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ReportClientSyncCertRecordResponse]{ + 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 *ReportClient) syncCertRecord(ctx context.Context, reportName string, body SyncCertRecordRequest, options *ReportClientBeginSyncCertRecordOptions) (*http.Response, error) { + var err error + const operationName = "ReportClient.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 *ReportClient) syncCertRecordCreateRequest(ctx context.Context, reportName string, body SyncCertRecordRequest, options *ReportClientBeginSyncCertRecordOptions) (*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 2022-11-16-preview +// Generated from API version 2024-06-27 // - reportName - Report Name. -// - parameters - Parameters for the create or update operation +// - properties - 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) { +func (client *ReportClient) BeginUpdate(ctx context.Context, reportName string, properties ReportResourcePatch, options *ReportClientBeginUpdateOptions) (*runtime.Poller[ReportClientUpdateResponse], error) { if options == nil || options.ResumeToken == "" { - resp, err := client.update(ctx, reportName, parameters, options) + resp, err := client.update(ctx, reportName, properties, options) if err != nil { return nil, err } poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ReportClientUpdateResponse]{ - FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + FinalStateVia: runtime.FinalStateViaLocation, Tracer: client.internal.Tracer(), }) return poller, err @@ -262,14 +593,14 @@ func (client *ReportClient) BeginUpdate(ctx context.Context, reportName string, // 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) { +// Generated from API version 2024-06-27 +func (client *ReportClient) update(ctx context.Context, reportName string, properties 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) + req, err := client.updateCreateRequest(ctx, reportName, properties, options) if err != nil { return nil, err } @@ -277,7 +608,7 @@ func (client *ReportClient) update(ctx context.Context, reportName string, param if err != nil { return nil, err } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated, http.StatusAccepted) { + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { err = runtime.NewResponseError(httpResp) return nil, err } @@ -285,7 +616,7 @@ func (client *ReportClient) update(ctx context.Context, reportName string, param } // updateCreateRequest creates the Update request. -func (client *ReportClient) updateCreateRequest(ctx context.Context, reportName string, parameters ReportResourcePatch, options *ReportClientBeginUpdateOptions) (*policy.Request, error) { +func (client *ReportClient) updateCreateRequest(ctx context.Context, reportName string, properties ReportResourcePatch, options *ReportClientBeginUpdateOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.AppComplianceAutomation/reports/{reportName}" if reportName == "" { return nil, errors.New("parameter reportName cannot be empty") @@ -296,11 +627,78 @@ func (client *ReportClient) updateCreateRequest(ctx context.Context, reportName 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 { + if err := runtime.MarshalAsJSON(req, properties); err != nil { return nil, err } return req, nil } + +// BeginVerify - Verify the AppComplianceAutomation report health status. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-06-27 +// - reportName - Report Name. +// - 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.verify(ctx, reportName, options) + if err != nil { + return nil, err + } + 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[ReportClientVerifyResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Verify - Verify the AppComplianceAutomation report health status. +// If the operation fails it returns an *azcore.ResponseError type. +// +// 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.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.verifyCreateRequest(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 +} + +// 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.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 +} 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 deleted file mode 100644 index f12c081fa922..000000000000 --- a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/reports_client.go +++ /dev/null @@ -1,104 +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" - "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" - "strconv" -) - -// ReportsClient contains the methods for the Reports group. -// Don't use this type directly, use NewReportsClient() instead. -type ReportsClient struct { - internal *arm.Client -} - -// NewReportsClient creates a new instance of ReportsClient with the specified values. -// - credential - used to authorize requests. Usually a credential from azidentity. -// - options - pass nil to accept the default values. -func NewReportsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*ReportsClient, error) { - cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) - if err != nil { - return nil, err - } - client := &ReportsClient{ - internal: cl, - } - return client, nil -} - -// NewListPager - Get the AppComplianceAutomation report list for the tenant. -// -// Generated from API version 2022-11-16-preview -// - 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]{ - More: func(page ReportsClientListResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *ReportsClientListResponse) (ReportsClientListResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ReportsClient.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, options) - }, nil) - if err != nil { - return ReportsClientListResponse{}, err - } - return client.listHandleResponse(resp) - }, - Tracer: client.internal.Tracer(), - }) -} - -// listCreateRequest creates the List request. -func (client *ReportsClient) listCreateRequest(ctx context.Context, options *ReportsClientListOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.AppComplianceAutomation/reports" - 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") - 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) - } - 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 *ReportsClient) listHandleResponse(resp *http.Response) (ReportsClientListResponse, error) { - result := ReportsClientListResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.ReportResourceList); err != nil { - return ReportsClientListResponse{}, err - } - return result, 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..2400d7beb9d3 --- /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 + +// EvidenceClientCreateOrUpdateResponse contains the response from method EvidenceClient.CreateOrUpdate. +type EvidenceClientCreateOrUpdateResponse struct { + // A class represent an AppComplianceAutomation evidence resource. + EvidenceResource +} + +// EvidenceClientDeleteResponse contains the response from method EvidenceClient.Delete. +type EvidenceClientDeleteResponse struct { + // placeholder for future response values +} + +// EvidenceClientDownloadResponse contains the response from method EvidenceClient.Download. +type EvidenceClientDownloadResponse struct { + // Object that includes all the possible response for the evidence file download operation. + EvidenceFileDownloadResponse +} + +// EvidenceClientGetResponse contains the response from method EvidenceClient.Get. +type EvidenceClientGetResponse struct { + // A class represent an AppComplianceAutomation evidence resource. + EvidenceResource +} + +// EvidenceClientListByReportResponse contains the response from method EvidenceClient.NewListByReportPager. +type EvidenceClientListByReportResponse 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 +} + +// 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 +} + +// ReportClientFixResponse contains the response from method ReportClient.BeginFix. +type ReportClientFixResponse struct { + // Report fix result. + ReportFixResult +} + +// ReportClientGetResponse contains the response from method ReportClient.Get. +type ReportClientGetResponse struct { + // A class represent an AppComplianceAutomation report resource. + ReportResource +} + +// ReportClientGetScopingQuestionsResponse contains the response from method ReportClient.GetScopingQuestions. +type ReportClientGetScopingQuestionsResponse struct { + // Scoping question list. + ScopingQuestions +} + +// ReportClientListResponse contains the response from method ReportClient.NewListPager. +type ReportClientListResponse struct { + // The response of a ReportResource list operation. + ReportResourceListResult +} + +// ReportClientNestedResourceCheckNameAvailabilityResponse contains the response from method ReportClient.NestedResourceCheckNameAvailability. +type ReportClientNestedResourceCheckNameAvailabilityResponse struct { + // The check availability result. + CheckNameAvailabilityResponse +} + +// ReportClientSyncCertRecordResponse contains the response from method ReportClient.BeginSyncCertRecord. +type ReportClientSyncCertRecordResponse struct { + // Synchronize certification record response. + SyncCertRecordResponse +} + +// ReportClientUpdateResponse contains the response from method ReportClient.BeginUpdate. +type ReportClientUpdateResponse struct { + // A class represent an AppComplianceAutomation report resource. + ReportResource +} + +// ReportClientVerifyResponse contains the response from method ReportClient.BeginVerify. +type ReportClientVerifyResponse struct { + // Report health status verification result. + ReportVerificationResult +} + +// 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 +} + +// ScopingConfigurationClientListResponse contains the response from method ScopingConfigurationClient.NewListPager. +type ScopingConfigurationClientListResponse struct { + // The response of a ScopingConfigurationResource list operation. + ScopingConfigurationResourceListResult +} + +// 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 +} + +// SnapshotClientListResponse contains the response from method SnapshotClient.NewListPager. +type SnapshotClientListResponse struct { + // The response of a SnapshotResource list operation. + SnapshotResourceListResult +} + +// WebhookClientCreateOrUpdateResponse contains the response from method WebhookClient.CreateOrUpdate. +type WebhookClientCreateOrUpdateResponse struct { + // A class represent an AppComplianceAutomation webhook resource. + WebhookResource +} + +// WebhookClientDeleteResponse contains the response from method WebhookClient.Delete. +type WebhookClientDeleteResponse struct { + // placeholder for future response values +} + +// WebhookClientGetResponse contains the response from method WebhookClient.Get. +type WebhookClientGetResponse struct { + // A class represent an AppComplianceAutomation webhook resource. + WebhookResource +} + +// WebhookClientListResponse contains the response from method WebhookClient.NewListPager. +type WebhookClientListResponse struct { + // The response of a WebhookResource list operation. + WebhookResourceListResult +} + +// WebhookClientUpdateResponse contains the response from method WebhookClient.Update. +type WebhookClientUpdateResponse 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..4d795ce7a504 --- /dev/null +++ b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/scopingconfiguration_client.go @@ -0,0 +1,275 @@ +//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. +// - properties - 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, properties 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, properties, 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, properties 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, properties); 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 +} + +// NewListPager - Returns a list format of the singleton scopingConfiguration for a specified report. +// +// Generated from API version 2024-06-27 +// - reportName - Report Name. +// - options - ScopingConfigurationClientListOptions contains the optional parameters for the ScopingConfigurationClient.NewListPager +// method. +func (client *ScopingConfigurationClient) NewListPager(reportName string, options *ScopingConfigurationClientListOptions) *runtime.Pager[ScopingConfigurationClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[ScopingConfigurationClientListResponse]{ + More: func(page ScopingConfigurationClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ScopingConfigurationClientListResponse) (ScopingConfigurationClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ScopingConfigurationClient.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 ScopingConfigurationClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *ScopingConfigurationClient) listCreateRequest(ctx context.Context, reportName string, options *ScopingConfigurationClientListOptions) (*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 *ScopingConfigurationClient) listHandleResponse(resp *http.Response) (ScopingConfigurationClientListResponse, error) { + result := ScopingConfigurationClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ScopingConfigurationResourceListResult); err != nil { + return ScopingConfigurationClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/snapshot_client.go b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/snapshot_client.go index 2962582f79c6..d4bd1a0a8ebd 100644 --- a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/snapshot_client.go +++ b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/snapshot_client.go @@ -17,6 +17,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" "net/url" + "strconv" "strings" ) @@ -43,19 +44,19 @@ func NewSnapshotClient(credential azcore.TokenCredential, options *arm.ClientOpt // 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 +// Generated from API version 2024-06-27 // - reportName - Report Name. // - snapshotName - Snapshot Name. -// - parameters - Parameters for the query operation +// - body - 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) { +func (client *SnapshotClient) BeginDownload(ctx context.Context, reportName string, snapshotName string, body SnapshotDownloadRequest, options *SnapshotClientBeginDownloadOptions) (*runtime.Poller[SnapshotClientDownloadResponse], error) { if options == nil || options.ResumeToken == "" { - resp, err := client.download(ctx, reportName, snapshotName, parameters, options) + 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[SnapshotClientDownloadResponse]{ - FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + FinalStateVia: runtime.FinalStateViaLocation, Tracer: client.internal.Tracer(), }) return poller, err @@ -69,14 +70,14 @@ func (client *SnapshotClient) BeginDownload(ctx context.Context, reportName stri // 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) { +// Generated from API version 2024-06-27 +func (client *SnapshotClient) download(ctx context.Context, reportName string, snapshotName string, body 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) + req, err := client.downloadCreateRequest(ctx, reportName, snapshotName, body, options) if err != nil { return nil, err } @@ -92,7 +93,7 @@ func (client *SnapshotClient) download(ctx context.Context, reportName string, s } // downloadCreateRequest creates the Download request. -func (client *SnapshotClient) downloadCreateRequest(ctx context.Context, reportName string, snapshotName string, parameters SnapshotDownloadRequest, options *SnapshotClientBeginDownloadOptions) (*policy.Request, error) { +func (client *SnapshotClient) downloadCreateRequest(ctx context.Context, reportName string, snapshotName string, body 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") @@ -107,10 +108,10 @@ func (client *SnapshotClient) downloadCreateRequest(ctx context.Context, reportN 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 { + if err := runtime.MarshalAsJSON(req, body); err != nil { return nil, err } return req, nil @@ -119,7 +120,7 @@ func (client *SnapshotClient) downloadCreateRequest(ctx context.Context, reportN // 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 +// Generated from API version 2024-06-27 // - reportName - Report Name. // - snapshotName - Snapshot Name. // - options - SnapshotClientGetOptions contains the optional parameters for the SnapshotClient.Get method. @@ -161,7 +162,7 @@ func (client *SnapshotClient) getCreateRequest(ctx context.Context, reportName s 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 @@ -175,3 +176,79 @@ func (client *SnapshotClient) getHandleResponse(resp *http.Response) (SnapshotCl } return result, nil } + +// NewListPager - Get the AppComplianceAutomation snapshot list. +// +// Generated from API version 2024-06-27 +// - reportName - Report Name. +// - options - SnapshotClientListOptions contains the optional parameters for the SnapshotClient.NewListPager method. +func (client *SnapshotClient) NewListPager(reportName string, options *SnapshotClientListOptions) *runtime.Pager[SnapshotClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[SnapshotClientListResponse]{ + More: func(page SnapshotClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *SnapshotClientListResponse) (SnapshotClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "SnapshotClient.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 SnapshotClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *SnapshotClient) listCreateRequest(ctx context.Context, reportName string, options *SnapshotClientListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.AppComplianceAutomation/reports/{reportName}/snapshots" + 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 *SnapshotClient) listHandleResponse(resp *http.Response) (SnapshotClientListResponse, error) { + result := SnapshotClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SnapshotResourceListResult); err != nil { + return SnapshotClientListResponse{}, 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 deleted file mode 100644 index 6de95508cd93..000000000000 --- a/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/snapshots_client.go +++ /dev/null @@ -1,112 +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" - "strconv" - "strings" -) - -// SnapshotsClient contains the methods for the Snapshots group. -// Don't use this type directly, use NewSnapshotsClient() instead. -type SnapshotsClient struct { - internal *arm.Client -} - -// NewSnapshotsClient creates a new instance of SnapshotsClient with the specified values. -// - credential - used to authorize requests. Usually a credential from azidentity. -// - options - pass nil to accept the default values. -func NewSnapshotsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*SnapshotsClient, error) { - cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) - if err != nil { - return nil, err - } - client := &SnapshotsClient{ - internal: cl, - } - return client, nil -} - -// NewListPager - Get the AppComplianceAutomation snapshot list. -// -// Generated from API version 2022-11-16-preview -// - 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] { - return runtime.NewPager(runtime.PagingHandler[SnapshotsClientListResponse]{ - More: func(page SnapshotsClientListResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *SnapshotsClientListResponse) (SnapshotsClientListResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "SnapshotsClient.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 SnapshotsClientListResponse{}, err - } - return client.listHandleResponse(resp) - }, - Tracer: client.internal.Tracer(), - }) -} - -// listCreateRequest creates the List request. -func (client *SnapshotsClient) listCreateRequest(ctx context.Context, reportName string, options *SnapshotsClientListOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.AppComplianceAutomation/reports/{reportName}/snapshots" - 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") - 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) - } - 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 -} - -// 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 { - 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/webhook_client.go b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/webhook_client.go new file mode 100644 index 000000000000..823d2170677f --- /dev/null +++ b/sdk/resourcemanager/appcomplianceautomation/armappcomplianceautomation/webhook_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" +) + +// WebhookClient contains the methods for the Webhook group. +// Don't use this type directly, use NewWebhookClient() instead. +type WebhookClient struct { + internal *arm.Client +} + +// NewWebhookClient creates a new instance of WebhookClient with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewWebhookClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*WebhookClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &WebhookClient{ + 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. +// - properties - Parameters for the create or update operation +// - options - WebhookClientCreateOrUpdateOptions contains the optional parameters for the WebhookClient.CreateOrUpdate method. +func (client *WebhookClient) CreateOrUpdate(ctx context.Context, reportName string, webhookName string, properties WebhookResource, options *WebhookClientCreateOrUpdateOptions) (WebhookClientCreateOrUpdateResponse, error) { + var err error + const operationName = "WebhookClient.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, properties, options) + if err != nil { + return WebhookClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WebhookClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return WebhookClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *WebhookClient) createOrUpdateCreateRequest(ctx context.Context, reportName string, webhookName string, properties WebhookResource, options *WebhookClientCreateOrUpdateOptions) (*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, properties); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *WebhookClient) createOrUpdateHandleResponse(resp *http.Response) (WebhookClientCreateOrUpdateResponse, error) { + result := WebhookClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.WebhookResource); err != nil { + return WebhookClientCreateOrUpdateResponse{}, 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 - WebhookClientDeleteOptions contains the optional parameters for the WebhookClient.Delete method. +func (client *WebhookClient) Delete(ctx context.Context, reportName string, webhookName string, options *WebhookClientDeleteOptions) (WebhookClientDeleteResponse, error) { + var err error + const operationName = "WebhookClient.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 WebhookClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WebhookClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return WebhookClientDeleteResponse{}, err + } + return WebhookClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *WebhookClient) deleteCreateRequest(ctx context.Context, reportName string, webhookName string, options *WebhookClientDeleteOptions) (*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 - WebhookClientGetOptions contains the optional parameters for the WebhookClient.Get method. +func (client *WebhookClient) Get(ctx context.Context, reportName string, webhookName string, options *WebhookClientGetOptions) (WebhookClientGetResponse, error) { + var err error + const operationName = "WebhookClient.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 WebhookClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WebhookClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WebhookClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *WebhookClient) getCreateRequest(ctx context.Context, reportName string, webhookName string, options *WebhookClientGetOptions) (*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 *WebhookClient) getHandleResponse(resp *http.Response) (WebhookClientGetResponse, error) { + result := WebhookClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.WebhookResource); err != nil { + return WebhookClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - Get the AppComplianceAutomation webhook list. +// +// Generated from API version 2024-06-27 +// - reportName - Report Name. +// - options - WebhookClientListOptions contains the optional parameters for the WebhookClient.NewListPager method. +func (client *WebhookClient) NewListPager(reportName string, options *WebhookClientListOptions) *runtime.Pager[WebhookClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[WebhookClientListResponse]{ + More: func(page WebhookClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *WebhookClientListResponse) (WebhookClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "WebhookClient.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 WebhookClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *WebhookClient) listCreateRequest(ctx context.Context, reportName string, options *WebhookClientListOptions) (*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 *WebhookClient) listHandleResponse(resp *http.Response) (WebhookClientListResponse, error) { + result := WebhookClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.WebhookResourceListResult); err != nil { + return WebhookClientListResponse{}, 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 - WebhookClientUpdateOptions contains the optional parameters for the WebhookClient.Update method. +func (client *WebhookClient) Update(ctx context.Context, reportName string, webhookName string, properties WebhookResourcePatch, options *WebhookClientUpdateOptions) (WebhookClientUpdateResponse, error) { + var err error + const operationName = "WebhookClient.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 WebhookClientUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WebhookClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WebhookClientUpdateResponse{}, err + } + resp, err := client.updateHandleResponse(httpResp) + return resp, err +} + +// updateCreateRequest creates the Update request. +func (client *WebhookClient) updateCreateRequest(ctx context.Context, reportName string, webhookName string, properties WebhookResourcePatch, options *WebhookClientUpdateOptions) (*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 *WebhookClient) updateHandleResponse(resp *http.Response) (WebhookClientUpdateResponse, error) { + result := WebhookClientUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.WebhookResource); err != nil { + return WebhookClientUpdateResponse{}, err + } + return result, nil +}