diff --git a/profiles/preview/preview/security/mgmt/security/models.go b/profiles/preview/preview/security/mgmt/security/models.go index c8c1a8108e05..f57c0df867cd 100644 --- a/profiles/preview/preview/security/mgmt/security/models.go +++ b/profiles/preview/preview/security/mgmt/security/models.go @@ -84,10 +84,17 @@ const ( type KindEnum = original.KindEnum const ( - KindAAD KindEnum = original.KindAAD - KindATA KindEnum = original.KindATA - KindCEF KindEnum = original.KindCEF - KindExternalSecuritySolution KindEnum = original.KindExternalSecuritySolution + KindDataExportSetting KindEnum = original.KindDataExportSetting + KindSetting KindEnum = original.KindSetting +) + +type KindEnum1 = original.KindEnum1 + +const ( + KindAAD KindEnum1 = original.KindAAD + KindATA KindEnum1 = original.KindATA + KindCEF KindEnum1 = original.KindCEF + KindExternalSecuritySolution KindEnum1 = original.KindExternalSecuritySolution ) type PricingTier = original.PricingTier @@ -105,6 +112,12 @@ const ( UDP Protocol = original.UDP ) +type SettingKind = original.SettingKind + +const ( + SettingKindDataExportSetting SettingKind = original.SettingKindDataExportSetting +) + type Status = original.Status const ( @@ -157,6 +170,8 @@ type ContactList = original.ContactList type ContactListIterator = original.ContactListIterator type ContactListPage = original.ContactListPage type ContactProperties = original.ContactProperties +type DataExportSetting = original.DataExportSetting +type DataExportSettingProperties = original.DataExportSettingProperties type DiscoveredSecuritySolution = original.DiscoveredSecuritySolution type DiscoveredSecuritySolutionList = original.DiscoveredSecuritySolutionList type DiscoveredSecuritySolutionListIterator = original.DiscoveredSecuritySolutionListIterator @@ -196,6 +211,13 @@ type PricingListIterator = original.PricingListIterator type PricingListPage = original.PricingListPage type PricingProperties = original.PricingProperties type Resource = original.Resource +type BasicSetting = original.BasicSetting +type Setting = original.Setting +type SettingKind1 = original.SettingKind1 +type SettingModel = original.SettingModel +type SettingsList = original.SettingsList +type SettingsListIterator = original.SettingsListIterator +type SettingsListPage = original.SettingsListPage type Task = original.Task type TaskList = original.TaskList type TaskListIterator = original.TaskListIterator @@ -209,6 +231,7 @@ type WorkspaceSettingListPage = original.WorkspaceSettingListPage type WorkspaceSettingProperties = original.WorkspaceSettingProperties type OperationsClient = original.OperationsClient type PricingsClient = original.PricingsClient +type SettingsClient = original.SettingsClient type TasksClient = original.TasksClient type WorkspaceSettingsClient = original.WorkspaceSettingsClient @@ -287,12 +310,18 @@ func PossibleFamilyValues() []Family { func PossibleKindEnumValues() []KindEnum { return original.PossibleKindEnumValues() } +func PossibleKindEnum1Values() []KindEnum1 { + return original.PossibleKindEnum1Values() +} func PossiblePricingTierValues() []PricingTier { return original.PossiblePricingTierValues() } func PossibleProtocolValues() []Protocol { return original.PossibleProtocolValues() } +func PossibleSettingKindValues() []SettingKind { + return original.PossibleSettingKindValues() +} func PossibleStatusValues() []Status { return original.PossibleStatusValues() } @@ -311,6 +340,12 @@ func NewPricingsClient(subscriptionID string, ascLocation string) PricingsClient func NewPricingsClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) PricingsClient { return original.NewPricingsClientWithBaseURI(baseURI, subscriptionID, ascLocation) } +func NewSettingsClient(subscriptionID string, ascLocation string) SettingsClient { + return original.NewSettingsClient(subscriptionID, ascLocation) +} +func NewSettingsClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) SettingsClient { + return original.NewSettingsClientWithBaseURI(baseURI, subscriptionID, ascLocation) +} func NewTasksClient(subscriptionID string, ascLocation string) TasksClient { return original.NewTasksClient(subscriptionID, ascLocation) } diff --git a/services/preview/security/mgmt/2017-08-01-preview/security/models.go b/services/preview/security/mgmt/2017-08-01-preview/security/models.go index 281cb345f4bd..4f55881c39e6 100644 --- a/services/preview/security/mgmt/2017-08-01-preview/security/models.go +++ b/services/preview/security/mgmt/2017-08-01-preview/security/models.go @@ -126,20 +126,35 @@ func PossibleFamilyValues() []Family { // KindEnum enumerates the values for kind enum. type KindEnum string +const ( + // KindDataExportSetting ... + KindDataExportSetting KindEnum = "DataExportSetting" + // KindSetting ... + KindSetting KindEnum = "Setting" +) + +// PossibleKindEnumValues returns an array of possible values for the KindEnum const type. +func PossibleKindEnumValues() []KindEnum { + return []KindEnum{KindDataExportSetting, KindSetting} +} + +// KindEnum1 enumerates the values for kind enum 1. +type KindEnum1 string + const ( // KindAAD ... - KindAAD KindEnum = "AAD" + KindAAD KindEnum1 = "AAD" // KindATA ... - KindATA KindEnum = "ATA" + KindATA KindEnum1 = "ATA" // KindCEF ... - KindCEF KindEnum = "CEF" + KindCEF KindEnum1 = "CEF" // KindExternalSecuritySolution ... - KindExternalSecuritySolution KindEnum = "ExternalSecuritySolution" + KindExternalSecuritySolution KindEnum1 = "ExternalSecuritySolution" ) -// PossibleKindEnumValues returns an array of possible values for the KindEnum const type. -func PossibleKindEnumValues() []KindEnum { - return []KindEnum{KindAAD, KindATA, KindCEF, KindExternalSecuritySolution} +// PossibleKindEnum1Values returns an array of possible values for the KindEnum1 const type. +func PossibleKindEnum1Values() []KindEnum1 { + return []KindEnum1{KindAAD, KindATA, KindCEF, KindExternalSecuritySolution} } // PricingTier enumerates the values for pricing tier. @@ -174,6 +189,19 @@ func PossibleProtocolValues() []Protocol { return []Protocol{All, TCP, UDP} } +// SettingKind enumerates the values for setting kind. +type SettingKind string + +const ( + // SettingKindDataExportSetting ... + SettingKindDataExportSetting SettingKind = "DataExportSetting" +) + +// PossibleSettingKindValues returns an array of possible values for the SettingKind const type. +func PossibleSettingKindValues() []SettingKind { + return []SettingKind{SettingKindDataExportSetting} +} + // Status enumerates the values for status. type Status string @@ -224,7 +252,7 @@ type AadExternalSecuritySolution struct { // Location - Location where the resource is stored Location *string `json:"location,omitempty"` // Kind - Possible values include: 'KindExternalSecuritySolution', 'KindCEF', 'KindATA', 'KindAAD' - Kind KindEnum `json:"kind,omitempty"` + Kind KindEnum1 `json:"kind,omitempty"` } // MarshalJSON is the custom marshaler for AadExternalSecuritySolution. @@ -735,7 +763,7 @@ type AtaExternalSecuritySolution struct { // Location - Location where the resource is stored Location *string `json:"location,omitempty"` // Kind - Possible values include: 'KindExternalSecuritySolution', 'KindCEF', 'KindATA', 'KindAAD' - Kind KindEnum `json:"kind,omitempty"` + Kind KindEnum1 `json:"kind,omitempty"` } // MarshalJSON is the custom marshaler for AtaExternalSecuritySolution. @@ -1021,7 +1049,7 @@ type CefExternalSecuritySolution struct { // Location - Location where the resource is stored Location *string `json:"location,omitempty"` // Kind - Possible values include: 'KindExternalSecuritySolution', 'KindCEF', 'KindATA', 'KindAAD' - Kind KindEnum `json:"kind,omitempty"` + Kind KindEnum1 `json:"kind,omitempty"` } // MarshalJSON is the custom marshaler for CefExternalSecuritySolution. @@ -1566,6 +1594,123 @@ type ContactProperties struct { AlertsToAdmins AlertsToAdmins `json:"alertsToAdmins,omitempty"` } +// DataExportSetting represents a data export setting +type DataExportSetting struct { + // DataExportSettingProperties - Data export setting data + *DataExportSettingProperties `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"` + // Kind - Possible values include: 'KindSetting', 'KindDataExportSetting' + Kind KindEnum `json:"kind,omitempty"` +} + +// MarshalJSON is the custom marshaler for DataExportSetting. +func (desVar DataExportSetting) MarshalJSON() ([]byte, error) { + desVar.Kind = KindDataExportSetting + objectMap := make(map[string]interface{}) + if desVar.DataExportSettingProperties != nil { + objectMap["properties"] = desVar.DataExportSettingProperties + } + if desVar.ID != nil { + objectMap["id"] = desVar.ID + } + if desVar.Name != nil { + objectMap["name"] = desVar.Name + } + if desVar.Type != nil { + objectMap["type"] = desVar.Type + } + if desVar.Kind != "" { + objectMap["kind"] = desVar.Kind + } + return json.Marshal(objectMap) +} + +// AsDataExportSetting is the BasicSetting implementation for DataExportSetting. +func (desVar DataExportSetting) AsDataExportSetting() (*DataExportSetting, bool) { + return &desVar, true +} + +// AsSetting is the BasicSetting implementation for DataExportSetting. +func (desVar DataExportSetting) AsSetting() (*Setting, bool) { + return nil, false +} + +// AsBasicSetting is the BasicSetting implementation for DataExportSetting. +func (desVar DataExportSetting) AsBasicSetting() (BasicSetting, bool) { + return &desVar, true +} + +// UnmarshalJSON is the custom unmarshaler for DataExportSetting struct. +func (desVar *DataExportSetting) 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 dataExportSettingProperties DataExportSettingProperties + err = json.Unmarshal(*v, &dataExportSettingProperties) + if err != nil { + return err + } + desVar.DataExportSettingProperties = &dataExportSettingProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + desVar.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + desVar.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + desVar.Type = &typeVar + } + case "kind": + if v != nil { + var kind KindEnum + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + desVar.Kind = kind + } + } + } + + return nil +} + +// DataExportSettingProperties the data export setting properties +type DataExportSettingProperties struct { + // Enabled - Is the data export setting is enabled + Enabled *bool `json:"enabled,omitempty"` +} + // DiscoveredSecuritySolution ... type DiscoveredSecuritySolution struct { autorest.Response `json:"-"` @@ -1797,7 +1942,7 @@ type ExternalSecuritySolution struct { // Location - Location where the resource is stored Location *string `json:"location,omitempty"` // Kind - Possible values include: 'KindExternalSecuritySolution', 'KindCEF', 'KindATA', 'KindAAD' - Kind KindEnum `json:"kind,omitempty"` + Kind KindEnum1 `json:"kind,omitempty"` } func unmarshalBasicExternalSecuritySolution(body []byte) (BasicExternalSecuritySolution, error) { @@ -2706,6 +2851,253 @@ type Resource struct { Type *string `json:"type,omitempty"` } +// BasicSetting represents a security setting in Azure Security Center. +type BasicSetting interface { + AsDataExportSetting() (*DataExportSetting, bool) + AsSetting() (*Setting, bool) +} + +// Setting represents a security setting in Azure Security Center. +type Setting struct { + autorest.Response `json:"-"` + // ID - Resource Id + ID *string `json:"id,omitempty"` + // Name - Resource name + Name *string `json:"name,omitempty"` + // Type - Resource type + Type *string `json:"type,omitempty"` + // Kind - Possible values include: 'KindSetting', 'KindDataExportSetting' + Kind KindEnum `json:"kind,omitempty"` +} + +func unmarshalBasicSetting(body []byte) (BasicSetting, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["kind"] { + case string(KindDataExportSetting): + var desVar DataExportSetting + err := json.Unmarshal(body, &desVar) + return desVar, err + default: + var s Setting + err := json.Unmarshal(body, &s) + return s, err + } +} +func unmarshalBasicSettingArray(body []byte) ([]BasicSetting, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + sArray := make([]BasicSetting, len(rawMessages)) + + for index, rawMessage := range rawMessages { + s, err := unmarshalBasicSetting(*rawMessage) + if err != nil { + return nil, err + } + sArray[index] = s + } + return sArray, nil +} + +// MarshalJSON is the custom marshaler for Setting. +func (s Setting) MarshalJSON() ([]byte, error) { + s.Kind = KindSetting + objectMap := make(map[string]interface{}) + if s.ID != nil { + objectMap["id"] = s.ID + } + if s.Name != nil { + objectMap["name"] = s.Name + } + if s.Type != nil { + objectMap["type"] = s.Type + } + if s.Kind != "" { + objectMap["kind"] = s.Kind + } + return json.Marshal(objectMap) +} + +// AsDataExportSetting is the BasicSetting implementation for Setting. +func (s Setting) AsDataExportSetting() (*DataExportSetting, bool) { + return nil, false +} + +// AsSetting is the BasicSetting implementation for Setting. +func (s Setting) AsSetting() (*Setting, bool) { + return &s, true +} + +// AsBasicSetting is the BasicSetting implementation for Setting. +func (s Setting) AsBasicSetting() (BasicSetting, bool) { + return &s, true +} + +// SettingKind1 the kind of the security setting +type SettingKind1 struct { + // Kind - the kind of the settings string. Possible values include: 'SettingKindDataExportSetting' + Kind SettingKind `json:"kind,omitempty"` +} + +// SettingModel ... +type SettingModel struct { + autorest.Response `json:"-"` + Value BasicSetting `json:"value,omitempty"` +} + +// UnmarshalJSON is the custom unmarshaler for SettingModel struct. +func (sm *SettingModel) UnmarshalJSON(body []byte) error { + s, err := unmarshalBasicSetting(body) + if err != nil { + return err + } + sm.Value = s + + return nil +} + +// SettingsList subscription settings list. +type SettingsList struct { + autorest.Response `json:"-"` + // Value - The settings list. + Value *[]BasicSetting `json:"value,omitempty"` + // NextLink - The URI to fetch the next page. + NextLink *string `json:"nextLink,omitempty"` +} + +// UnmarshalJSON is the custom unmarshaler for SettingsList struct. +func (sl *SettingsList) 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 "value": + if v != nil { + value, err := unmarshalBasicSettingArray(*v) + if err != nil { + return err + } + sl.Value = &value + } + case "nextLink": + if v != nil { + var nextLink string + err = json.Unmarshal(*v, &nextLink) + if err != nil { + return err + } + sl.NextLink = &nextLink + } + } + } + + return nil +} + +// SettingsListIterator provides access to a complete listing of Setting values. +type SettingsListIterator struct { + i int + page SettingsListPage +} + +// Next 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 *SettingsListIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter SettingsListIterator) 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 SettingsListIterator) Response() SettingsList { + 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 SettingsListIterator) Value() BasicSetting { + if !iter.page.NotDone() { + return Setting{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (sl SettingsList) IsEmpty() bool { + return sl.Value == nil || len(*sl.Value) == 0 +} + +// settingsListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sl SettingsList) settingsListPreparer() (*http.Request, error) { + if sl.NextLink == nil || len(to.String(sl.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sl.NextLink))) +} + +// SettingsListPage contains a page of BasicSetting values. +type SettingsListPage struct { + fn func(SettingsList) (SettingsList, error) + sl SettingsList +} + +// 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. +func (page *SettingsListPage) Next() error { + next, err := page.fn(page.sl) + if err != nil { + return err + } + page.sl = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page SettingsListPage) NotDone() bool { + return !page.sl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page SettingsListPage) Response() SettingsList { + return page.sl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page SettingsListPage) Values() []BasicSetting { + if page.sl.IsEmpty() { + return nil + } + return *page.sl.Value +} + // Task security task that we recommend to do in order to strengthen security type Task struct { autorest.Response `json:"-"` diff --git a/services/preview/security/mgmt/2017-08-01-preview/security/settings.go b/services/preview/security/mgmt/2017-08-01-preview/security/settings.go new file mode 100644 index 000000000000..6991ea8df8a2 --- /dev/null +++ b/services/preview/security/mgmt/2017-08-01-preview/security/settings.go @@ -0,0 +1,282 @@ +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" + "net/http" +) + +// SettingsClient is the API spec for Microsoft.Security (Azure Security Center) resource provider +type SettingsClient struct { + BaseClient +} + +// NewSettingsClient creates an instance of the SettingsClient client. +func NewSettingsClient(subscriptionID string, ascLocation string) SettingsClient { + return NewSettingsClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewSettingsClientWithBaseURI creates an instance of the SettingsClient client. +func NewSettingsClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) SettingsClient { + return SettingsClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// Get settings of different configurations in security center +// Parameters: +// settingName - name of setting +func (client SettingsClient) Get(ctx context.Context, settingName string) (result SettingModel, err error) { + 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}}}}); err != nil { + return result, validation.NewError("security.SettingsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, settingName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.SettingsClient", "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.SettingsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.SettingsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client SettingsClient) GetPreparer(ctx context.Context, settingName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "settingName": autorest.Encode("path", settingName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/settings/{settingName}", 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 SettingsClient) 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 SettingsClient) GetResponder(resp *http.Response) (result SettingModel, 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 settings about different configurations in security center +func (client SettingsClient) List(ctx context.Context) (result SettingsListPage, err error) { + 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}}}}); err != nil { + return result, validation.NewError("security.SettingsClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "security.SettingsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.sl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.SettingsClient", "List", resp, "Failure sending request") + return + } + + result.sl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.SettingsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client SettingsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/settings", 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 SettingsClient) 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 SettingsClient) ListResponder(resp *http.Response) (result SettingsList, 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 SettingsClient) listNextResults(lastResults SettingsList) (result SettingsList, err error) { + req, err := lastResults.settingsListPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "security.SettingsClient", "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.SettingsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.SettingsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client SettingsClient) ListComplete(ctx context.Context) (result SettingsListIterator, err error) { + result.page, err = client.List(ctx) + return +} + +// Update updating settings about different configurations in security center +// Parameters: +// settingName - name of setting +// setting - setting object +func (client SettingsClient) Update(ctx context.Context, settingName string, setting BasicSetting) (result SettingModel, err error) { + 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}}}}); err != nil { + return result, validation.NewError("security.SettingsClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, settingName, setting) + if err != nil { + err = autorest.NewErrorWithError(err, "security.SettingsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.SettingsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.SettingsClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client SettingsClient) UpdatePreparer(ctx context.Context, settingName string, setting BasicSetting) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "settingName": autorest.Encode("path", settingName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/settings/{settingName}", pathParameters), + autorest.WithJSON(setting), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client SettingsClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client SettingsClient) UpdateResponder(resp *http.Response) (result SettingModel, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +}