diff --git a/profiles/preview/preview/security/mgmt/security/models.go b/profiles/preview/preview/security/mgmt/security/models.go index 849c043f978a..c588ff5e487b 100644 --- a/profiles/preview/preview/security/mgmt/security/models.go +++ b/profiles/preview/preview/security/mgmt/security/models.go @@ -122,6 +122,15 @@ const ( SettingKindDataExportSetting SettingKind = original.SettingKindDataExportSetting ) +type State = original.State + +const ( + Failed State = original.Failed + Passed State = original.Passed + Skipped State = original.Skipped + Unsupported State = original.Unsupported +) + type Status = original.Status const ( @@ -242,6 +251,24 @@ type Pricing = original.Pricing type PricingList = original.PricingList type PricingProperties = original.PricingProperties type PricingsClient = original.PricingsClient +type RegulatoryComplianceAssessment = original.RegulatoryComplianceAssessment +type RegulatoryComplianceAssessmentList = original.RegulatoryComplianceAssessmentList +type RegulatoryComplianceAssessmentListIterator = original.RegulatoryComplianceAssessmentListIterator +type RegulatoryComplianceAssessmentListPage = original.RegulatoryComplianceAssessmentListPage +type RegulatoryComplianceAssessmentProperties = original.RegulatoryComplianceAssessmentProperties +type RegulatoryComplianceAssessmentsClient = original.RegulatoryComplianceAssessmentsClient +type RegulatoryComplianceControl = original.RegulatoryComplianceControl +type RegulatoryComplianceControlList = original.RegulatoryComplianceControlList +type RegulatoryComplianceControlListIterator = original.RegulatoryComplianceControlListIterator +type RegulatoryComplianceControlListPage = original.RegulatoryComplianceControlListPage +type RegulatoryComplianceControlProperties = original.RegulatoryComplianceControlProperties +type RegulatoryComplianceControlsClient = original.RegulatoryComplianceControlsClient +type RegulatoryComplianceStandard = original.RegulatoryComplianceStandard +type RegulatoryComplianceStandardList = original.RegulatoryComplianceStandardList +type RegulatoryComplianceStandardListIterator = original.RegulatoryComplianceStandardListIterator +type RegulatoryComplianceStandardListPage = original.RegulatoryComplianceStandardListPage +type RegulatoryComplianceStandardProperties = original.RegulatoryComplianceStandardProperties +type RegulatoryComplianceStandardsClient = original.RegulatoryComplianceStandardsClient type Resource = original.Resource type SensitivityLabel = original.SensitivityLabel type Setting = original.Setting @@ -420,6 +447,42 @@ func NewPricingsClient(subscriptionID string, ascLocation string) PricingsClient func NewPricingsClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) PricingsClient { return original.NewPricingsClientWithBaseURI(baseURI, subscriptionID, ascLocation) } +func NewRegulatoryComplianceAssessmentListIterator(page RegulatoryComplianceAssessmentListPage) RegulatoryComplianceAssessmentListIterator { + return original.NewRegulatoryComplianceAssessmentListIterator(page) +} +func NewRegulatoryComplianceAssessmentListPage(getNextPage func(context.Context, RegulatoryComplianceAssessmentList) (RegulatoryComplianceAssessmentList, error)) RegulatoryComplianceAssessmentListPage { + return original.NewRegulatoryComplianceAssessmentListPage(getNextPage) +} +func NewRegulatoryComplianceAssessmentsClient(subscriptionID string, ascLocation string) RegulatoryComplianceAssessmentsClient { + return original.NewRegulatoryComplianceAssessmentsClient(subscriptionID, ascLocation) +} +func NewRegulatoryComplianceAssessmentsClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) RegulatoryComplianceAssessmentsClient { + return original.NewRegulatoryComplianceAssessmentsClientWithBaseURI(baseURI, subscriptionID, ascLocation) +} +func NewRegulatoryComplianceControlListIterator(page RegulatoryComplianceControlListPage) RegulatoryComplianceControlListIterator { + return original.NewRegulatoryComplianceControlListIterator(page) +} +func NewRegulatoryComplianceControlListPage(getNextPage func(context.Context, RegulatoryComplianceControlList) (RegulatoryComplianceControlList, error)) RegulatoryComplianceControlListPage { + return original.NewRegulatoryComplianceControlListPage(getNextPage) +} +func NewRegulatoryComplianceControlsClient(subscriptionID string, ascLocation string) RegulatoryComplianceControlsClient { + return original.NewRegulatoryComplianceControlsClient(subscriptionID, ascLocation) +} +func NewRegulatoryComplianceControlsClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) RegulatoryComplianceControlsClient { + return original.NewRegulatoryComplianceControlsClientWithBaseURI(baseURI, subscriptionID, ascLocation) +} +func NewRegulatoryComplianceStandardListIterator(page RegulatoryComplianceStandardListPage) RegulatoryComplianceStandardListIterator { + return original.NewRegulatoryComplianceStandardListIterator(page) +} +func NewRegulatoryComplianceStandardListPage(getNextPage func(context.Context, RegulatoryComplianceStandardList) (RegulatoryComplianceStandardList, error)) RegulatoryComplianceStandardListPage { + return original.NewRegulatoryComplianceStandardListPage(getNextPage) +} +func NewRegulatoryComplianceStandardsClient(subscriptionID string, ascLocation string) RegulatoryComplianceStandardsClient { + return original.NewRegulatoryComplianceStandardsClient(subscriptionID, ascLocation) +} +func NewRegulatoryComplianceStandardsClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) RegulatoryComplianceStandardsClient { + return original.NewRegulatoryComplianceStandardsClientWithBaseURI(baseURI, subscriptionID, ascLocation) +} func NewSettingsClient(subscriptionID string, ascLocation string) SettingsClient { return original.NewSettingsClient(subscriptionID, ascLocation) } @@ -507,6 +570,9 @@ func PossibleReportedSeverityValues() []ReportedSeverity { func PossibleSettingKindValues() []SettingKind { return original.PossibleSettingKindValues() } +func PossibleStateValues() []State { + return original.PossibleStateValues() +} func PossibleStatusReasonValues() []StatusReason { return original.PossibleStatusReasonValues() } diff --git a/profiles/preview/preview/security/mgmt/security/securityapi/models.go b/profiles/preview/preview/security/mgmt/security/securityapi/models.go index ee674663e5ce..52e04ed3e409 100644 --- a/profiles/preview/preview/security/mgmt/security/securityapi/models.go +++ b/profiles/preview/preview/security/mgmt/security/securityapi/models.go @@ -34,6 +34,9 @@ type JitNetworkAccessPoliciesClientAPI = original.JitNetworkAccessPoliciesClient type LocationsClientAPI = original.LocationsClientAPI type OperationsClientAPI = original.OperationsClientAPI type PricingsClientAPI = original.PricingsClientAPI +type RegulatoryComplianceAssessmentsClientAPI = original.RegulatoryComplianceAssessmentsClientAPI +type RegulatoryComplianceControlsClientAPI = original.RegulatoryComplianceControlsClientAPI +type RegulatoryComplianceStandardsClientAPI = original.RegulatoryComplianceStandardsClientAPI type SettingsClientAPI = original.SettingsClientAPI type TasksClientAPI = original.TasksClientAPI type TopologyClientAPI = original.TopologyClientAPI diff --git a/services/preview/security/mgmt/v1.0/security/models.go b/services/preview/security/mgmt/v1.0/security/models.go index 6edbc07f29ac..4cb7abd729b5 100644 --- a/services/preview/security/mgmt/v1.0/security/models.go +++ b/services/preview/security/mgmt/v1.0/security/models.go @@ -229,6 +229,25 @@ func PossibleSettingKindValues() []SettingKind { return []SettingKind{SettingKindAlertSuppressionSetting, SettingKindDataExportSetting} } +// State enumerates the values for state. +type State string + +const ( + // Failed At least one supported regulatory compliance control in the given standard has a state of failed + Failed State = "Failed" + // Passed All supported regulatory compliance controls in the given standard have a passed state + Passed State = "Passed" + // Skipped All supported regulatory compliance controls in the given standard have a state of skipped + Skipped State = "Skipped" + // Unsupported No supported regulatory compliance data for the given standard + Unsupported State = "Unsupported" +) + +// PossibleStateValues returns an array of possible values for the State const type. +func PossibleStateValues() []State { + return []State{Failed, Passed, Skipped, Unsupported} +} + // Status enumerates the values for status. type Status string @@ -4179,6 +4198,739 @@ type PricingProperties struct { PricingTier PricingTier `json:"pricingTier,omitempty"` } +// RegulatoryComplianceAssessment regulatory compliance assessment details and state +type RegulatoryComplianceAssessment struct { + autorest.Response `json:"-"` + // RegulatoryComplianceAssessmentProperties - Regulatory compliance assessment data + *RegulatoryComplianceAssessmentProperties `json:"properties,omitempty"` + // ID - Resource Id + ID *string `json:"id,omitempty"` + // Name - Resource name + Name *string `json:"name,omitempty"` + // Type - Resource type + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for RegulatoryComplianceAssessment. +func (rca RegulatoryComplianceAssessment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rca.RegulatoryComplianceAssessmentProperties != nil { + objectMap["properties"] = rca.RegulatoryComplianceAssessmentProperties + } + if rca.ID != nil { + objectMap["id"] = rca.ID + } + if rca.Name != nil { + objectMap["name"] = rca.Name + } + if rca.Type != nil { + objectMap["type"] = rca.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RegulatoryComplianceAssessment struct. +func (rca *RegulatoryComplianceAssessment) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var regulatoryComplianceAssessmentProperties RegulatoryComplianceAssessmentProperties + err = json.Unmarshal(*v, ®ulatoryComplianceAssessmentProperties) + if err != nil { + return err + } + rca.RegulatoryComplianceAssessmentProperties = ®ulatoryComplianceAssessmentProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + rca.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rca.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + rca.Type = &typeVar + } + } + } + + return nil +} + +// RegulatoryComplianceAssessmentList list of regulatory compliance assessment response +type RegulatoryComplianceAssessmentList struct { + autorest.Response `json:"-"` + Value *[]RegulatoryComplianceAssessment `json:"value,omitempty"` + // NextLink - The URI to fetch the next page. + NextLink *string `json:"nextLink,omitempty"` +} + +// RegulatoryComplianceAssessmentListIterator provides access to a complete listing of +// RegulatoryComplianceAssessment values. +type RegulatoryComplianceAssessmentListIterator struct { + i int + page RegulatoryComplianceAssessmentListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *RegulatoryComplianceAssessmentListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegulatoryComplianceAssessmentListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *RegulatoryComplianceAssessmentListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter RegulatoryComplianceAssessmentListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter RegulatoryComplianceAssessmentListIterator) Response() RegulatoryComplianceAssessmentList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter RegulatoryComplianceAssessmentListIterator) Value() RegulatoryComplianceAssessment { + if !iter.page.NotDone() { + return RegulatoryComplianceAssessment{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the RegulatoryComplianceAssessmentListIterator type. +func NewRegulatoryComplianceAssessmentListIterator(page RegulatoryComplianceAssessmentListPage) RegulatoryComplianceAssessmentListIterator { + return RegulatoryComplianceAssessmentListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (rcal RegulatoryComplianceAssessmentList) IsEmpty() bool { + return rcal.Value == nil || len(*rcal.Value) == 0 +} + +// regulatoryComplianceAssessmentListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (rcal RegulatoryComplianceAssessmentList) regulatoryComplianceAssessmentListPreparer(ctx context.Context) (*http.Request, error) { + if rcal.NextLink == nil || len(to.String(rcal.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(rcal.NextLink))) +} + +// RegulatoryComplianceAssessmentListPage contains a page of RegulatoryComplianceAssessment values. +type RegulatoryComplianceAssessmentListPage struct { + fn func(context.Context, RegulatoryComplianceAssessmentList) (RegulatoryComplianceAssessmentList, error) + rcal RegulatoryComplianceAssessmentList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *RegulatoryComplianceAssessmentListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegulatoryComplianceAssessmentListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.rcal) + if err != nil { + return err + } + page.rcal = next + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *RegulatoryComplianceAssessmentListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page RegulatoryComplianceAssessmentListPage) NotDone() bool { + return !page.rcal.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page RegulatoryComplianceAssessmentListPage) Response() RegulatoryComplianceAssessmentList { + return page.rcal +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page RegulatoryComplianceAssessmentListPage) Values() []RegulatoryComplianceAssessment { + if page.rcal.IsEmpty() { + return nil + } + return *page.rcal.Value +} + +// Creates a new instance of the RegulatoryComplianceAssessmentListPage type. +func NewRegulatoryComplianceAssessmentListPage(getNextPage func(context.Context, RegulatoryComplianceAssessmentList) (RegulatoryComplianceAssessmentList, error)) RegulatoryComplianceAssessmentListPage { + return RegulatoryComplianceAssessmentListPage{fn: getNextPage} +} + +// RegulatoryComplianceAssessmentProperties regulatory compliance assessment data +type RegulatoryComplianceAssessmentProperties struct { + // Description - The description of the regulatory compliance assessment + Description *string `json:"description,omitempty"` + // AssessmentType - The expected type of assessment contained in the AssessmentDetailsLink + AssessmentType *string `json:"assessmentType,omitempty"` + // AssessmentDetailsLink - Link to more detailed assessment results data. The response type will be according to the assessmentType field + AssessmentDetailsLink *string `json:"assessmentDetailsLink,omitempty"` + // State - Aggregative state based on the assessment's scanned resources states. Possible values include: 'Passed', 'Failed', 'Skipped', 'Unsupported' + State State `json:"state,omitempty"` + // PassedResources - The given assessment's related resources count with passed state. + PassedResources *int32 `json:"passedResources,omitempty"` + // FailedResources - The given assessment's related resources count with failed state. + FailedResources *int32 `json:"failedResources,omitempty"` + // SkippedResources - The given assessment's related resources count with skipped state. + SkippedResources *int32 `json:"skippedResources,omitempty"` + // UnsupportedResources - The given assessment's related resources count with unsupported state. + UnsupportedResources *int32 `json:"unsupportedResources,omitempty"` +} + +// RegulatoryComplianceControl regulatory compliance control details and state +type RegulatoryComplianceControl struct { + autorest.Response `json:"-"` + // RegulatoryComplianceControlProperties - Regulatory compliance control data + *RegulatoryComplianceControlProperties `json:"properties,omitempty"` + // ID - Resource Id + ID *string `json:"id,omitempty"` + // Name - Resource name + Name *string `json:"name,omitempty"` + // Type - Resource type + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for RegulatoryComplianceControl. +func (rcc RegulatoryComplianceControl) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rcc.RegulatoryComplianceControlProperties != nil { + objectMap["properties"] = rcc.RegulatoryComplianceControlProperties + } + if rcc.ID != nil { + objectMap["id"] = rcc.ID + } + if rcc.Name != nil { + objectMap["name"] = rcc.Name + } + if rcc.Type != nil { + objectMap["type"] = rcc.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RegulatoryComplianceControl struct. +func (rcc *RegulatoryComplianceControl) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var regulatoryComplianceControlProperties RegulatoryComplianceControlProperties + err = json.Unmarshal(*v, ®ulatoryComplianceControlProperties) + if err != nil { + return err + } + rcc.RegulatoryComplianceControlProperties = ®ulatoryComplianceControlProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + rcc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rcc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + rcc.Type = &typeVar + } + } + } + + return nil +} + +// RegulatoryComplianceControlList list of regulatory compliance controls response +type RegulatoryComplianceControlList struct { + autorest.Response `json:"-"` + // Value - List of regulatory compliance controls + Value *[]RegulatoryComplianceControl `json:"value,omitempty"` + // NextLink - The URI to fetch the next page. + NextLink *string `json:"nextLink,omitempty"` +} + +// RegulatoryComplianceControlListIterator provides access to a complete listing of +// RegulatoryComplianceControl values. +type RegulatoryComplianceControlListIterator struct { + i int + page RegulatoryComplianceControlListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *RegulatoryComplianceControlListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegulatoryComplianceControlListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *RegulatoryComplianceControlListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter RegulatoryComplianceControlListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter RegulatoryComplianceControlListIterator) Response() RegulatoryComplianceControlList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter RegulatoryComplianceControlListIterator) Value() RegulatoryComplianceControl { + if !iter.page.NotDone() { + return RegulatoryComplianceControl{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the RegulatoryComplianceControlListIterator type. +func NewRegulatoryComplianceControlListIterator(page RegulatoryComplianceControlListPage) RegulatoryComplianceControlListIterator { + return RegulatoryComplianceControlListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (rccl RegulatoryComplianceControlList) IsEmpty() bool { + return rccl.Value == nil || len(*rccl.Value) == 0 +} + +// regulatoryComplianceControlListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (rccl RegulatoryComplianceControlList) regulatoryComplianceControlListPreparer(ctx context.Context) (*http.Request, error) { + if rccl.NextLink == nil || len(to.String(rccl.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(rccl.NextLink))) +} + +// RegulatoryComplianceControlListPage contains a page of RegulatoryComplianceControl values. +type RegulatoryComplianceControlListPage struct { + fn func(context.Context, RegulatoryComplianceControlList) (RegulatoryComplianceControlList, error) + rccl RegulatoryComplianceControlList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *RegulatoryComplianceControlListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegulatoryComplianceControlListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.rccl) + if err != nil { + return err + } + page.rccl = next + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *RegulatoryComplianceControlListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page RegulatoryComplianceControlListPage) NotDone() bool { + return !page.rccl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page RegulatoryComplianceControlListPage) Response() RegulatoryComplianceControlList { + return page.rccl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page RegulatoryComplianceControlListPage) Values() []RegulatoryComplianceControl { + if page.rccl.IsEmpty() { + return nil + } + return *page.rccl.Value +} + +// Creates a new instance of the RegulatoryComplianceControlListPage type. +func NewRegulatoryComplianceControlListPage(getNextPage func(context.Context, RegulatoryComplianceControlList) (RegulatoryComplianceControlList, error)) RegulatoryComplianceControlListPage { + return RegulatoryComplianceControlListPage{fn: getNextPage} +} + +// RegulatoryComplianceControlProperties regulatory compliance control data +type RegulatoryComplianceControlProperties struct { + // Description - The description of the regulatory compliance control + Description *string `json:"description,omitempty"` + // State - Aggregative state based on the control's supported assessments states. Possible values include: 'Passed', 'Failed', 'Skipped', 'Unsupported' + State State `json:"state,omitempty"` + // PassedAssessments - The number of supported regulatory compliance assessments of the given control with a passed state + PassedAssessments *int32 `json:"passedAssessments,omitempty"` + // FailedAssessments - The number of supported regulatory compliance assessments of the given control with a failed state + FailedAssessments *int32 `json:"failedAssessments,omitempty"` + // SkippedAssessments - The number of supported regulatory compliance assessments of the given control with a skipped state + SkippedAssessments *int32 `json:"skippedAssessments,omitempty"` +} + +// RegulatoryComplianceStandard regulatory compliance standard details and state +type RegulatoryComplianceStandard struct { + autorest.Response `json:"-"` + // RegulatoryComplianceStandardProperties - Regulatory compliance standard data + *RegulatoryComplianceStandardProperties `json:"properties,omitempty"` + // ID - Resource Id + ID *string `json:"id,omitempty"` + // Name - Resource name + Name *string `json:"name,omitempty"` + // Type - Resource type + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for RegulatoryComplianceStandard. +func (rcs RegulatoryComplianceStandard) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rcs.RegulatoryComplianceStandardProperties != nil { + objectMap["properties"] = rcs.RegulatoryComplianceStandardProperties + } + if rcs.ID != nil { + objectMap["id"] = rcs.ID + } + if rcs.Name != nil { + objectMap["name"] = rcs.Name + } + if rcs.Type != nil { + objectMap["type"] = rcs.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RegulatoryComplianceStandard struct. +func (rcs *RegulatoryComplianceStandard) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var regulatoryComplianceStandardProperties RegulatoryComplianceStandardProperties + err = json.Unmarshal(*v, ®ulatoryComplianceStandardProperties) + if err != nil { + return err + } + rcs.RegulatoryComplianceStandardProperties = ®ulatoryComplianceStandardProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + rcs.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rcs.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + rcs.Type = &typeVar + } + } + } + + return nil +} + +// RegulatoryComplianceStandardList list of regulatory compliance standards response +type RegulatoryComplianceStandardList struct { + autorest.Response `json:"-"` + Value *[]RegulatoryComplianceStandard `json:"value,omitempty"` + // NextLink - The URI to fetch the next page. + NextLink *string `json:"nextLink,omitempty"` +} + +// RegulatoryComplianceStandardListIterator provides access to a complete listing of +// RegulatoryComplianceStandard values. +type RegulatoryComplianceStandardListIterator struct { + i int + page RegulatoryComplianceStandardListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *RegulatoryComplianceStandardListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegulatoryComplianceStandardListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *RegulatoryComplianceStandardListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter RegulatoryComplianceStandardListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter RegulatoryComplianceStandardListIterator) Response() RegulatoryComplianceStandardList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter RegulatoryComplianceStandardListIterator) Value() RegulatoryComplianceStandard { + if !iter.page.NotDone() { + return RegulatoryComplianceStandard{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the RegulatoryComplianceStandardListIterator type. +func NewRegulatoryComplianceStandardListIterator(page RegulatoryComplianceStandardListPage) RegulatoryComplianceStandardListIterator { + return RegulatoryComplianceStandardListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (rcsl RegulatoryComplianceStandardList) IsEmpty() bool { + return rcsl.Value == nil || len(*rcsl.Value) == 0 +} + +// regulatoryComplianceStandardListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (rcsl RegulatoryComplianceStandardList) regulatoryComplianceStandardListPreparer(ctx context.Context) (*http.Request, error) { + if rcsl.NextLink == nil || len(to.String(rcsl.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(rcsl.NextLink))) +} + +// RegulatoryComplianceStandardListPage contains a page of RegulatoryComplianceStandard values. +type RegulatoryComplianceStandardListPage struct { + fn func(context.Context, RegulatoryComplianceStandardList) (RegulatoryComplianceStandardList, error) + rcsl RegulatoryComplianceStandardList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *RegulatoryComplianceStandardListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegulatoryComplianceStandardListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.rcsl) + if err != nil { + return err + } + page.rcsl = next + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *RegulatoryComplianceStandardListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page RegulatoryComplianceStandardListPage) NotDone() bool { + return !page.rcsl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page RegulatoryComplianceStandardListPage) Response() RegulatoryComplianceStandardList { + return page.rcsl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page RegulatoryComplianceStandardListPage) Values() []RegulatoryComplianceStandard { + if page.rcsl.IsEmpty() { + return nil + } + return *page.rcsl.Value +} + +// Creates a new instance of the RegulatoryComplianceStandardListPage type. +func NewRegulatoryComplianceStandardListPage(getNextPage func(context.Context, RegulatoryComplianceStandardList) (RegulatoryComplianceStandardList, error)) RegulatoryComplianceStandardListPage { + return RegulatoryComplianceStandardListPage{fn: getNextPage} +} + +// RegulatoryComplianceStandardProperties regulatory compliance standard data +type RegulatoryComplianceStandardProperties struct { + // State - Aggregative state based on the standard's supported controls states. Possible values include: 'Passed', 'Failed', 'Skipped', 'Unsupported' + State State `json:"state,omitempty"` + // PassedControls - The number of supported regulatory compliance controls of the given standard with a passed state + PassedControls *int32 `json:"passedControls,omitempty"` + // FailedControls - The number of supported regulatory compliance controls of the given standard with a failed state + FailedControls *int32 `json:"failedControls,omitempty"` + // SkippedControls - The number of supported regulatory compliance controls of the given standard with a skipped state + SkippedControls *int32 `json:"skippedControls,omitempty"` + // UnsupportedControls - The number of regulatory compliance controls of the given standard which are unsupported by automated assessments + UnsupportedControls *int32 `json:"unsupportedControls,omitempty"` +} + // Resource describes an Azure resource. type Resource struct { // ID - Resource Id diff --git a/services/preview/security/mgmt/v1.0/security/regulatorycomplianceassessments.go b/services/preview/security/mgmt/v1.0/security/regulatorycomplianceassessments.go new file mode 100644 index 000000000000..a03511f202bb --- /dev/null +++ b/services/preview/security/mgmt/v1.0/security/regulatorycomplianceassessments.go @@ -0,0 +1,268 @@ +package security + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// RegulatoryComplianceAssessmentsClient is the API spec for Microsoft.Security (Azure Security Center) resource +// provider +type RegulatoryComplianceAssessmentsClient struct { + BaseClient +} + +// NewRegulatoryComplianceAssessmentsClient creates an instance of the RegulatoryComplianceAssessmentsClient client. +func NewRegulatoryComplianceAssessmentsClient(subscriptionID string, ascLocation string) RegulatoryComplianceAssessmentsClient { + return NewRegulatoryComplianceAssessmentsClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewRegulatoryComplianceAssessmentsClientWithBaseURI creates an instance of the RegulatoryComplianceAssessmentsClient +// client. +func NewRegulatoryComplianceAssessmentsClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) RegulatoryComplianceAssessmentsClient { + return RegulatoryComplianceAssessmentsClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// Get supported regulatory compliance details and state for selected assessment +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// regulatoryComplianceStandardName - name of the regulatory compliance standard object +// regulatoryComplianceControlName - name of the regulatory compliance control object +// regulatoryComplianceAssessmentName - name of the regulatory compliance assessment object +func (client RegulatoryComplianceAssessmentsClient) Get(ctx context.Context, resourceGroupName string, regulatoryComplianceStandardName string, regulatoryComplianceControlName string, regulatoryComplianceAssessmentName string) (result RegulatoryComplianceAssessment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegulatoryComplianceAssessmentsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.RegulatoryComplianceAssessmentsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, regulatoryComplianceStandardName, regulatoryComplianceControlName, regulatoryComplianceAssessmentName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceAssessmentsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceAssessmentsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceAssessmentsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client RegulatoryComplianceAssessmentsClient) GetPreparer(ctx context.Context, resourceGroupName string, regulatoryComplianceStandardName string, regulatoryComplianceControlName string, regulatoryComplianceAssessmentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "regulatoryComplianceAssessmentName": autorest.Encode("path", regulatoryComplianceAssessmentName), + "regulatoryComplianceControlName": autorest.Encode("path", regulatoryComplianceControlName), + "regulatoryComplianceStandardName": autorest.Encode("path", regulatoryComplianceStandardName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/regulatoryComplianceStandards/{regulatoryComplianceStandardName}/regulatoryComplianceControls/{regulatoryComplianceControlName}/regulatoryComplianceAssessments/{regulatoryComplianceAssessmentName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client RegulatoryComplianceAssessmentsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client RegulatoryComplianceAssessmentsClient) GetResponder(resp *http.Response) (result RegulatoryComplianceAssessment, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List details and state of assessments mapped to selected regulatory compliance control +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// regulatoryComplianceStandardName - name of the regulatory compliance standard object +// regulatoryComplianceControlName - name of the regulatory compliance control object +// filter - oData filter. Optional. +func (client RegulatoryComplianceAssessmentsClient) List(ctx context.Context, resourceGroupName string, regulatoryComplianceStandardName string, regulatoryComplianceControlName string, filter string) (result RegulatoryComplianceAssessmentListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegulatoryComplianceAssessmentsClient.List") + defer func() { + sc := -1 + if result.rcal.Response.Response != nil { + sc = result.rcal.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.RegulatoryComplianceAssessmentsClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, regulatoryComplianceStandardName, regulatoryComplianceControlName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceAssessmentsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.rcal.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceAssessmentsClient", "List", resp, "Failure sending request") + return + } + + result.rcal, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceAssessmentsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client RegulatoryComplianceAssessmentsClient) ListPreparer(ctx context.Context, resourceGroupName string, regulatoryComplianceStandardName string, regulatoryComplianceControlName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "regulatoryComplianceControlName": autorest.Encode("path", regulatoryComplianceControlName), + "regulatoryComplianceStandardName": autorest.Encode("path", regulatoryComplianceStandardName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/regulatoryComplianceStandards/{regulatoryComplianceStandardName}/regulatoryComplianceControls/{regulatoryComplianceControlName}/regulatoryComplianceAssessments", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client RegulatoryComplianceAssessmentsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client RegulatoryComplianceAssessmentsClient) ListResponder(resp *http.Response) (result RegulatoryComplianceAssessmentList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client RegulatoryComplianceAssessmentsClient) listNextResults(ctx context.Context, lastResults RegulatoryComplianceAssessmentList) (result RegulatoryComplianceAssessmentList, err error) { + req, err := lastResults.regulatoryComplianceAssessmentListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.RegulatoryComplianceAssessmentsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.RegulatoryComplianceAssessmentsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceAssessmentsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client RegulatoryComplianceAssessmentsClient) ListComplete(ctx context.Context, resourceGroupName string, regulatoryComplianceStandardName string, regulatoryComplianceControlName string, filter string) (result RegulatoryComplianceAssessmentListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegulatoryComplianceAssessmentsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, resourceGroupName, regulatoryComplianceStandardName, regulatoryComplianceControlName, filter) + return +} diff --git a/services/preview/security/mgmt/v1.0/security/regulatorycompliancecontrols.go b/services/preview/security/mgmt/v1.0/security/regulatorycompliancecontrols.go new file mode 100644 index 000000000000..cd3e803c9f64 --- /dev/null +++ b/services/preview/security/mgmt/v1.0/security/regulatorycompliancecontrols.go @@ -0,0 +1,263 @@ +package security + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// RegulatoryComplianceControlsClient is the API spec for Microsoft.Security (Azure Security Center) resource provider +type RegulatoryComplianceControlsClient struct { + BaseClient +} + +// NewRegulatoryComplianceControlsClient creates an instance of the RegulatoryComplianceControlsClient client. +func NewRegulatoryComplianceControlsClient(subscriptionID string, ascLocation string) RegulatoryComplianceControlsClient { + return NewRegulatoryComplianceControlsClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewRegulatoryComplianceControlsClientWithBaseURI creates an instance of the RegulatoryComplianceControlsClient +// client. +func NewRegulatoryComplianceControlsClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) RegulatoryComplianceControlsClient { + return RegulatoryComplianceControlsClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// Get selected regulatory compliance control details and state +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// regulatoryComplianceStandardName - name of the regulatory compliance standard object +// regulatoryComplianceControlName - name of the regulatory compliance control object +func (client RegulatoryComplianceControlsClient) Get(ctx context.Context, resourceGroupName string, regulatoryComplianceStandardName string, regulatoryComplianceControlName string) (result RegulatoryComplianceControl, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegulatoryComplianceControlsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.RegulatoryComplianceControlsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, regulatoryComplianceStandardName, regulatoryComplianceControlName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceControlsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceControlsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceControlsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client RegulatoryComplianceControlsClient) GetPreparer(ctx context.Context, resourceGroupName string, regulatoryComplianceStandardName string, regulatoryComplianceControlName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "regulatoryComplianceControlName": autorest.Encode("path", regulatoryComplianceControlName), + "regulatoryComplianceStandardName": autorest.Encode("path", regulatoryComplianceStandardName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/regulatoryComplianceStandards/{regulatoryComplianceStandardName}/regulatoryComplianceControls/{regulatoryComplianceControlName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client RegulatoryComplianceControlsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client RegulatoryComplianceControlsClient) GetResponder(resp *http.Response) (result RegulatoryComplianceControl, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List all supported regulatory compliance controls details and state for selected standard +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// regulatoryComplianceStandardName - name of the regulatory compliance standard object +// filter - oData filter. Optional. +func (client RegulatoryComplianceControlsClient) List(ctx context.Context, resourceGroupName string, regulatoryComplianceStandardName string, filter string) (result RegulatoryComplianceControlListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegulatoryComplianceControlsClient.List") + defer func() { + sc := -1 + if result.rccl.Response.Response != nil { + sc = result.rccl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.RegulatoryComplianceControlsClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, regulatoryComplianceStandardName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceControlsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.rccl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceControlsClient", "List", resp, "Failure sending request") + return + } + + result.rccl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceControlsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client RegulatoryComplianceControlsClient) ListPreparer(ctx context.Context, resourceGroupName string, regulatoryComplianceStandardName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "regulatoryComplianceStandardName": autorest.Encode("path", regulatoryComplianceStandardName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/regulatoryComplianceStandards/{regulatoryComplianceStandardName}/regulatoryComplianceControls", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client RegulatoryComplianceControlsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client RegulatoryComplianceControlsClient) ListResponder(resp *http.Response) (result RegulatoryComplianceControlList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client RegulatoryComplianceControlsClient) listNextResults(ctx context.Context, lastResults RegulatoryComplianceControlList) (result RegulatoryComplianceControlList, err error) { + req, err := lastResults.regulatoryComplianceControlListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.RegulatoryComplianceControlsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.RegulatoryComplianceControlsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceControlsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client RegulatoryComplianceControlsClient) ListComplete(ctx context.Context, resourceGroupName string, regulatoryComplianceStandardName string, filter string) (result RegulatoryComplianceControlListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegulatoryComplianceControlsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, resourceGroupName, regulatoryComplianceStandardName, filter) + return +} diff --git a/services/preview/security/mgmt/v1.0/security/regulatorycompliancestandards.go b/services/preview/security/mgmt/v1.0/security/regulatorycompliancestandards.go new file mode 100644 index 000000000000..279e3ab19c3e --- /dev/null +++ b/services/preview/security/mgmt/v1.0/security/regulatorycompliancestandards.go @@ -0,0 +1,259 @@ +package security + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// RegulatoryComplianceStandardsClient is the API spec for Microsoft.Security (Azure Security Center) resource provider +type RegulatoryComplianceStandardsClient struct { + BaseClient +} + +// NewRegulatoryComplianceStandardsClient creates an instance of the RegulatoryComplianceStandardsClient client. +func NewRegulatoryComplianceStandardsClient(subscriptionID string, ascLocation string) RegulatoryComplianceStandardsClient { + return NewRegulatoryComplianceStandardsClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewRegulatoryComplianceStandardsClientWithBaseURI creates an instance of the RegulatoryComplianceStandardsClient +// client. +func NewRegulatoryComplianceStandardsClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) RegulatoryComplianceStandardsClient { + return RegulatoryComplianceStandardsClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// Get supported regulatory compliance details state for selected standard +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// regulatoryComplianceStandardName - name of the regulatory compliance standard object +func (client RegulatoryComplianceStandardsClient) Get(ctx context.Context, resourceGroupName string, regulatoryComplianceStandardName string) (result RegulatoryComplianceStandard, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegulatoryComplianceStandardsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.RegulatoryComplianceStandardsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, regulatoryComplianceStandardName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceStandardsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceStandardsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceStandardsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client RegulatoryComplianceStandardsClient) GetPreparer(ctx context.Context, resourceGroupName string, regulatoryComplianceStandardName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "regulatoryComplianceStandardName": autorest.Encode("path", regulatoryComplianceStandardName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/regulatoryComplianceStandards/{regulatoryComplianceStandardName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client RegulatoryComplianceStandardsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client RegulatoryComplianceStandardsClient) GetResponder(resp *http.Response) (result RegulatoryComplianceStandard, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List supported regulatory compliance standards details and state +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// filter - oData filter. Optional. +func (client RegulatoryComplianceStandardsClient) List(ctx context.Context, resourceGroupName string, filter string) (result RegulatoryComplianceStandardListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegulatoryComplianceStandardsClient.List") + defer func() { + sc := -1 + if result.rcsl.Response.Response != nil { + sc = result.rcsl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.RegulatoryComplianceStandardsClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceStandardsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.rcsl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceStandardsClient", "List", resp, "Failure sending request") + return + } + + result.rcsl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceStandardsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client RegulatoryComplianceStandardsClient) ListPreparer(ctx context.Context, resourceGroupName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/regulatoryComplianceStandards", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client RegulatoryComplianceStandardsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client RegulatoryComplianceStandardsClient) ListResponder(resp *http.Response) (result RegulatoryComplianceStandardList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client RegulatoryComplianceStandardsClient) listNextResults(ctx context.Context, lastResults RegulatoryComplianceStandardList) (result RegulatoryComplianceStandardList, err error) { + req, err := lastResults.regulatoryComplianceStandardListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.RegulatoryComplianceStandardsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.RegulatoryComplianceStandardsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceStandardsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client RegulatoryComplianceStandardsClient) ListComplete(ctx context.Context, resourceGroupName string, filter string) (result RegulatoryComplianceStandardListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegulatoryComplianceStandardsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, resourceGroupName, filter) + return +} diff --git a/services/preview/security/mgmt/v1.0/security/securityapi/interfaces.go b/services/preview/security/mgmt/v1.0/security/securityapi/interfaces.go index 02d788961ea6..e94c3dcbe3ea 100644 --- a/services/preview/security/mgmt/v1.0/security/securityapi/interfaces.go +++ b/services/preview/security/mgmt/v1.0/security/securityapi/interfaces.go @@ -23,6 +23,30 @@ import ( "github.com/Azure/go-autorest/autorest" ) +// RegulatoryComplianceStandardsClientAPI contains the set of methods on the RegulatoryComplianceStandardsClient type. +type RegulatoryComplianceStandardsClientAPI interface { + Get(ctx context.Context, resourceGroupName string, regulatoryComplianceStandardName string) (result security.RegulatoryComplianceStandard, err error) + List(ctx context.Context, resourceGroupName string, filter string) (result security.RegulatoryComplianceStandardListPage, err error) +} + +var _ RegulatoryComplianceStandardsClientAPI = (*security.RegulatoryComplianceStandardsClient)(nil) + +// RegulatoryComplianceControlsClientAPI contains the set of methods on the RegulatoryComplianceControlsClient type. +type RegulatoryComplianceControlsClientAPI interface { + Get(ctx context.Context, resourceGroupName string, regulatoryComplianceStandardName string, regulatoryComplianceControlName string) (result security.RegulatoryComplianceControl, err error) + List(ctx context.Context, resourceGroupName string, regulatoryComplianceStandardName string, filter string) (result security.RegulatoryComplianceControlListPage, err error) +} + +var _ RegulatoryComplianceControlsClientAPI = (*security.RegulatoryComplianceControlsClient)(nil) + +// RegulatoryComplianceAssessmentsClientAPI contains the set of methods on the RegulatoryComplianceAssessmentsClient type. +type RegulatoryComplianceAssessmentsClientAPI interface { + Get(ctx context.Context, resourceGroupName string, regulatoryComplianceStandardName string, regulatoryComplianceControlName string, regulatoryComplianceAssessmentName string) (result security.RegulatoryComplianceAssessment, err error) + List(ctx context.Context, resourceGroupName string, regulatoryComplianceStandardName string, regulatoryComplianceControlName string, filter string) (result security.RegulatoryComplianceAssessmentListPage, err error) +} + +var _ RegulatoryComplianceAssessmentsClientAPI = (*security.RegulatoryComplianceAssessmentsClient)(nil) + // PricingsClientAPI contains the set of methods on the PricingsClient type. type PricingsClientAPI interface { CreateOrUpdateResourceGroupPricing(ctx context.Context, resourceGroupName string, pricingName string, pricing security.Pricing) (result security.Pricing, err error) diff --git a/services/preview/security/mgmt/v2.0/security/models.go b/services/preview/security/mgmt/v2.0/security/models.go index d2ffb417460b..d145ae36dc96 100644 --- a/services/preview/security/mgmt/v2.0/security/models.go +++ b/services/preview/security/mgmt/v2.0/security/models.go @@ -229,6 +229,25 @@ func PossibleSettingKindValues() []SettingKind { return []SettingKind{SettingKindAlertSuppressionSetting, SettingKindDataExportSetting} } +// State enumerates the values for state. +type State string + +const ( + // Failed At least one supported regulatory compliance control in the given standard has a state of failed + Failed State = "Failed" + // Passed All supported regulatory compliance controls in the given standard have a passed state + Passed State = "Passed" + // Skipped All supported regulatory compliance controls in the given standard have a state of skipped + Skipped State = "Skipped" + // Unsupported No supported regulatory compliance data for the given standard + Unsupported State = "Unsupported" +) + +// PossibleStateValues returns an array of possible values for the State const type. +func PossibleStateValues() []State { + return []State{Failed, Passed, Skipped, Unsupported} +} + // Status enumerates the values for status. type Status string @@ -4042,6 +4061,739 @@ type PricingProperties struct { FreeTrialRemainingTime *string `json:"freeTrialRemainingTime,omitempty"` } +// RegulatoryComplianceAssessment regulatory compliance assessment details and state +type RegulatoryComplianceAssessment struct { + autorest.Response `json:"-"` + // RegulatoryComplianceAssessmentProperties - Regulatory compliance assessment data + *RegulatoryComplianceAssessmentProperties `json:"properties,omitempty"` + // ID - Resource Id + ID *string `json:"id,omitempty"` + // Name - Resource name + Name *string `json:"name,omitempty"` + // Type - Resource type + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for RegulatoryComplianceAssessment. +func (rca RegulatoryComplianceAssessment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rca.RegulatoryComplianceAssessmentProperties != nil { + objectMap["properties"] = rca.RegulatoryComplianceAssessmentProperties + } + if rca.ID != nil { + objectMap["id"] = rca.ID + } + if rca.Name != nil { + objectMap["name"] = rca.Name + } + if rca.Type != nil { + objectMap["type"] = rca.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RegulatoryComplianceAssessment struct. +func (rca *RegulatoryComplianceAssessment) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var regulatoryComplianceAssessmentProperties RegulatoryComplianceAssessmentProperties + err = json.Unmarshal(*v, ®ulatoryComplianceAssessmentProperties) + if err != nil { + return err + } + rca.RegulatoryComplianceAssessmentProperties = ®ulatoryComplianceAssessmentProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + rca.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rca.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + rca.Type = &typeVar + } + } + } + + return nil +} + +// RegulatoryComplianceAssessmentList list of regulatory compliance assessment response +type RegulatoryComplianceAssessmentList struct { + autorest.Response `json:"-"` + Value *[]RegulatoryComplianceAssessment `json:"value,omitempty"` + // NextLink - The URI to fetch the next page. + NextLink *string `json:"nextLink,omitempty"` +} + +// RegulatoryComplianceAssessmentListIterator provides access to a complete listing of +// RegulatoryComplianceAssessment values. +type RegulatoryComplianceAssessmentListIterator struct { + i int + page RegulatoryComplianceAssessmentListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *RegulatoryComplianceAssessmentListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegulatoryComplianceAssessmentListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *RegulatoryComplianceAssessmentListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter RegulatoryComplianceAssessmentListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter RegulatoryComplianceAssessmentListIterator) Response() RegulatoryComplianceAssessmentList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter RegulatoryComplianceAssessmentListIterator) Value() RegulatoryComplianceAssessment { + if !iter.page.NotDone() { + return RegulatoryComplianceAssessment{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the RegulatoryComplianceAssessmentListIterator type. +func NewRegulatoryComplianceAssessmentListIterator(page RegulatoryComplianceAssessmentListPage) RegulatoryComplianceAssessmentListIterator { + return RegulatoryComplianceAssessmentListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (rcal RegulatoryComplianceAssessmentList) IsEmpty() bool { + return rcal.Value == nil || len(*rcal.Value) == 0 +} + +// regulatoryComplianceAssessmentListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (rcal RegulatoryComplianceAssessmentList) regulatoryComplianceAssessmentListPreparer(ctx context.Context) (*http.Request, error) { + if rcal.NextLink == nil || len(to.String(rcal.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(rcal.NextLink))) +} + +// RegulatoryComplianceAssessmentListPage contains a page of RegulatoryComplianceAssessment values. +type RegulatoryComplianceAssessmentListPage struct { + fn func(context.Context, RegulatoryComplianceAssessmentList) (RegulatoryComplianceAssessmentList, error) + rcal RegulatoryComplianceAssessmentList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *RegulatoryComplianceAssessmentListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegulatoryComplianceAssessmentListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.rcal) + if err != nil { + return err + } + page.rcal = next + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *RegulatoryComplianceAssessmentListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page RegulatoryComplianceAssessmentListPage) NotDone() bool { + return !page.rcal.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page RegulatoryComplianceAssessmentListPage) Response() RegulatoryComplianceAssessmentList { + return page.rcal +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page RegulatoryComplianceAssessmentListPage) Values() []RegulatoryComplianceAssessment { + if page.rcal.IsEmpty() { + return nil + } + return *page.rcal.Value +} + +// Creates a new instance of the RegulatoryComplianceAssessmentListPage type. +func NewRegulatoryComplianceAssessmentListPage(getNextPage func(context.Context, RegulatoryComplianceAssessmentList) (RegulatoryComplianceAssessmentList, error)) RegulatoryComplianceAssessmentListPage { + return RegulatoryComplianceAssessmentListPage{fn: getNextPage} +} + +// RegulatoryComplianceAssessmentProperties regulatory compliance assessment data +type RegulatoryComplianceAssessmentProperties struct { + // Description - The description of the regulatory compliance assessment + Description *string `json:"description,omitempty"` + // AssessmentType - The expected type of assessment contained in the AssessmentDetailsLink + AssessmentType *string `json:"assessmentType,omitempty"` + // AssessmentDetailsLink - Link to more detailed assessment results data. The response type will be according to the assessmentType field + AssessmentDetailsLink *string `json:"assessmentDetailsLink,omitempty"` + // State - Aggregative state based on the assessment's scanned resources states. Possible values include: 'Passed', 'Failed', 'Skipped', 'Unsupported' + State State `json:"state,omitempty"` + // PassedResources - The given assessment's related resources count with passed state. + PassedResources *int32 `json:"passedResources,omitempty"` + // FailedResources - The given assessment's related resources count with failed state. + FailedResources *int32 `json:"failedResources,omitempty"` + // SkippedResources - The given assessment's related resources count with skipped state. + SkippedResources *int32 `json:"skippedResources,omitempty"` + // UnsupportedResources - The given assessment's related resources count with unsupported state. + UnsupportedResources *int32 `json:"unsupportedResources,omitempty"` +} + +// RegulatoryComplianceControl regulatory compliance control details and state +type RegulatoryComplianceControl struct { + autorest.Response `json:"-"` + // RegulatoryComplianceControlProperties - Regulatory compliance control data + *RegulatoryComplianceControlProperties `json:"properties,omitempty"` + // ID - Resource Id + ID *string `json:"id,omitempty"` + // Name - Resource name + Name *string `json:"name,omitempty"` + // Type - Resource type + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for RegulatoryComplianceControl. +func (rcc RegulatoryComplianceControl) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rcc.RegulatoryComplianceControlProperties != nil { + objectMap["properties"] = rcc.RegulatoryComplianceControlProperties + } + if rcc.ID != nil { + objectMap["id"] = rcc.ID + } + if rcc.Name != nil { + objectMap["name"] = rcc.Name + } + if rcc.Type != nil { + objectMap["type"] = rcc.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RegulatoryComplianceControl struct. +func (rcc *RegulatoryComplianceControl) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var regulatoryComplianceControlProperties RegulatoryComplianceControlProperties + err = json.Unmarshal(*v, ®ulatoryComplianceControlProperties) + if err != nil { + return err + } + rcc.RegulatoryComplianceControlProperties = ®ulatoryComplianceControlProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + rcc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rcc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + rcc.Type = &typeVar + } + } + } + + return nil +} + +// RegulatoryComplianceControlList list of regulatory compliance controls response +type RegulatoryComplianceControlList struct { + autorest.Response `json:"-"` + // Value - List of regulatory compliance controls + Value *[]RegulatoryComplianceControl `json:"value,omitempty"` + // NextLink - The URI to fetch the next page. + NextLink *string `json:"nextLink,omitempty"` +} + +// RegulatoryComplianceControlListIterator provides access to a complete listing of +// RegulatoryComplianceControl values. +type RegulatoryComplianceControlListIterator struct { + i int + page RegulatoryComplianceControlListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *RegulatoryComplianceControlListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegulatoryComplianceControlListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *RegulatoryComplianceControlListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter RegulatoryComplianceControlListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter RegulatoryComplianceControlListIterator) Response() RegulatoryComplianceControlList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter RegulatoryComplianceControlListIterator) Value() RegulatoryComplianceControl { + if !iter.page.NotDone() { + return RegulatoryComplianceControl{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the RegulatoryComplianceControlListIterator type. +func NewRegulatoryComplianceControlListIterator(page RegulatoryComplianceControlListPage) RegulatoryComplianceControlListIterator { + return RegulatoryComplianceControlListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (rccl RegulatoryComplianceControlList) IsEmpty() bool { + return rccl.Value == nil || len(*rccl.Value) == 0 +} + +// regulatoryComplianceControlListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (rccl RegulatoryComplianceControlList) regulatoryComplianceControlListPreparer(ctx context.Context) (*http.Request, error) { + if rccl.NextLink == nil || len(to.String(rccl.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(rccl.NextLink))) +} + +// RegulatoryComplianceControlListPage contains a page of RegulatoryComplianceControl values. +type RegulatoryComplianceControlListPage struct { + fn func(context.Context, RegulatoryComplianceControlList) (RegulatoryComplianceControlList, error) + rccl RegulatoryComplianceControlList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *RegulatoryComplianceControlListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegulatoryComplianceControlListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.rccl) + if err != nil { + return err + } + page.rccl = next + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *RegulatoryComplianceControlListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page RegulatoryComplianceControlListPage) NotDone() bool { + return !page.rccl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page RegulatoryComplianceControlListPage) Response() RegulatoryComplianceControlList { + return page.rccl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page RegulatoryComplianceControlListPage) Values() []RegulatoryComplianceControl { + if page.rccl.IsEmpty() { + return nil + } + return *page.rccl.Value +} + +// Creates a new instance of the RegulatoryComplianceControlListPage type. +func NewRegulatoryComplianceControlListPage(getNextPage func(context.Context, RegulatoryComplianceControlList) (RegulatoryComplianceControlList, error)) RegulatoryComplianceControlListPage { + return RegulatoryComplianceControlListPage{fn: getNextPage} +} + +// RegulatoryComplianceControlProperties regulatory compliance control data +type RegulatoryComplianceControlProperties struct { + // Description - The description of the regulatory compliance control + Description *string `json:"description,omitempty"` + // State - Aggregative state based on the control's supported assessments states. Possible values include: 'Passed', 'Failed', 'Skipped', 'Unsupported' + State State `json:"state,omitempty"` + // PassedAssessments - The number of supported regulatory compliance assessments of the given control with a passed state + PassedAssessments *int32 `json:"passedAssessments,omitempty"` + // FailedAssessments - The number of supported regulatory compliance assessments of the given control with a failed state + FailedAssessments *int32 `json:"failedAssessments,omitempty"` + // SkippedAssessments - The number of supported regulatory compliance assessments of the given control with a skipped state + SkippedAssessments *int32 `json:"skippedAssessments,omitempty"` +} + +// RegulatoryComplianceStandard regulatory compliance standard details and state +type RegulatoryComplianceStandard struct { + autorest.Response `json:"-"` + // RegulatoryComplianceStandardProperties - Regulatory compliance standard data + *RegulatoryComplianceStandardProperties `json:"properties,omitempty"` + // ID - Resource Id + ID *string `json:"id,omitempty"` + // Name - Resource name + Name *string `json:"name,omitempty"` + // Type - Resource type + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for RegulatoryComplianceStandard. +func (rcs RegulatoryComplianceStandard) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rcs.RegulatoryComplianceStandardProperties != nil { + objectMap["properties"] = rcs.RegulatoryComplianceStandardProperties + } + if rcs.ID != nil { + objectMap["id"] = rcs.ID + } + if rcs.Name != nil { + objectMap["name"] = rcs.Name + } + if rcs.Type != nil { + objectMap["type"] = rcs.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RegulatoryComplianceStandard struct. +func (rcs *RegulatoryComplianceStandard) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var regulatoryComplianceStandardProperties RegulatoryComplianceStandardProperties + err = json.Unmarshal(*v, ®ulatoryComplianceStandardProperties) + if err != nil { + return err + } + rcs.RegulatoryComplianceStandardProperties = ®ulatoryComplianceStandardProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + rcs.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rcs.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + rcs.Type = &typeVar + } + } + } + + return nil +} + +// RegulatoryComplianceStandardList list of regulatory compliance standards response +type RegulatoryComplianceStandardList struct { + autorest.Response `json:"-"` + Value *[]RegulatoryComplianceStandard `json:"value,omitempty"` + // NextLink - The URI to fetch the next page. + NextLink *string `json:"nextLink,omitempty"` +} + +// RegulatoryComplianceStandardListIterator provides access to a complete listing of +// RegulatoryComplianceStandard values. +type RegulatoryComplianceStandardListIterator struct { + i int + page RegulatoryComplianceStandardListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *RegulatoryComplianceStandardListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegulatoryComplianceStandardListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *RegulatoryComplianceStandardListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter RegulatoryComplianceStandardListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter RegulatoryComplianceStandardListIterator) Response() RegulatoryComplianceStandardList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter RegulatoryComplianceStandardListIterator) Value() RegulatoryComplianceStandard { + if !iter.page.NotDone() { + return RegulatoryComplianceStandard{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the RegulatoryComplianceStandardListIterator type. +func NewRegulatoryComplianceStandardListIterator(page RegulatoryComplianceStandardListPage) RegulatoryComplianceStandardListIterator { + return RegulatoryComplianceStandardListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (rcsl RegulatoryComplianceStandardList) IsEmpty() bool { + return rcsl.Value == nil || len(*rcsl.Value) == 0 +} + +// regulatoryComplianceStandardListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (rcsl RegulatoryComplianceStandardList) regulatoryComplianceStandardListPreparer(ctx context.Context) (*http.Request, error) { + if rcsl.NextLink == nil || len(to.String(rcsl.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(rcsl.NextLink))) +} + +// RegulatoryComplianceStandardListPage contains a page of RegulatoryComplianceStandard values. +type RegulatoryComplianceStandardListPage struct { + fn func(context.Context, RegulatoryComplianceStandardList) (RegulatoryComplianceStandardList, error) + rcsl RegulatoryComplianceStandardList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *RegulatoryComplianceStandardListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegulatoryComplianceStandardListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.rcsl) + if err != nil { + return err + } + page.rcsl = next + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *RegulatoryComplianceStandardListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page RegulatoryComplianceStandardListPage) NotDone() bool { + return !page.rcsl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page RegulatoryComplianceStandardListPage) Response() RegulatoryComplianceStandardList { + return page.rcsl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page RegulatoryComplianceStandardListPage) Values() []RegulatoryComplianceStandard { + if page.rcsl.IsEmpty() { + return nil + } + return *page.rcsl.Value +} + +// Creates a new instance of the RegulatoryComplianceStandardListPage type. +func NewRegulatoryComplianceStandardListPage(getNextPage func(context.Context, RegulatoryComplianceStandardList) (RegulatoryComplianceStandardList, error)) RegulatoryComplianceStandardListPage { + return RegulatoryComplianceStandardListPage{fn: getNextPage} +} + +// RegulatoryComplianceStandardProperties regulatory compliance standard data +type RegulatoryComplianceStandardProperties struct { + // State - Aggregative state based on the standard's supported controls states. Possible values include: 'Passed', 'Failed', 'Skipped', 'Unsupported' + State State `json:"state,omitempty"` + // PassedControls - The number of supported regulatory compliance controls of the given standard with a passed state + PassedControls *int32 `json:"passedControls,omitempty"` + // FailedControls - The number of supported regulatory compliance controls of the given standard with a failed state + FailedControls *int32 `json:"failedControls,omitempty"` + // SkippedControls - The number of supported regulatory compliance controls of the given standard with a skipped state + SkippedControls *int32 `json:"skippedControls,omitempty"` + // UnsupportedControls - The number of regulatory compliance controls of the given standard which are unsupported by automated assessments + UnsupportedControls *int32 `json:"unsupportedControls,omitempty"` +} + // Resource describes an Azure resource. type Resource struct { // ID - Resource Id diff --git a/services/preview/security/mgmt/v2.0/security/regulatorycomplianceassessments.go b/services/preview/security/mgmt/v2.0/security/regulatorycomplianceassessments.go new file mode 100644 index 000000000000..a03511f202bb --- /dev/null +++ b/services/preview/security/mgmt/v2.0/security/regulatorycomplianceassessments.go @@ -0,0 +1,268 @@ +package security + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// RegulatoryComplianceAssessmentsClient is the API spec for Microsoft.Security (Azure Security Center) resource +// provider +type RegulatoryComplianceAssessmentsClient struct { + BaseClient +} + +// NewRegulatoryComplianceAssessmentsClient creates an instance of the RegulatoryComplianceAssessmentsClient client. +func NewRegulatoryComplianceAssessmentsClient(subscriptionID string, ascLocation string) RegulatoryComplianceAssessmentsClient { + return NewRegulatoryComplianceAssessmentsClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewRegulatoryComplianceAssessmentsClientWithBaseURI creates an instance of the RegulatoryComplianceAssessmentsClient +// client. +func NewRegulatoryComplianceAssessmentsClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) RegulatoryComplianceAssessmentsClient { + return RegulatoryComplianceAssessmentsClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// Get supported regulatory compliance details and state for selected assessment +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// regulatoryComplianceStandardName - name of the regulatory compliance standard object +// regulatoryComplianceControlName - name of the regulatory compliance control object +// regulatoryComplianceAssessmentName - name of the regulatory compliance assessment object +func (client RegulatoryComplianceAssessmentsClient) Get(ctx context.Context, resourceGroupName string, regulatoryComplianceStandardName string, regulatoryComplianceControlName string, regulatoryComplianceAssessmentName string) (result RegulatoryComplianceAssessment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegulatoryComplianceAssessmentsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.RegulatoryComplianceAssessmentsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, regulatoryComplianceStandardName, regulatoryComplianceControlName, regulatoryComplianceAssessmentName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceAssessmentsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceAssessmentsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceAssessmentsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client RegulatoryComplianceAssessmentsClient) GetPreparer(ctx context.Context, resourceGroupName string, regulatoryComplianceStandardName string, regulatoryComplianceControlName string, regulatoryComplianceAssessmentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "regulatoryComplianceAssessmentName": autorest.Encode("path", regulatoryComplianceAssessmentName), + "regulatoryComplianceControlName": autorest.Encode("path", regulatoryComplianceControlName), + "regulatoryComplianceStandardName": autorest.Encode("path", regulatoryComplianceStandardName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/regulatoryComplianceStandards/{regulatoryComplianceStandardName}/regulatoryComplianceControls/{regulatoryComplianceControlName}/regulatoryComplianceAssessments/{regulatoryComplianceAssessmentName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client RegulatoryComplianceAssessmentsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client RegulatoryComplianceAssessmentsClient) GetResponder(resp *http.Response) (result RegulatoryComplianceAssessment, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List details and state of assessments mapped to selected regulatory compliance control +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// regulatoryComplianceStandardName - name of the regulatory compliance standard object +// regulatoryComplianceControlName - name of the regulatory compliance control object +// filter - oData filter. Optional. +func (client RegulatoryComplianceAssessmentsClient) List(ctx context.Context, resourceGroupName string, regulatoryComplianceStandardName string, regulatoryComplianceControlName string, filter string) (result RegulatoryComplianceAssessmentListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegulatoryComplianceAssessmentsClient.List") + defer func() { + sc := -1 + if result.rcal.Response.Response != nil { + sc = result.rcal.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.RegulatoryComplianceAssessmentsClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, regulatoryComplianceStandardName, regulatoryComplianceControlName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceAssessmentsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.rcal.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceAssessmentsClient", "List", resp, "Failure sending request") + return + } + + result.rcal, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceAssessmentsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client RegulatoryComplianceAssessmentsClient) ListPreparer(ctx context.Context, resourceGroupName string, regulatoryComplianceStandardName string, regulatoryComplianceControlName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "regulatoryComplianceControlName": autorest.Encode("path", regulatoryComplianceControlName), + "regulatoryComplianceStandardName": autorest.Encode("path", regulatoryComplianceStandardName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/regulatoryComplianceStandards/{regulatoryComplianceStandardName}/regulatoryComplianceControls/{regulatoryComplianceControlName}/regulatoryComplianceAssessments", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client RegulatoryComplianceAssessmentsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client RegulatoryComplianceAssessmentsClient) ListResponder(resp *http.Response) (result RegulatoryComplianceAssessmentList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client RegulatoryComplianceAssessmentsClient) listNextResults(ctx context.Context, lastResults RegulatoryComplianceAssessmentList) (result RegulatoryComplianceAssessmentList, err error) { + req, err := lastResults.regulatoryComplianceAssessmentListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.RegulatoryComplianceAssessmentsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.RegulatoryComplianceAssessmentsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceAssessmentsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client RegulatoryComplianceAssessmentsClient) ListComplete(ctx context.Context, resourceGroupName string, regulatoryComplianceStandardName string, regulatoryComplianceControlName string, filter string) (result RegulatoryComplianceAssessmentListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegulatoryComplianceAssessmentsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, resourceGroupName, regulatoryComplianceStandardName, regulatoryComplianceControlName, filter) + return +} diff --git a/services/preview/security/mgmt/v2.0/security/regulatorycompliancecontrols.go b/services/preview/security/mgmt/v2.0/security/regulatorycompliancecontrols.go new file mode 100644 index 000000000000..cd3e803c9f64 --- /dev/null +++ b/services/preview/security/mgmt/v2.0/security/regulatorycompliancecontrols.go @@ -0,0 +1,263 @@ +package security + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// RegulatoryComplianceControlsClient is the API spec for Microsoft.Security (Azure Security Center) resource provider +type RegulatoryComplianceControlsClient struct { + BaseClient +} + +// NewRegulatoryComplianceControlsClient creates an instance of the RegulatoryComplianceControlsClient client. +func NewRegulatoryComplianceControlsClient(subscriptionID string, ascLocation string) RegulatoryComplianceControlsClient { + return NewRegulatoryComplianceControlsClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewRegulatoryComplianceControlsClientWithBaseURI creates an instance of the RegulatoryComplianceControlsClient +// client. +func NewRegulatoryComplianceControlsClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) RegulatoryComplianceControlsClient { + return RegulatoryComplianceControlsClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// Get selected regulatory compliance control details and state +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// regulatoryComplianceStandardName - name of the regulatory compliance standard object +// regulatoryComplianceControlName - name of the regulatory compliance control object +func (client RegulatoryComplianceControlsClient) Get(ctx context.Context, resourceGroupName string, regulatoryComplianceStandardName string, regulatoryComplianceControlName string) (result RegulatoryComplianceControl, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegulatoryComplianceControlsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.RegulatoryComplianceControlsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, regulatoryComplianceStandardName, regulatoryComplianceControlName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceControlsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceControlsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceControlsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client RegulatoryComplianceControlsClient) GetPreparer(ctx context.Context, resourceGroupName string, regulatoryComplianceStandardName string, regulatoryComplianceControlName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "regulatoryComplianceControlName": autorest.Encode("path", regulatoryComplianceControlName), + "regulatoryComplianceStandardName": autorest.Encode("path", regulatoryComplianceStandardName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/regulatoryComplianceStandards/{regulatoryComplianceStandardName}/regulatoryComplianceControls/{regulatoryComplianceControlName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client RegulatoryComplianceControlsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client RegulatoryComplianceControlsClient) GetResponder(resp *http.Response) (result RegulatoryComplianceControl, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List all supported regulatory compliance controls details and state for selected standard +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// regulatoryComplianceStandardName - name of the regulatory compliance standard object +// filter - oData filter. Optional. +func (client RegulatoryComplianceControlsClient) List(ctx context.Context, resourceGroupName string, regulatoryComplianceStandardName string, filter string) (result RegulatoryComplianceControlListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegulatoryComplianceControlsClient.List") + defer func() { + sc := -1 + if result.rccl.Response.Response != nil { + sc = result.rccl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.RegulatoryComplianceControlsClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, regulatoryComplianceStandardName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceControlsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.rccl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceControlsClient", "List", resp, "Failure sending request") + return + } + + result.rccl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceControlsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client RegulatoryComplianceControlsClient) ListPreparer(ctx context.Context, resourceGroupName string, regulatoryComplianceStandardName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "regulatoryComplianceStandardName": autorest.Encode("path", regulatoryComplianceStandardName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/regulatoryComplianceStandards/{regulatoryComplianceStandardName}/regulatoryComplianceControls", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client RegulatoryComplianceControlsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client RegulatoryComplianceControlsClient) ListResponder(resp *http.Response) (result RegulatoryComplianceControlList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client RegulatoryComplianceControlsClient) listNextResults(ctx context.Context, lastResults RegulatoryComplianceControlList) (result RegulatoryComplianceControlList, err error) { + req, err := lastResults.regulatoryComplianceControlListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.RegulatoryComplianceControlsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.RegulatoryComplianceControlsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceControlsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client RegulatoryComplianceControlsClient) ListComplete(ctx context.Context, resourceGroupName string, regulatoryComplianceStandardName string, filter string) (result RegulatoryComplianceControlListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegulatoryComplianceControlsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, resourceGroupName, regulatoryComplianceStandardName, filter) + return +} diff --git a/services/preview/security/mgmt/v2.0/security/regulatorycompliancestandards.go b/services/preview/security/mgmt/v2.0/security/regulatorycompliancestandards.go new file mode 100644 index 000000000000..279e3ab19c3e --- /dev/null +++ b/services/preview/security/mgmt/v2.0/security/regulatorycompliancestandards.go @@ -0,0 +1,259 @@ +package security + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// RegulatoryComplianceStandardsClient is the API spec for Microsoft.Security (Azure Security Center) resource provider +type RegulatoryComplianceStandardsClient struct { + BaseClient +} + +// NewRegulatoryComplianceStandardsClient creates an instance of the RegulatoryComplianceStandardsClient client. +func NewRegulatoryComplianceStandardsClient(subscriptionID string, ascLocation string) RegulatoryComplianceStandardsClient { + return NewRegulatoryComplianceStandardsClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewRegulatoryComplianceStandardsClientWithBaseURI creates an instance of the RegulatoryComplianceStandardsClient +// client. +func NewRegulatoryComplianceStandardsClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) RegulatoryComplianceStandardsClient { + return RegulatoryComplianceStandardsClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// Get supported regulatory compliance details state for selected standard +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// regulatoryComplianceStandardName - name of the regulatory compliance standard object +func (client RegulatoryComplianceStandardsClient) Get(ctx context.Context, resourceGroupName string, regulatoryComplianceStandardName string) (result RegulatoryComplianceStandard, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegulatoryComplianceStandardsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.RegulatoryComplianceStandardsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, regulatoryComplianceStandardName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceStandardsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceStandardsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceStandardsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client RegulatoryComplianceStandardsClient) GetPreparer(ctx context.Context, resourceGroupName string, regulatoryComplianceStandardName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "regulatoryComplianceStandardName": autorest.Encode("path", regulatoryComplianceStandardName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/regulatoryComplianceStandards/{regulatoryComplianceStandardName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client RegulatoryComplianceStandardsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client RegulatoryComplianceStandardsClient) GetResponder(resp *http.Response) (result RegulatoryComplianceStandard, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List supported regulatory compliance standards details and state +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// filter - oData filter. Optional. +func (client RegulatoryComplianceStandardsClient) List(ctx context.Context, resourceGroupName string, filter string) (result RegulatoryComplianceStandardListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegulatoryComplianceStandardsClient.List") + defer func() { + sc := -1 + if result.rcsl.Response.Response != nil { + sc = result.rcsl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.RegulatoryComplianceStandardsClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceStandardsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.rcsl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceStandardsClient", "List", resp, "Failure sending request") + return + } + + result.rcsl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceStandardsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client RegulatoryComplianceStandardsClient) ListPreparer(ctx context.Context, resourceGroupName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/regulatoryComplianceStandards", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client RegulatoryComplianceStandardsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client RegulatoryComplianceStandardsClient) ListResponder(resp *http.Response) (result RegulatoryComplianceStandardList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client RegulatoryComplianceStandardsClient) listNextResults(ctx context.Context, lastResults RegulatoryComplianceStandardList) (result RegulatoryComplianceStandardList, err error) { + req, err := lastResults.regulatoryComplianceStandardListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.RegulatoryComplianceStandardsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.RegulatoryComplianceStandardsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceStandardsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client RegulatoryComplianceStandardsClient) ListComplete(ctx context.Context, resourceGroupName string, filter string) (result RegulatoryComplianceStandardListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegulatoryComplianceStandardsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, resourceGroupName, filter) + return +} diff --git a/services/preview/security/mgmt/v2.0/security/securityapi/interfaces.go b/services/preview/security/mgmt/v2.0/security/securityapi/interfaces.go index fad632a153b3..a28a52dc5d86 100644 --- a/services/preview/security/mgmt/v2.0/security/securityapi/interfaces.go +++ b/services/preview/security/mgmt/v2.0/security/securityapi/interfaces.go @@ -23,6 +23,30 @@ import ( "github.com/Azure/go-autorest/autorest" ) +// RegulatoryComplianceStandardsClientAPI contains the set of methods on the RegulatoryComplianceStandardsClient type. +type RegulatoryComplianceStandardsClientAPI interface { + Get(ctx context.Context, resourceGroupName string, regulatoryComplianceStandardName string) (result security.RegulatoryComplianceStandard, err error) + List(ctx context.Context, resourceGroupName string, filter string) (result security.RegulatoryComplianceStandardListPage, err error) +} + +var _ RegulatoryComplianceStandardsClientAPI = (*security.RegulatoryComplianceStandardsClient)(nil) + +// RegulatoryComplianceControlsClientAPI contains the set of methods on the RegulatoryComplianceControlsClient type. +type RegulatoryComplianceControlsClientAPI interface { + Get(ctx context.Context, resourceGroupName string, regulatoryComplianceStandardName string, regulatoryComplianceControlName string) (result security.RegulatoryComplianceControl, err error) + List(ctx context.Context, resourceGroupName string, regulatoryComplianceStandardName string, filter string) (result security.RegulatoryComplianceControlListPage, err error) +} + +var _ RegulatoryComplianceControlsClientAPI = (*security.RegulatoryComplianceControlsClient)(nil) + +// RegulatoryComplianceAssessmentsClientAPI contains the set of methods on the RegulatoryComplianceAssessmentsClient type. +type RegulatoryComplianceAssessmentsClientAPI interface { + Get(ctx context.Context, resourceGroupName string, regulatoryComplianceStandardName string, regulatoryComplianceControlName string, regulatoryComplianceAssessmentName string) (result security.RegulatoryComplianceAssessment, err error) + List(ctx context.Context, resourceGroupName string, regulatoryComplianceStandardName string, regulatoryComplianceControlName string, filter string) (result security.RegulatoryComplianceAssessmentListPage, err error) +} + +var _ RegulatoryComplianceAssessmentsClientAPI = (*security.RegulatoryComplianceAssessmentsClient)(nil) + // PricingsClientAPI contains the set of methods on the PricingsClient type. type PricingsClientAPI interface { Get(ctx context.Context, pricingName string) (result security.Pricing, err error)