diff --git a/go.mod b/go.mod index 2977ba0b8339..a11f8bfe4f9f 100644 --- a/go.mod +++ b/go.mod @@ -17,8 +17,8 @@ require ( github.com/google/go-cmp v0.5.9 github.com/google/uuid v1.3.1 github.com/hashicorp/go-azure-helpers v0.66.2 - github.com/hashicorp/go-azure-sdk/resource-manager v0.20240227.1172434 - github.com/hashicorp/go-azure-sdk/sdk v0.20240227.1172434 + github.com/hashicorp/go-azure-sdk/resource-manager v0.20240228.1142829 + github.com/hashicorp/go-azure-sdk/sdk v0.20240228.1142829 github.com/hashicorp/go-hclog v1.5.0 github.com/hashicorp/go-multierror v1.1.1 github.com/hashicorp/go-uuid v1.0.3 diff --git a/go.sum b/go.sum index e14180d18efb..254f093e2411 100644 --- a/go.sum +++ b/go.sum @@ -115,10 +115,10 @@ github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brv github.com/hashicorp/go-azure-helpers v0.12.0/go.mod h1:Zc3v4DNeX6PDdy7NljlYpnrdac1++qNW0I4U+ofGwpg= github.com/hashicorp/go-azure-helpers v0.66.2 h1:+Pzuo7pdKl0hBXXr5ymmhs4Q40tHAo2nAvHq4WgSjx8= github.com/hashicorp/go-azure-helpers v0.66.2/go.mod h1:kJxXrFtJKJdOEqvad8pllAe7dhP4DbN8J6sqFZe47+4= -github.com/hashicorp/go-azure-sdk/resource-manager v0.20240227.1172434 h1:UNp65kdO4noJDrEe99Od5NfXSnjrrTs0dEyw2MM8jK0= -github.com/hashicorp/go-azure-sdk/resource-manager v0.20240227.1172434/go.mod h1:8Pmp8Bg+FDUjkbuuiLLqysKrKUu5dOIf1dX3KFKNSU8= -github.com/hashicorp/go-azure-sdk/sdk v0.20240227.1172434 h1:IX9e6DRUYl+1skjZPpfdhnEV3cx8dNX1qECYSVcD288= -github.com/hashicorp/go-azure-sdk/sdk v0.20240227.1172434/go.mod h1:IKIPyL+hfFWBHABKT0NOWlIEzlusiUBG0SxIfaiv278= +github.com/hashicorp/go-azure-sdk/resource-manager v0.20240228.1142829 h1:hvfN48POr1yZXJSzW71ynTVGfMQgLmX4NDJ3lPkiwgs= +github.com/hashicorp/go-azure-sdk/resource-manager v0.20240228.1142829/go.mod h1:89N0LAkz404ZWWJfW1RVl/x8Xv8RdUAuc2rqkNo7za8= +github.com/hashicorp/go-azure-sdk/sdk v0.20240228.1142829 h1:eRWPAvNi95VOZBKJYY9yikyorCLMgFpQnJZOpCZAzj4= +github.com/hashicorp/go-azure-sdk/sdk v0.20240228.1142829/go.mod h1:IKIPyL+hfFWBHABKT0NOWlIEzlusiUBG0SxIfaiv278= github.com/hashicorp/go-checkpoint v0.5.0 h1:MFYpPZCnQqQTE18jFwSII6eUQrD/oxMFp3mlgcqk5mU= github.com/hashicorp/go-checkpoint v0.5.0/go.mod h1:7nfLNL10NsxqO4iWuW6tWW0HjZuDrwkBuEQsVcpCOgg= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= diff --git a/internal/clients/client.go b/internal/clients/client.go index bf3ecab33c01..b39da80f7bcd 100644 --- a/internal/clients/client.go +++ b/internal/clients/client.go @@ -597,7 +597,9 @@ func (client *Client) Build(ctx context.Context, o *common.ClientOptions) error if client.Search, err = search.NewClient(o); err != nil { return fmt.Errorf("building clients for Search: %+v", err) } - client.SecurityCenter = securityCenter.NewClient(o) + if client.SecurityCenter, err = securityCenter.NewClient(o); err != nil { + return fmt.Errorf("building clients for Security Center: %+v", err) + } if client.Sentinel, err = sentinel.NewClient(o); err != nil { return fmt.Errorf("building clients for Sentinel: %+v", err) } diff --git a/internal/services/securitycenter/client/client.go b/internal/services/securitycenter/client/client.go index 027506f85948..8e069fbb92b9 100644 --- a/internal/services/securitycenter/client/client.go +++ b/internal/services/securitycenter/client/client.go @@ -4,6 +4,8 @@ package client import ( + "fmt" + "github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security" // nolint: staticcheck "github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations" "github.com/hashicorp/go-azure-sdk/resource-manager/security/2021-06-01/assessmentsmetadata" @@ -31,14 +33,17 @@ type Client struct { DefenderForStorageClient *defenderforstorage.DefenderForStorageClient } -func NewClient(o *common.ClientOptions) *Client { +func NewClient(o *common.ClientOptions) (*Client, error) { ascLocation := "Global" AssessmentsClient := security.NewAssessmentsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId, ascLocation) o.ConfigureClient(&AssessmentsClient.Client, o.ResourceManagerAuthorizer) - AssessmentsMetadataClient := assessmentsmetadata.NewAssessmentsMetadataClientWithBaseURI(o.ResourceManagerEndpoint) - o.ConfigureClient(&AssessmentsMetadataClient.Client, o.ResourceManagerAuthorizer) + AssessmentsMetadataClient, err := assessmentsmetadata.NewAssessmentsMetadataClientWithBaseURI(o.Environment.ResourceManager) + if err != nil { + return nil, fmt.Errorf("building Assessments Metadata client : %+v", err) + } + o.Configure(AssessmentsMetadataClient.Client, o.Authorizers.ResourceManager) ContactsClient := security.NewContactsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId, ascLocation) o.ConfigureClient(&ContactsClient.Client, o.ResourceManagerAuthorizer) @@ -49,8 +54,11 @@ func NewClient(o *common.ClientOptions) *Client { IotSecuritySolutionClient := security.NewIotSecuritySolutionClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId, ascLocation) o.ConfigureClient(&IotSecuritySolutionClient.Client, o.ResourceManagerAuthorizer) - PricingClient := pricings_v2023_01_01.NewPricingsClientWithBaseURI(o.ResourceManagerEndpoint) - o.ConfigureClient(&PricingClient.Client, o.ResourceManagerAuthorizer) + PricingClient, err := pricings_v2023_01_01.NewPricingsClientWithBaseURI(o.Environment.ResourceManager) + if err != nil { + return nil, fmt.Errorf("building Pricing client : %+v", err) + } + o.Configure(PricingClient.Client, o.Authorizers.ResourceManager) WorkspaceClient := security.NewWorkspaceSettingsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId, ascLocation) o.ConfigureClient(&WorkspaceClient.Client, o.ResourceManagerAuthorizer) @@ -61,35 +69,47 @@ func NewClient(o *common.ClientOptions) *Client { AutoProvisioningClient := security.NewAutoProvisioningSettingsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId, ascLocation) o.ConfigureClient(&AutoProvisioningClient.Client, o.ResourceManagerAuthorizer) - SettingClient := settings.NewSettingsClientWithBaseURI(o.ResourceManagerEndpoint) - o.ConfigureClient(&SettingClient.Client, o.ResourceManagerAuthorizer) + SettingClient, err := settings.NewSettingsClientWithBaseURI(o.Environment.ResourceManager) + if err != nil { + return nil, fmt.Errorf("building Setting client : %+v", err) + } + o.Configure(SettingClient.Client, o.Authorizers.ResourceManager) - AutomationsClient := automations.NewAutomationsClientWithBaseURI(o.ResourceManagerEndpoint) - o.ConfigureClient(&AutomationsClient.Client, o.ResourceManagerAuthorizer) + AutomationsClient, err := automations.NewAutomationsClientWithBaseURI(o.Environment.ResourceManager) + if err != nil { + return nil, fmt.Errorf("building Automations client : %+v", err) + } + o.Configure(AutomationsClient.Client, o.Authorizers.ResourceManager) ServerVulnerabilityAssessmentClient := security.NewServerVulnerabilityAssessmentClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId, ascLocation) o.ConfigureClient(&ServerVulnerabilityAssessmentClient.Client, o.ResourceManagerAuthorizer) - ServerVulnerabilityAssessmentSettingClient := servervulnerabilityassessmentssettings.NewServerVulnerabilityAssessmentsSettingsClientWithBaseURI(o.ResourceManagerEndpoint) - o.ConfigureClient(&ServerVulnerabilityAssessmentSettingClient.Client, o.ResourceManagerAuthorizer) + ServerVulnerabilityAssessmentSettingClient, err := servervulnerabilityassessmentssettings.NewServerVulnerabilityAssessmentsSettingsClientWithBaseURI(o.Environment.ResourceManager) + if err != nil { + return nil, fmt.Errorf("building Server Vulnerability Assessment Setting client : %+v", err) + } + o.Configure(ServerVulnerabilityAssessmentSettingClient.Client, o.Authorizers.ResourceManager) - DefenderForStorageClient := defenderforstorage.NewDefenderForStorageClientWithBaseURI(o.ResourceManagerEndpoint) - o.ConfigureClient(&DefenderForStorageClient.Client, o.ResourceManagerAuthorizer) + DefenderForStorageClient, err := defenderforstorage.NewDefenderForStorageClientWithBaseURI(o.Environment.ResourceManager) + if err != nil { + return nil, fmt.Errorf("building Defender For Storage client : %+v", err) + } + o.Configure(DefenderForStorageClient.Client, o.Authorizers.ResourceManager) return &Client{ AssessmentsClient: &AssessmentsClient, - AssessmentsMetadataClient: &AssessmentsMetadataClient, + AssessmentsMetadataClient: AssessmentsMetadataClient, ContactsClient: &ContactsClient, DeviceSecurityGroupsClient: &DeviceSecurityGroupsClient, IotSecuritySolutionClient: &IotSecuritySolutionClient, - PricingClient: &PricingClient, + PricingClient: PricingClient, WorkspaceClient: &WorkspaceClient, AdvancedThreatProtectionClient: &AdvancedThreatProtectionClient, AutoProvisioningClient: &AutoProvisioningClient, - SettingClient: &SettingClient, - AutomationsClient: &AutomationsClient, + SettingClient: SettingClient, + AutomationsClient: AutomationsClient, ServerVulnerabilityAssessmentClient: &ServerVulnerabilityAssessmentClient, - ServerVulnerabilityAssessmentSettingClient: &ServerVulnerabilityAssessmentSettingClient, - DefenderForStorageClient: &DefenderForStorageClient, - } + ServerVulnerabilityAssessmentSettingClient: ServerVulnerabilityAssessmentSettingClient, + DefenderForStorageClient: DefenderForStorageClient, + }, nil } diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/relay/2021-11-01/namespaces/model_networkrulesetproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/relay/2021-11-01/namespaces/model_networkrulesetproperties.go index 8b952d49ada8..dcc27088e8b6 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/relay/2021-11-01/namespaces/model_networkrulesetproperties.go +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/relay/2021-11-01/namespaces/model_networkrulesetproperties.go @@ -4,7 +4,8 @@ package namespaces // Licensed under the MIT License. See NOTICE.txt in the project root for license information. type NetworkRuleSetProperties struct { - DefaultAction *DefaultAction `json:"defaultAction,omitempty"` - IPRules *[]NWRuleSetIPRules `json:"ipRules,omitempty"` - PublicNetworkAccess *PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` + DefaultAction *DefaultAction `json:"defaultAction,omitempty"` + IPRules *[]NWRuleSetIPRules `json:"ipRules,omitempty"` + PublicNetworkAccess *PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` + TrustedServiceAccessEnabled *bool `json:"trustedServiceAccessEnabled,omitempty"` } diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/client.go index f09d9ae37490..96c013baa3dc 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/client.go +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/client.go @@ -1,18 +1,26 @@ package automations -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. type AutomationsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewAutomationsClientWithBaseURI(endpoint string) AutomationsClient { - return AutomationsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewAutomationsClientWithBaseURI(sdkApi sdkEnv.Api) (*AutomationsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "automations", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AutomationsClient: %+v", err) } + + return &AutomationsClient{ + Client: client, + }, nil } diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/constants.go index 781bcd18c6a8..cd0d9c05c6e5 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/constants.go +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/constants.go @@ -1,6 +1,10 @@ package automations -import "strings" +import ( + "encoding/json" + "fmt" + "strings" +) // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. @@ -21,6 +25,19 @@ func PossibleValuesForActionType() []string { } } +func (s *ActionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseActionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseActionType(input string) (*ActionType, error) { vals := map[string]ActionType{ "eventhub": ActionTypeEventHub, @@ -68,6 +85,19 @@ func PossibleValuesForEventSource() []string { } } +func (s *EventSource) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEventSource(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseEventSource(input string) (*EventSource, error) { vals := map[string]EventSource{ "alerts": EventSourceAlerts, @@ -119,6 +149,19 @@ func PossibleValuesForOperator() []string { } } +func (s *Operator) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOperator(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseOperator(input string) (*Operator, error) { vals := map[string]Operator{ "contains": OperatorContains, @@ -158,6 +201,19 @@ func PossibleValuesForPropertyType() []string { } } +func (s *PropertyType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePropertyType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePropertyType(input string) (*PropertyType, error) { vals := map[string]PropertyType{ "boolean": PropertyTypeBoolean, diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_createorupdate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_createorupdate.go new file mode 100644 index 000000000000..cd3cde6e688b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_createorupdate.go @@ -0,0 +1,59 @@ +package automations + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Automation +} + +// CreateOrUpdate ... +func (c AutomationsClient) CreateOrUpdate(ctx context.Context, id AutomationId, input Automation) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Automation + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_createorupdate_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_createorupdate_autorest.go deleted file mode 100644 index 94ae3d41efe9..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_createorupdate_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package automations - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdateOperationResponse struct { - HttpResponse *http.Response - Model *Automation -} - -// CreateOrUpdate ... -func (c AutomationsClient) CreateOrUpdate(ctx context.Context, id AutomationId, input Automation) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "automations.AutomationsClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "automations.AutomationsClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "automations.AutomationsClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c AutomationsClient) preparerForCreateOrUpdate(ctx context.Context, id AutomationId, input Automation) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateOrUpdate handles the response to the CreateOrUpdate request. The method always -// closes the http.Response Body. -func (c AutomationsClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_delete.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_delete.go new file mode 100644 index 000000000000..ec425e78f725 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_delete.go @@ -0,0 +1,46 @@ +package automations + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c AutomationsClient) Delete(ctx context.Context, id AutomationId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_delete_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_delete_autorest.go deleted file mode 100644 index a6d74dbe9600..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_delete_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package automations - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteOperationResponse struct { - HttpResponse *http.Response -} - -// Delete ... -func (c AutomationsClient) Delete(ctx context.Context, id AutomationId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "automations.AutomationsClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "automations.AutomationsClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "automations.AutomationsClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c AutomationsClient) preparerForDelete(ctx context.Context, id AutomationId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c AutomationsClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_get.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_get.go new file mode 100644 index 000000000000..3624696e16a3 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_get.go @@ -0,0 +1,54 @@ +package automations + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Automation +} + +// Get ... +func (c AutomationsClient) Get(ctx context.Context, id AutomationId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Automation + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_get_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_get_autorest.go deleted file mode 100644 index 8abeacea42f9..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package automations - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *Automation -} - -// Get ... -func (c AutomationsClient) Get(ctx context.Context, id AutomationId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "automations.AutomationsClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "automations.AutomationsClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "automations.AutomationsClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c AutomationsClient) preparerForGet(ctx context.Context, id AutomationId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c AutomationsClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_list.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_list.go new file mode 100644 index 000000000000..f0aec026038c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_list.go @@ -0,0 +1,92 @@ +package automations + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Automation +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Automation +} + +// List ... +func (c AutomationsClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Security/automations", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Automation `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c AutomationsClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, AutomationOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AutomationsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate AutomationOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Automation, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_list_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_list_autorest.go deleted file mode 100644 index ef2fcb618fbf..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_list_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package automations - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListOperationResponse struct { - HttpResponse *http.Response - Model *[]Automation - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []Automation -} - -func (r ListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// List ... -func (c AutomationsClient) List(ctx context.Context, id commonids.SubscriptionId) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "automations.AutomationsClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "automations.AutomationsClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "automations.AutomationsClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c AutomationsClient) preparerForList(ctx context.Context, id commonids.SubscriptionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Security/automations", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c AutomationsClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForList handles the response to the List request. The method always -// closes the http.Response Body. -func (c AutomationsClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []Automation `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { - req, err := c.preparerForListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "automations.AutomationsClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "automations.AutomationsClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "automations.AutomationsClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c AutomationsClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, AutomationOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c AutomationsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate AutomationOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]Automation, 0) - - page, err := c.List(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_listbyresourcegroup.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_listbyresourcegroup.go new file mode 100644 index 000000000000..b2d13d8ad0a2 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_listbyresourcegroup.go @@ -0,0 +1,92 @@ +package automations + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Automation +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []Automation +} + +// ListByResourceGroup ... +func (c AutomationsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Security/automations", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Automation `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c AutomationsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, AutomationOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AutomationsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate AutomationOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]Automation, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_listbyresourcegroup_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_listbyresourcegroup_autorest.go deleted file mode 100644 index 87ecc2c21606..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_listbyresourcegroup_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package automations - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByResourceGroupOperationResponse struct { - HttpResponse *http.Response - Model *[]Automation - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByResourceGroupOperationResponse, error) -} - -type ListByResourceGroupCompleteResult struct { - Items []Automation -} - -func (r ListByResourceGroupOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByResourceGroupOperationResponse) LoadMore(ctx context.Context) (resp ListByResourceGroupOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByResourceGroup ... -func (c AutomationsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (resp ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroup(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "automations.AutomationsClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "automations.AutomationsClient", "ListByResourceGroup", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByResourceGroup(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "automations.AutomationsClient", "ListByResourceGroup", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByResourceGroup prepares the ListByResourceGroup request. -func (c AutomationsClient) preparerForListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Security/automations", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByResourceGroupWithNextLink prepares the ListByResourceGroup request with the given nextLink token. -func (c AutomationsClient) preparerForListByResourceGroupWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByResourceGroup handles the response to the ListByResourceGroup request. The method always -// closes the http.Response Body. -func (c AutomationsClient) responderForListByResourceGroup(resp *http.Response) (result ListByResourceGroupOperationResponse, err error) { - type page struct { - Values []Automation `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroupWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "automations.AutomationsClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "automations.AutomationsClient", "ListByResourceGroup", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByResourceGroup(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "automations.AutomationsClient", "ListByResourceGroup", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByResourceGroupComplete retrieves all of the results into a single object -func (c AutomationsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { - return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, AutomationOperationPredicate{}) -} - -// ListByResourceGroupCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c AutomationsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate AutomationOperationPredicate) (resp ListByResourceGroupCompleteResult, err error) { - items := make([]Automation, 0) - - page, err := c.ListByResourceGroup(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByResourceGroupCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_validate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_validate.go new file mode 100644 index 000000000000..7315953962db --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_validate.go @@ -0,0 +1,59 @@ +package automations + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ValidateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AutomationValidationStatus +} + +// Validate ... +func (c AutomationsClient) Validate(ctx context.Context, id AutomationId, input Automation) (result ValidateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/validate", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AutomationValidationStatus + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_validate_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_validate_autorest.go deleted file mode 100644 index 4e4a767f065d..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_validate_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package automations - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ValidateOperationResponse struct { - HttpResponse *http.Response - Model *AutomationValidationStatus -} - -// Validate ... -func (c AutomationsClient) Validate(ctx context.Context, id AutomationId, input Automation) (result ValidateOperationResponse, err error) { - req, err := c.preparerForValidate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "automations.AutomationsClient", "Validate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "automations.AutomationsClient", "Validate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForValidate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "automations.AutomationsClient", "Validate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForValidate prepares the Validate request. -func (c AutomationsClient) preparerForValidate(ctx context.Context, id AutomationId, input Automation) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/validate", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForValidate handles the response to the Validate request. The method always -// closes the http.Response Body. -func (c AutomationsClient) responderForValidate(resp *http.Response) (result ValidateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2021-06-01/assessmentsmetadata/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2021-06-01/assessmentsmetadata/client.go index c0aadd1558d7..538aeb656d51 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2021-06-01/assessmentsmetadata/client.go +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2021-06-01/assessmentsmetadata/client.go @@ -1,18 +1,26 @@ package assessmentsmetadata -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. type AssessmentsMetadataClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewAssessmentsMetadataClientWithBaseURI(endpoint string) AssessmentsMetadataClient { - return AssessmentsMetadataClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewAssessmentsMetadataClientWithBaseURI(sdkApi sdkEnv.Api) (*AssessmentsMetadataClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "assessmentsmetadata", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AssessmentsMetadataClient: %+v", err) } + + return &AssessmentsMetadataClient{ + Client: client, + }, nil } diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2021-06-01/assessmentsmetadata/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2021-06-01/assessmentsmetadata/constants.go index 0d20712b3a6b..27048c454c5e 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2021-06-01/assessmentsmetadata/constants.go +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2021-06-01/assessmentsmetadata/constants.go @@ -1,6 +1,10 @@ package assessmentsmetadata -import "strings" +import ( + "encoding/json" + "fmt" + "strings" +) // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. @@ -23,6 +27,19 @@ func PossibleValuesForAssessmentType() []string { } } +func (s *AssessmentType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAssessmentType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseAssessmentType(input string) (*AssessmentType, error) { vals := map[string]AssessmentType{ "builtin": AssessmentTypeBuiltIn, @@ -59,6 +76,19 @@ func PossibleValuesForCategories() []string { } } +func (s *Categories) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCategories(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseCategories(input string) (*Categories, error) { vals := map[string]Categories{ "compute": CategoriesCompute, @@ -92,6 +122,19 @@ func PossibleValuesForImplementationEffort() []string { } } +func (s *ImplementationEffort) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseImplementationEffort(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseImplementationEffort(input string) (*ImplementationEffort, error) { vals := map[string]ImplementationEffort{ "high": ImplementationEffortHigh, @@ -123,6 +166,19 @@ func PossibleValuesForSeverity() []string { } } +func (s *Severity) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSeverity(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseSeverity(input string) (*Severity, error) { vals := map[string]Severity{ "high": SeverityHigh, @@ -176,6 +232,19 @@ func PossibleValuesForTactics() []string { } } +func (s *Tactics) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTactics(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseTactics(input string) (*Tactics, error) { vals := map[string]Tactics{ "collection": TacticsCollection, @@ -420,6 +489,19 @@ func PossibleValuesForTechniques() []string { } } +func (s *Techniques) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTechniques(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseTechniques(input string) (*Techniques, error) { vals := map[string]Techniques{ "abuse elevation control mechanism": TechniquesAbuseElevationControlMechanism, @@ -562,6 +644,19 @@ func PossibleValuesForThreats() []string { } } +func (s *Threats) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseThreats(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseThreats(input string) (*Threats, error) { vals := map[string]Threats{ "accountbreach": ThreatsAccountBreach, @@ -598,6 +693,19 @@ func PossibleValuesForUserImpact() []string { } } +func (s *UserImpact) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUserImpact(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseUserImpact(input string) (*UserImpact, error) { vals := map[string]UserImpact{ "high": UserImpactHigh, diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2021-06-01/assessmentsmetadata/method_createinsubscription.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2021-06-01/assessmentsmetadata/method_createinsubscription.go new file mode 100644 index 000000000000..a81501a924b8 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2021-06-01/assessmentsmetadata/method_createinsubscription.go @@ -0,0 +1,58 @@ +package assessmentsmetadata + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateInSubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SecurityAssessmentMetadataResponse +} + +// CreateInSubscription ... +func (c AssessmentsMetadataClient) CreateInSubscription(ctx context.Context, id ProviderAssessmentMetadataId, input SecurityAssessmentMetadataResponse) (result CreateInSubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SecurityAssessmentMetadataResponse + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2021-06-01/assessmentsmetadata/method_createinsubscription_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2021-06-01/assessmentsmetadata/method_createinsubscription_autorest.go deleted file mode 100644 index 35ddfe1552a6..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2021-06-01/assessmentsmetadata/method_createinsubscription_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package assessmentsmetadata - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateInSubscriptionOperationResponse struct { - HttpResponse *http.Response - Model *SecurityAssessmentMetadataResponse -} - -// CreateInSubscription ... -func (c AssessmentsMetadataClient) CreateInSubscription(ctx context.Context, id ProviderAssessmentMetadataId, input SecurityAssessmentMetadataResponse) (result CreateInSubscriptionOperationResponse, err error) { - req, err := c.preparerForCreateInSubscription(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "assessmentsmetadata.AssessmentsMetadataClient", "CreateInSubscription", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "assessmentsmetadata.AssessmentsMetadataClient", "CreateInSubscription", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateInSubscription(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "assessmentsmetadata.AssessmentsMetadataClient", "CreateInSubscription", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateInSubscription prepares the CreateInSubscription request. -func (c AssessmentsMetadataClient) preparerForCreateInSubscription(ctx context.Context, id ProviderAssessmentMetadataId, input SecurityAssessmentMetadataResponse) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateInSubscription handles the response to the CreateInSubscription request. The method always -// closes the http.Response Body. -func (c AssessmentsMetadataClient) responderForCreateInSubscription(resp *http.Response) (result CreateInSubscriptionOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2021-06-01/assessmentsmetadata/method_deleteinsubscription.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2021-06-01/assessmentsmetadata/method_deleteinsubscription.go new file mode 100644 index 000000000000..1c18b693a1e3 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2021-06-01/assessmentsmetadata/method_deleteinsubscription.go @@ -0,0 +1,46 @@ +package assessmentsmetadata + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteInSubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteInSubscription ... +func (c AssessmentsMetadataClient) DeleteInSubscription(ctx context.Context, id ProviderAssessmentMetadataId) (result DeleteInSubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2021-06-01/assessmentsmetadata/method_deleteinsubscription_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2021-06-01/assessmentsmetadata/method_deleteinsubscription_autorest.go deleted file mode 100644 index 69002c88c88c..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2021-06-01/assessmentsmetadata/method_deleteinsubscription_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package assessmentsmetadata - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteInSubscriptionOperationResponse struct { - HttpResponse *http.Response -} - -// DeleteInSubscription ... -func (c AssessmentsMetadataClient) DeleteInSubscription(ctx context.Context, id ProviderAssessmentMetadataId) (result DeleteInSubscriptionOperationResponse, err error) { - req, err := c.preparerForDeleteInSubscription(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "assessmentsmetadata.AssessmentsMetadataClient", "DeleteInSubscription", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "assessmentsmetadata.AssessmentsMetadataClient", "DeleteInSubscription", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDeleteInSubscription(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "assessmentsmetadata.AssessmentsMetadataClient", "DeleteInSubscription", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDeleteInSubscription prepares the DeleteInSubscription request. -func (c AssessmentsMetadataClient) preparerForDeleteInSubscription(ctx context.Context, id ProviderAssessmentMetadataId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDeleteInSubscription handles the response to the DeleteInSubscription request. The method always -// closes the http.Response Body. -func (c AssessmentsMetadataClient) responderForDeleteInSubscription(resp *http.Response) (result DeleteInSubscriptionOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2021-06-01/assessmentsmetadata/method_get.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2021-06-01/assessmentsmetadata/method_get.go new file mode 100644 index 000000000000..414b57d87c6d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2021-06-01/assessmentsmetadata/method_get.go @@ -0,0 +1,54 @@ +package assessmentsmetadata + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SecurityAssessmentMetadataResponse +} + +// Get ... +func (c AssessmentsMetadataClient) Get(ctx context.Context, id AssessmentMetadataId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SecurityAssessmentMetadataResponse + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2021-06-01/assessmentsmetadata/method_get_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2021-06-01/assessmentsmetadata/method_get_autorest.go deleted file mode 100644 index 2f76335c0359..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2021-06-01/assessmentsmetadata/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package assessmentsmetadata - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *SecurityAssessmentMetadataResponse -} - -// Get ... -func (c AssessmentsMetadataClient) Get(ctx context.Context, id AssessmentMetadataId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "assessmentsmetadata.AssessmentsMetadataClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "assessmentsmetadata.AssessmentsMetadataClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "assessmentsmetadata.AssessmentsMetadataClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c AssessmentsMetadataClient) preparerForGet(ctx context.Context, id AssessmentMetadataId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c AssessmentsMetadataClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2021-06-01/assessmentsmetadata/method_getinsubscription.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2021-06-01/assessmentsmetadata/method_getinsubscription.go new file mode 100644 index 000000000000..1e38e35abec9 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2021-06-01/assessmentsmetadata/method_getinsubscription.go @@ -0,0 +1,54 @@ +package assessmentsmetadata + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetInSubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SecurityAssessmentMetadataResponse +} + +// GetInSubscription ... +func (c AssessmentsMetadataClient) GetInSubscription(ctx context.Context, id ProviderAssessmentMetadataId) (result GetInSubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SecurityAssessmentMetadataResponse + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2021-06-01/assessmentsmetadata/method_getinsubscription_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2021-06-01/assessmentsmetadata/method_getinsubscription_autorest.go deleted file mode 100644 index 483a5b5dc7ce..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2021-06-01/assessmentsmetadata/method_getinsubscription_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package assessmentsmetadata - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetInSubscriptionOperationResponse struct { - HttpResponse *http.Response - Model *SecurityAssessmentMetadataResponse -} - -// GetInSubscription ... -func (c AssessmentsMetadataClient) GetInSubscription(ctx context.Context, id ProviderAssessmentMetadataId) (result GetInSubscriptionOperationResponse, err error) { - req, err := c.preparerForGetInSubscription(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "assessmentsmetadata.AssessmentsMetadataClient", "GetInSubscription", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "assessmentsmetadata.AssessmentsMetadataClient", "GetInSubscription", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetInSubscription(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "assessmentsmetadata.AssessmentsMetadataClient", "GetInSubscription", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetInSubscription prepares the GetInSubscription request. -func (c AssessmentsMetadataClient) preparerForGetInSubscription(ctx context.Context, id ProviderAssessmentMetadataId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetInSubscription handles the response to the GetInSubscription request. The method always -// closes the http.Response Body. -func (c AssessmentsMetadataClient) responderForGetInSubscription(resp *http.Response) (result GetInSubscriptionOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2021-06-01/assessmentsmetadata/method_list.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2021-06-01/assessmentsmetadata/method_list.go new file mode 100644 index 000000000000..e17eed6f064c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2021-06-01/assessmentsmetadata/method_list.go @@ -0,0 +1,91 @@ +package assessmentsmetadata + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SecurityAssessmentMetadataResponse +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []SecurityAssessmentMetadataResponse +} + +// List ... +func (c AssessmentsMetadataClient) List(ctx context.Context) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: "/providers/Microsoft.Security/assessmentMetadata", + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]SecurityAssessmentMetadataResponse `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c AssessmentsMetadataClient) ListComplete(ctx context.Context) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, SecurityAssessmentMetadataResponseOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AssessmentsMetadataClient) ListCompleteMatchingPredicate(ctx context.Context, predicate SecurityAssessmentMetadataResponseOperationPredicate) (result ListCompleteResult, err error) { + items := make([]SecurityAssessmentMetadataResponse, 0) + + resp, err := c.List(ctx) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2021-06-01/assessmentsmetadata/method_list_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2021-06-01/assessmentsmetadata/method_list_autorest.go deleted file mode 100644 index 18733ef85c90..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2021-06-01/assessmentsmetadata/method_list_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package assessmentsmetadata - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListOperationResponse struct { - HttpResponse *http.Response - Model *[]SecurityAssessmentMetadataResponse - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []SecurityAssessmentMetadataResponse -} - -func (r ListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// List ... -func (c AssessmentsMetadataClient) List(ctx context.Context) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx) - if err != nil { - err = autorest.NewErrorWithError(err, "assessmentsmetadata.AssessmentsMetadataClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "assessmentsmetadata.AssessmentsMetadataClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "assessmentsmetadata.AssessmentsMetadataClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c AssessmentsMetadataClient) preparerForList(ctx context.Context) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath("/providers/Microsoft.Security/assessmentMetadata"), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c AssessmentsMetadataClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForList handles the response to the List request. The method always -// closes the http.Response Body. -func (c AssessmentsMetadataClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []SecurityAssessmentMetadataResponse `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { - req, err := c.preparerForListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "assessmentsmetadata.AssessmentsMetadataClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "assessmentsmetadata.AssessmentsMetadataClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "assessmentsmetadata.AssessmentsMetadataClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c AssessmentsMetadataClient) ListComplete(ctx context.Context) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, SecurityAssessmentMetadataResponseOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c AssessmentsMetadataClient) ListCompleteMatchingPredicate(ctx context.Context, predicate SecurityAssessmentMetadataResponseOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]SecurityAssessmentMetadataResponse, 0) - - page, err := c.List(ctx) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2021-06-01/assessmentsmetadata/method_listbysubscription.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2021-06-01/assessmentsmetadata/method_listbysubscription.go new file mode 100644 index 000000000000..75e6b4540d81 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2021-06-01/assessmentsmetadata/method_listbysubscription.go @@ -0,0 +1,92 @@ +package assessmentsmetadata + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SecurityAssessmentMetadataResponse +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []SecurityAssessmentMetadataResponse +} + +// ListBySubscription ... +func (c AssessmentsMetadataClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Security/assessmentMetadata", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]SecurityAssessmentMetadataResponse `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c AssessmentsMetadataClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, SecurityAssessmentMetadataResponseOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AssessmentsMetadataClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate SecurityAssessmentMetadataResponseOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]SecurityAssessmentMetadataResponse, 0) + + resp, err := c.ListBySubscription(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2021-06-01/assessmentsmetadata/method_listbysubscription_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2021-06-01/assessmentsmetadata/method_listbysubscription_autorest.go deleted file mode 100644 index 59ebe826395b..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2021-06-01/assessmentsmetadata/method_listbysubscription_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package assessmentsmetadata - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListBySubscriptionOperationResponse struct { - HttpResponse *http.Response - Model *[]SecurityAssessmentMetadataResponse - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListBySubscriptionOperationResponse, error) -} - -type ListBySubscriptionCompleteResult struct { - Items []SecurityAssessmentMetadataResponse -} - -func (r ListBySubscriptionOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListBySubscriptionOperationResponse) LoadMore(ctx context.Context) (resp ListBySubscriptionOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListBySubscription ... -func (c AssessmentsMetadataClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (resp ListBySubscriptionOperationResponse, err error) { - req, err := c.preparerForListBySubscription(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "assessmentsmetadata.AssessmentsMetadataClient", "ListBySubscription", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "assessmentsmetadata.AssessmentsMetadataClient", "ListBySubscription", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListBySubscription(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "assessmentsmetadata.AssessmentsMetadataClient", "ListBySubscription", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListBySubscription prepares the ListBySubscription request. -func (c AssessmentsMetadataClient) preparerForListBySubscription(ctx context.Context, id commonids.SubscriptionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Security/assessmentMetadata", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListBySubscriptionWithNextLink prepares the ListBySubscription request with the given nextLink token. -func (c AssessmentsMetadataClient) preparerForListBySubscriptionWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListBySubscription handles the response to the ListBySubscription request. The method always -// closes the http.Response Body. -func (c AssessmentsMetadataClient) responderForListBySubscription(resp *http.Response) (result ListBySubscriptionOperationResponse, err error) { - type page struct { - Values []SecurityAssessmentMetadataResponse `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListBySubscriptionOperationResponse, err error) { - req, err := c.preparerForListBySubscriptionWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "assessmentsmetadata.AssessmentsMetadataClient", "ListBySubscription", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "assessmentsmetadata.AssessmentsMetadataClient", "ListBySubscription", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListBySubscription(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "assessmentsmetadata.AssessmentsMetadataClient", "ListBySubscription", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListBySubscriptionComplete retrieves all of the results into a single object -func (c AssessmentsMetadataClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { - return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, SecurityAssessmentMetadataResponseOperationPredicate{}) -} - -// ListBySubscriptionCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c AssessmentsMetadataClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate SecurityAssessmentMetadataResponseOperationPredicate) (resp ListBySubscriptionCompleteResult, err error) { - items := make([]SecurityAssessmentMetadataResponse, 0) - - page, err := c.ListBySubscription(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListBySubscriptionCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2022-05-01/settings/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2022-05-01/settings/client.go index fe7a909262c1..7a9bd9ec8a1d 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2022-05-01/settings/client.go +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2022-05-01/settings/client.go @@ -1,18 +1,26 @@ package settings -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. type SettingsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewSettingsClientWithBaseURI(endpoint string) SettingsClient { - return SettingsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewSettingsClientWithBaseURI(sdkApi sdkEnv.Api) (*SettingsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "settings", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SettingsClient: %+v", err) } + + return &SettingsClient{ + Client: client, + }, nil } diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2022-05-01/settings/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2022-05-01/settings/constants.go index 9adae3396c41..70b6b056f105 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2022-05-01/settings/constants.go +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2022-05-01/settings/constants.go @@ -1,6 +1,10 @@ package settings -import "strings" +import ( + "encoding/json" + "fmt" + "strings" +) // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. @@ -21,6 +25,19 @@ func PossibleValuesForSettingKind() []string { } } +func (s *SettingKind) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSettingKind(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseSettingKind(input string) (*SettingKind, error) { vals := map[string]SettingKind{ "alertsuppressionsetting": SettingKindAlertSuppressionSetting, @@ -56,6 +73,19 @@ func PossibleValuesForSettingName() []string { } } +func (s *SettingName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSettingName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseSettingName(input string) (*SettingName, error) { vals := map[string]SettingName{ "mcas": SettingNameMCAS, diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2022-05-01/settings/method_get.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2022-05-01/settings/method_get.go new file mode 100644 index 000000000000..0ff21eba0401 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2022-05-01/settings/method_get.go @@ -0,0 +1,58 @@ +package settings + +import ( + "context" + "encoding/json" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Setting +} + +// Get ... +func (c SettingsClient) Get(ctx context.Context, id SettingId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var respObj json.RawMessage + if err = resp.Unmarshal(&respObj); err != nil { + return + } + model, err := unmarshalSettingImplementation(respObj) + if err != nil { + return + } + result.Model = &model + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2022-05-01/settings/method_get_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2022-05-01/settings/method_get_autorest.go deleted file mode 100644 index 81fe20015c27..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2022-05-01/settings/method_get_autorest.go +++ /dev/null @@ -1,77 +0,0 @@ -package settings - -import ( - "context" - "encoding/json" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *Setting -} - -// Get ... -func (c SettingsClient) Get(ctx context.Context, id SettingId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "settings.SettingsClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "settings.SettingsClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "settings.SettingsClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c SettingsClient) preparerForGet(ctx context.Context, id SettingId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c SettingsClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - var respObj json.RawMessage - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - if err != nil { - return - } - model, err := unmarshalSettingImplementation(respObj) - if err != nil { - return - } - result.Model = &model - return -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2022-05-01/settings/method_list.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2022-05-01/settings/method_list.go new file mode 100644 index 000000000000..a353ea41327c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2022-05-01/settings/method_list.go @@ -0,0 +1,104 @@ +package settings + +import ( + "context" + "encoding/json" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Setting +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Setting +} + +// List ... +func (c SettingsClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Security/settings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]json.RawMessage `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + temp := make([]Setting, 0) + if values.Values != nil { + for i, v := range *values.Values { + val, err := unmarshalSettingImplementation(v) + if err != nil { + err = fmt.Errorf("unmarshalling item %d for Setting (%q): %+v", i, v, err) + return result, err + } + temp = append(temp, val) + } + } + result.Model = &temp + + return +} + +// ListComplete retrieves all the results into a single object +func (c SettingsClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, SettingOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SettingsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate SettingOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Setting, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2022-05-01/settings/method_list_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2022-05-01/settings/method_list_autorest.go deleted file mode 100644 index 6107c61a4d05..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2022-05-01/settings/method_list_autorest.go +++ /dev/null @@ -1,197 +0,0 @@ -package settings - -import ( - "context" - "encoding/json" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListOperationResponse struct { - HttpResponse *http.Response - Model *[]Setting - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []Setting -} - -func (r ListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// List ... -func (c SettingsClient) List(ctx context.Context, id commonids.SubscriptionId) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "settings.SettingsClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "settings.SettingsClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "settings.SettingsClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c SettingsClient) preparerForList(ctx context.Context, id commonids.SubscriptionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Security/settings", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c SettingsClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForList handles the response to the List request. The method always -// closes the http.Response Body. -func (c SettingsClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []json.RawMessage `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - temp := make([]Setting, 0) - for i, v := range respObj.Values { - val, err := unmarshalSettingImplementation(v) - if err != nil { - err = fmt.Errorf("unmarshalling item %d for Setting (%q): %+v", i, v, err) - return result, err - } - temp = append(temp, val) - } - result.Model = &temp - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { - req, err := c.preparerForListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "settings.SettingsClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "settings.SettingsClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "settings.SettingsClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c SettingsClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, SettingOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c SettingsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate SettingOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]Setting, 0) - - page, err := c.List(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2022-05-01/settings/method_update.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2022-05-01/settings/method_update.go new file mode 100644 index 000000000000..283f4df61771 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2022-05-01/settings/method_update.go @@ -0,0 +1,62 @@ +package settings + +import ( + "context" + "encoding/json" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Setting +} + +// Update ... +func (c SettingsClient) Update(ctx context.Context, id SettingId, input Setting) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var respObj json.RawMessage + if err = resp.Unmarshal(&respObj); err != nil { + return + } + model, err := unmarshalSettingImplementation(respObj) + if err != nil { + return + } + result.Model = &model + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2022-05-01/settings/method_update_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2022-05-01/settings/method_update_autorest.go deleted file mode 100644 index 3a27e491a05d..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2022-05-01/settings/method_update_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package settings - -import ( - "context" - "encoding/json" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateOperationResponse struct { - HttpResponse *http.Response - Model *Setting -} - -// Update ... -func (c SettingsClient) Update(ctx context.Context, id SettingId, input Setting) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "settings.SettingsClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "settings.SettingsClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "settings.SettingsClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c SettingsClient) preparerForUpdate(ctx context.Context, id SettingId, input Setting) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdate handles the response to the Update request. The method always -// closes the http.Response Body. -func (c SettingsClient) responderForUpdate(resp *http.Response) (result UpdateOperationResponse, err error) { - var respObj json.RawMessage - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - if err != nil { - return - } - model, err := unmarshalSettingImplementation(respObj) - if err != nil { - return - } - result.Model = &model - return -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2022-12-01-preview/defenderforstorage/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2022-12-01-preview/defenderforstorage/client.go index 7fa1e4325295..cb1db4530c8c 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2022-12-01-preview/defenderforstorage/client.go +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2022-12-01-preview/defenderforstorage/client.go @@ -1,18 +1,26 @@ package defenderforstorage -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. type DefenderForStorageClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewDefenderForStorageClientWithBaseURI(endpoint string) DefenderForStorageClient { - return DefenderForStorageClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewDefenderForStorageClientWithBaseURI(sdkApi sdkEnv.Api) (*DefenderForStorageClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "defenderforstorage", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DefenderForStorageClient: %+v", err) } + + return &DefenderForStorageClient{ + Client: client, + }, nil } diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2022-12-01-preview/defenderforstorage/method_create.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2022-12-01-preview/defenderforstorage/method_create.go new file mode 100644 index 000000000000..bc33b57be16a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2022-12-01-preview/defenderforstorage/method_create.go @@ -0,0 +1,61 @@ +package defenderforstorage + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DefenderForStorageSetting +} + +// Create ... +func (c DefenderForStorageClient) Create(ctx context.Context, id commonids.ScopeId, input DefenderForStorageSetting) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/providers/Microsoft.Security/defenderForStorageSettings/current", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DefenderForStorageSetting + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2022-12-01-preview/defenderforstorage/method_create_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2022-12-01-preview/defenderforstorage/method_create_autorest.go deleted file mode 100644 index 8f84cd1ec5bf..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2022-12-01-preview/defenderforstorage/method_create_autorest.go +++ /dev/null @@ -1,71 +0,0 @@ -package defenderforstorage - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOperationResponse struct { - HttpResponse *http.Response - Model *DefenderForStorageSetting -} - -// Create ... -func (c DefenderForStorageClient) Create(ctx context.Context, id commonids.ScopeId, input DefenderForStorageSetting) (result CreateOperationResponse, err error) { - req, err := c.preparerForCreate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "defenderforstorage.DefenderForStorageClient", "Create", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "defenderforstorage.DefenderForStorageClient", "Create", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "defenderforstorage.DefenderForStorageClient", "Create", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreate prepares the Create request. -func (c DefenderForStorageClient) preparerForCreate(ctx context.Context, id commonids.ScopeId, input DefenderForStorageSetting) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Security/defenderForStorageSettings/current", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreate handles the response to the Create request. The method always -// closes the http.Response Body. -func (c DefenderForStorageClient) responderForCreate(resp *http.Response) (result CreateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2022-12-01-preview/defenderforstorage/method_get.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2022-12-01-preview/defenderforstorage/method_get.go new file mode 100644 index 000000000000..a1f44e098acb --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2022-12-01-preview/defenderforstorage/method_get.go @@ -0,0 +1,56 @@ +package defenderforstorage + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DefenderForStorageSetting +} + +// Get ... +func (c DefenderForStorageClient) Get(ctx context.Context, id commonids.ScopeId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Security/defenderForStorageSettings/current", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DefenderForStorageSetting + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2022-12-01-preview/defenderforstorage/method_get_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2022-12-01-preview/defenderforstorage/method_get_autorest.go deleted file mode 100644 index d29aa3f7ef36..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2022-12-01-preview/defenderforstorage/method_get_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package defenderforstorage - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *DefenderForStorageSetting -} - -// Get ... -func (c DefenderForStorageClient) Get(ctx context.Context, id commonids.ScopeId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "defenderforstorage.DefenderForStorageClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "defenderforstorage.DefenderForStorageClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "defenderforstorage.DefenderForStorageClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c DefenderForStorageClient) preparerForGet(ctx context.Context, id commonids.ScopeId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Security/defenderForStorageSettings/current", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c DefenderForStorageClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-01-01/pricings/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-01-01/pricings/client.go index 69e28da13d7b..7d9c16fd7af1 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-01-01/pricings/client.go +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-01-01/pricings/client.go @@ -1,18 +1,26 @@ package pricings -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. type PricingsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewPricingsClientWithBaseURI(endpoint string) PricingsClient { - return PricingsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewPricingsClientWithBaseURI(sdkApi sdkEnv.Api) (*PricingsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "pricings", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PricingsClient: %+v", err) } + + return &PricingsClient{ + Client: client, + }, nil } diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-01-01/pricings/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-01-01/pricings/constants.go index 0bfd688468ec..85a58ee38ee5 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-01-01/pricings/constants.go +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-01-01/pricings/constants.go @@ -1,6 +1,10 @@ package pricings -import "strings" +import ( + "encoding/json" + "fmt" + "strings" +) // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. @@ -19,6 +23,19 @@ func PossibleValuesForCode() []string { } } +func (s *Code) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseCode(input string) (*Code, error) { vals := map[string]Code{ "failed": CodeFailed, @@ -47,6 +64,19 @@ func PossibleValuesForIsEnabled() []string { } } +func (s *IsEnabled) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIsEnabled(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseIsEnabled(input string) (*IsEnabled, error) { vals := map[string]IsEnabled{ "false": IsEnabledFalse, @@ -75,6 +105,19 @@ func PossibleValuesForPricingTier() []string { } } +func (s *PricingTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePricingTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePricingTier(input string) (*PricingTier, error) { vals := map[string]PricingTier{ "free": PricingTierFree, diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-01-01/pricings/method_get.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-01-01/pricings/method_get.go new file mode 100644 index 000000000000..36f6a556ae2c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-01-01/pricings/method_get.go @@ -0,0 +1,54 @@ +package pricings + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Pricing +} + +// Get ... +func (c PricingsClient) Get(ctx context.Context, id PricingId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Pricing + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-01-01/pricings/method_get_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-01-01/pricings/method_get_autorest.go deleted file mode 100644 index 4ec18804a210..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-01-01/pricings/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package pricings - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *Pricing -} - -// Get ... -func (c PricingsClient) Get(ctx context.Context, id PricingId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "pricings.PricingsClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "pricings.PricingsClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "pricings.PricingsClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c PricingsClient) preparerForGet(ctx context.Context, id PricingId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c PricingsClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-01-01/pricings/method_list.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-01-01/pricings/method_list.go new file mode 100644 index 000000000000..ad645d5d8682 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-01-01/pricings/method_list.go @@ -0,0 +1,56 @@ +package pricings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PricingList +} + +// List ... +func (c PricingsClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Security/pricings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PricingList + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-01-01/pricings/method_list_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-01-01/pricings/method_list_autorest.go deleted file mode 100644 index 0a0eecb490aa..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-01-01/pricings/method_list_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package pricings - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListOperationResponse struct { - HttpResponse *http.Response - Model *PricingList -} - -// List ... -func (c PricingsClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "pricings.PricingsClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "pricings.PricingsClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "pricings.PricingsClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForList prepares the List request. -func (c PricingsClient) preparerForList(ctx context.Context, id commonids.SubscriptionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Security/pricings", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForList handles the response to the List request. The method always -// closes the http.Response Body. -func (c PricingsClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-01-01/pricings/method_update.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-01-01/pricings/method_update.go new file mode 100644 index 000000000000..07420ccd7945 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-01-01/pricings/method_update.go @@ -0,0 +1,58 @@ +package pricings + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Pricing +} + +// Update ... +func (c PricingsClient) Update(ctx context.Context, id PricingId, input Pricing) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Pricing + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-01-01/pricings/method_update_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-01-01/pricings/method_update_autorest.go deleted file mode 100644 index 60c62b7d3cb1..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-01-01/pricings/method_update_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package pricings - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateOperationResponse struct { - HttpResponse *http.Response - Model *Pricing -} - -// Update ... -func (c PricingsClient) Update(ctx context.Context, id PricingId, input Pricing) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "pricings.PricingsClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "pricings.PricingsClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "pricings.PricingsClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c PricingsClient) preparerForUpdate(ctx context.Context, id PricingId, input Pricing) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdate handles the response to the Update request. The method always -// closes the http.Response Body. -func (c PricingsClient) responderForUpdate(resp *http.Response) (result UpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-05-01/servervulnerabilityassessmentssettings/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-05-01/servervulnerabilityassessmentssettings/client.go index b251c73c5147..6f2ce3fb3259 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-05-01/servervulnerabilityassessmentssettings/client.go +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-05-01/servervulnerabilityassessmentssettings/client.go @@ -1,18 +1,26 @@ package servervulnerabilityassessmentssettings -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. type ServerVulnerabilityAssessmentsSettingsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewServerVulnerabilityAssessmentsSettingsClientWithBaseURI(endpoint string) ServerVulnerabilityAssessmentsSettingsClient { - return ServerVulnerabilityAssessmentsSettingsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewServerVulnerabilityAssessmentsSettingsClientWithBaseURI(sdkApi sdkEnv.Api) (*ServerVulnerabilityAssessmentsSettingsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "servervulnerabilityassessmentssettings", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ServerVulnerabilityAssessmentsSettingsClient: %+v", err) } + + return &ServerVulnerabilityAssessmentsSettingsClient{ + Client: client, + }, nil } diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-05-01/servervulnerabilityassessmentssettings/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-05-01/servervulnerabilityassessmentssettings/constants.go index f3ee7ed233d6..8300644de629 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-05-01/servervulnerabilityassessmentssettings/constants.go +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-05-01/servervulnerabilityassessmentssettings/constants.go @@ -1,6 +1,10 @@ package servervulnerabilityassessmentssettings -import "strings" +import ( + "encoding/json" + "fmt" + "strings" +) // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. @@ -17,6 +21,19 @@ func PossibleValuesForServerVulnerabilityAssessmentsAzureSettingSelectedProvider } } +func (s *ServerVulnerabilityAssessmentsAzureSettingSelectedProvider) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServerVulnerabilityAssessmentsAzureSettingSelectedProvider(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseServerVulnerabilityAssessmentsAzureSettingSelectedProvider(input string) (*ServerVulnerabilityAssessmentsAzureSettingSelectedProvider, error) { vals := map[string]ServerVulnerabilityAssessmentsAzureSettingSelectedProvider{ "mdetvm": ServerVulnerabilityAssessmentsAzureSettingSelectedProviderMdeTVM, @@ -42,6 +59,19 @@ func PossibleValuesForServerVulnerabilityAssessmentsSettingKind() []string { } } +func (s *ServerVulnerabilityAssessmentsSettingKind) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServerVulnerabilityAssessmentsSettingKind(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseServerVulnerabilityAssessmentsSettingKind(input string) (*ServerVulnerabilityAssessmentsSettingKind, error) { vals := map[string]ServerVulnerabilityAssessmentsSettingKind{ "azureserverssetting": ServerVulnerabilityAssessmentsSettingKindAzureServersSetting, diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-05-01/servervulnerabilityassessmentssettings/method_createorupdate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-05-01/servervulnerabilityassessmentssettings/method_createorupdate.go new file mode 100644 index 000000000000..0d2d06907da3 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-05-01/servervulnerabilityassessmentssettings/method_createorupdate.go @@ -0,0 +1,65 @@ +package servervulnerabilityassessmentssettings + +import ( + "context" + "encoding/json" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ServerVulnerabilityAssessmentsSetting +} + +// CreateOrUpdate ... +func (c ServerVulnerabilityAssessmentsSettingsClient) CreateOrUpdate(ctx context.Context, id commonids.SubscriptionId, input ServerVulnerabilityAssessmentsSetting) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/providers/Microsoft.Security/serverVulnerabilityAssessmentsSettings/azureServersSetting", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var respObj json.RawMessage + if err = resp.Unmarshal(&respObj); err != nil { + return + } + model, err := unmarshalServerVulnerabilityAssessmentsSettingImplementation(respObj) + if err != nil { + return + } + result.Model = &model + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-05-01/servervulnerabilityassessmentssettings/method_createorupdate_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-05-01/servervulnerabilityassessmentssettings/method_createorupdate_autorest.go deleted file mode 100644 index b50145aa367d..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-05-01/servervulnerabilityassessmentssettings/method_createorupdate_autorest.go +++ /dev/null @@ -1,80 +0,0 @@ -package servervulnerabilityassessmentssettings - -import ( - "context" - "encoding/json" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdateOperationResponse struct { - HttpResponse *http.Response - Model *ServerVulnerabilityAssessmentsSetting -} - -// CreateOrUpdate ... -func (c ServerVulnerabilityAssessmentsSettingsClient) CreateOrUpdate(ctx context.Context, id commonids.SubscriptionId, input ServerVulnerabilityAssessmentsSetting) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "servervulnerabilityassessmentssettings.ServerVulnerabilityAssessmentsSettingsClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "servervulnerabilityassessmentssettings.ServerVulnerabilityAssessmentsSettingsClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "servervulnerabilityassessmentssettings.ServerVulnerabilityAssessmentsSettingsClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c ServerVulnerabilityAssessmentsSettingsClient) preparerForCreateOrUpdate(ctx context.Context, id commonids.SubscriptionId, input ServerVulnerabilityAssessmentsSetting) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Security/serverVulnerabilityAssessmentsSettings/azureServersSetting", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateOrUpdate handles the response to the CreateOrUpdate request. The method always -// closes the http.Response Body. -func (c ServerVulnerabilityAssessmentsSettingsClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - var respObj json.RawMessage - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - if err != nil { - return - } - model, err := unmarshalServerVulnerabilityAssessmentsSettingImplementation(respObj) - if err != nil { - return - } - result.Model = &model - return -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-05-01/servervulnerabilityassessmentssettings/method_delete.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-05-01/servervulnerabilityassessmentssettings/method_delete.go new file mode 100644 index 000000000000..9eadb890db8f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-05-01/servervulnerabilityassessmentssettings/method_delete.go @@ -0,0 +1,49 @@ +package servervulnerabilityassessmentssettings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c ServerVulnerabilityAssessmentsSettingsClient) Delete(ctx context.Context, id commonids.SubscriptionId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: fmt.Sprintf("%s/providers/Microsoft.Security/serverVulnerabilityAssessmentsSettings/azureServersSetting", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-05-01/servervulnerabilityassessmentssettings/method_delete_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-05-01/servervulnerabilityassessmentssettings/method_delete_autorest.go deleted file mode 100644 index b0c96d0e2b1a..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-05-01/servervulnerabilityassessmentssettings/method_delete_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package servervulnerabilityassessmentssettings - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteOperationResponse struct { - HttpResponse *http.Response -} - -// Delete ... -func (c ServerVulnerabilityAssessmentsSettingsClient) Delete(ctx context.Context, id commonids.SubscriptionId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "servervulnerabilityassessmentssettings.ServerVulnerabilityAssessmentsSettingsClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "servervulnerabilityassessmentssettings.ServerVulnerabilityAssessmentsSettingsClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "servervulnerabilityassessmentssettings.ServerVulnerabilityAssessmentsSettingsClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c ServerVulnerabilityAssessmentsSettingsClient) preparerForDelete(ctx context.Context, id commonids.SubscriptionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Security/serverVulnerabilityAssessmentsSettings/azureServersSetting", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c ServerVulnerabilityAssessmentsSettingsClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-05-01/servervulnerabilityassessmentssettings/method_get.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-05-01/servervulnerabilityassessmentssettings/method_get.go new file mode 100644 index 000000000000..ca1ec434b0a5 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-05-01/servervulnerabilityassessmentssettings/method_get.go @@ -0,0 +1,60 @@ +package servervulnerabilityassessmentssettings + +import ( + "context" + "encoding/json" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ServerVulnerabilityAssessmentsSetting +} + +// Get ... +func (c ServerVulnerabilityAssessmentsSettingsClient) Get(ctx context.Context, id commonids.SubscriptionId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Security/serverVulnerabilityAssessmentsSettings/azureServersSetting", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var respObj json.RawMessage + if err = resp.Unmarshal(&respObj); err != nil { + return + } + model, err := unmarshalServerVulnerabilityAssessmentsSettingImplementation(respObj) + if err != nil { + return + } + result.Model = &model + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-05-01/servervulnerabilityassessmentssettings/method_get_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-05-01/servervulnerabilityassessmentssettings/method_get_autorest.go deleted file mode 100644 index 173f27a4a7e0..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-05-01/servervulnerabilityassessmentssettings/method_get_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package servervulnerabilityassessmentssettings - -import ( - "context" - "encoding/json" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *ServerVulnerabilityAssessmentsSetting -} - -// Get ... -func (c ServerVulnerabilityAssessmentsSettingsClient) Get(ctx context.Context, id commonids.SubscriptionId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "servervulnerabilityassessmentssettings.ServerVulnerabilityAssessmentsSettingsClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "servervulnerabilityassessmentssettings.ServerVulnerabilityAssessmentsSettingsClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "servervulnerabilityassessmentssettings.ServerVulnerabilityAssessmentsSettingsClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ServerVulnerabilityAssessmentsSettingsClient) preparerForGet(ctx context.Context, id commonids.SubscriptionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Security/serverVulnerabilityAssessmentsSettings/azureServersSetting", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c ServerVulnerabilityAssessmentsSettingsClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - var respObj json.RawMessage - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - if err != nil { - return - } - model, err := unmarshalServerVulnerabilityAssessmentsSettingImplementation(respObj) - if err != nil { - return - } - result.Model = &model - return -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-05-01/servervulnerabilityassessmentssettings/method_listbysubscription.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-05-01/servervulnerabilityassessmentssettings/method_listbysubscription.go new file mode 100644 index 000000000000..97eb1a630975 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-05-01/servervulnerabilityassessmentssettings/method_listbysubscription.go @@ -0,0 +1,104 @@ +package servervulnerabilityassessmentssettings + +import ( + "context" + "encoding/json" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ServerVulnerabilityAssessmentsSetting +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []ServerVulnerabilityAssessmentsSetting +} + +// ListBySubscription ... +func (c ServerVulnerabilityAssessmentsSettingsClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Security/serverVulnerabilityAssessmentsSettings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]json.RawMessage `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + temp := make([]ServerVulnerabilityAssessmentsSetting, 0) + if values.Values != nil { + for i, v := range *values.Values { + val, err := unmarshalServerVulnerabilityAssessmentsSettingImplementation(v) + if err != nil { + err = fmt.Errorf("unmarshalling item %d for ServerVulnerabilityAssessmentsSetting (%q): %+v", i, v, err) + return result, err + } + temp = append(temp, val) + } + } + result.Model = &temp + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c ServerVulnerabilityAssessmentsSettingsClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, ServerVulnerabilityAssessmentsSettingOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ServerVulnerabilityAssessmentsSettingsClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ServerVulnerabilityAssessmentsSettingOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]ServerVulnerabilityAssessmentsSetting, 0) + + resp, err := c.ListBySubscription(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-05-01/servervulnerabilityassessmentssettings/method_listbysubscription_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-05-01/servervulnerabilityassessmentssettings/method_listbysubscription_autorest.go deleted file mode 100644 index e38e86f15318..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-05-01/servervulnerabilityassessmentssettings/method_listbysubscription_autorest.go +++ /dev/null @@ -1,197 +0,0 @@ -package servervulnerabilityassessmentssettings - -import ( - "context" - "encoding/json" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListBySubscriptionOperationResponse struct { - HttpResponse *http.Response - Model *[]ServerVulnerabilityAssessmentsSetting - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListBySubscriptionOperationResponse, error) -} - -type ListBySubscriptionCompleteResult struct { - Items []ServerVulnerabilityAssessmentsSetting -} - -func (r ListBySubscriptionOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListBySubscriptionOperationResponse) LoadMore(ctx context.Context) (resp ListBySubscriptionOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListBySubscription ... -func (c ServerVulnerabilityAssessmentsSettingsClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (resp ListBySubscriptionOperationResponse, err error) { - req, err := c.preparerForListBySubscription(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "servervulnerabilityassessmentssettings.ServerVulnerabilityAssessmentsSettingsClient", "ListBySubscription", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "servervulnerabilityassessmentssettings.ServerVulnerabilityAssessmentsSettingsClient", "ListBySubscription", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListBySubscription(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "servervulnerabilityassessmentssettings.ServerVulnerabilityAssessmentsSettingsClient", "ListBySubscription", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListBySubscription prepares the ListBySubscription request. -func (c ServerVulnerabilityAssessmentsSettingsClient) preparerForListBySubscription(ctx context.Context, id commonids.SubscriptionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Security/serverVulnerabilityAssessmentsSettings", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListBySubscriptionWithNextLink prepares the ListBySubscription request with the given nextLink token. -func (c ServerVulnerabilityAssessmentsSettingsClient) preparerForListBySubscriptionWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListBySubscription handles the response to the ListBySubscription request. The method always -// closes the http.Response Body. -func (c ServerVulnerabilityAssessmentsSettingsClient) responderForListBySubscription(resp *http.Response) (result ListBySubscriptionOperationResponse, err error) { - type page struct { - Values []json.RawMessage `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - temp := make([]ServerVulnerabilityAssessmentsSetting, 0) - for i, v := range respObj.Values { - val, err := unmarshalServerVulnerabilityAssessmentsSettingImplementation(v) - if err != nil { - err = fmt.Errorf("unmarshalling item %d for ServerVulnerabilityAssessmentsSetting (%q): %+v", i, v, err) - return result, err - } - temp = append(temp, val) - } - result.Model = &temp - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListBySubscriptionOperationResponse, err error) { - req, err := c.preparerForListBySubscriptionWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "servervulnerabilityassessmentssettings.ServerVulnerabilityAssessmentsSettingsClient", "ListBySubscription", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "servervulnerabilityassessmentssettings.ServerVulnerabilityAssessmentsSettingsClient", "ListBySubscription", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListBySubscription(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "servervulnerabilityassessmentssettings.ServerVulnerabilityAssessmentsSettingsClient", "ListBySubscription", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListBySubscriptionComplete retrieves all of the results into a single object -func (c ServerVulnerabilityAssessmentsSettingsClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { - return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, ServerVulnerabilityAssessmentsSettingOperationPredicate{}) -} - -// ListBySubscriptionCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ServerVulnerabilityAssessmentsSettingsClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ServerVulnerabilityAssessmentsSettingOperationPredicate) (resp ListBySubscriptionCompleteResult, err error) { - items := make([]ServerVulnerabilityAssessmentsSetting, 0) - - page, err := c.ListBySubscription(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListBySubscriptionCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/sdk/auth/shared_key_authorizer.go b/vendor/github.com/hashicorp/go-azure-sdk/sdk/auth/shared_key_authorizer.go index 3a9ff1ea7ba5..b4cf1594381d 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/sdk/auth/shared_key_authorizer.go +++ b/vendor/github.com/hashicorp/go-azure-sdk/sdk/auth/shared_key_authorizer.go @@ -13,6 +13,7 @@ import ( "net/http" "net/url" "sort" + "strconv" "strings" "time" @@ -68,7 +69,6 @@ const ( storageEmulatorAccountName string = "devstoreaccount1" headerContentEncoding = "Content-Encoding" - headerContentLength = "Content-Length" headerContentMD5 = "Content-MD5" headerContentLanguage = "Content-Language" headerContentType = "Content-Type" @@ -96,7 +96,7 @@ func buildSharedKey(accName string, accKey []byte, req *http.Request, keyType Sh date := time.Now().UTC().Format(http.TimeFormat) req.Header.Set(headerXMSDate, date) } - canString, err := buildCanonicalizedString(req.Method, req.Header, canRes, keyType) + canString, err := buildCanonicalizedString(req.Method, req.ContentLength, req.Header, canRes, keyType) if err != nil { return "", err } @@ -168,10 +168,10 @@ func getCanonicalizedAccountName(accountName string) string { return strings.TrimSuffix(accountName, "-secondary") } -func buildCanonicalizedString(verb string, headers http.Header, canonicalizedResource string, keyType SharedKeyType) (string, error) { - contentLength := headers.Get(headerContentLength) - if contentLength == "0" { - contentLength = "" +func buildCanonicalizedString(verb string, contentLength int64, headers http.Header, canonicalizedResource string, keyType SharedKeyType) (string, error) { + var contentLengthString string + if contentLength > 0 { + contentLengthString = strconv.Itoa(int(contentLength)) } date := headers.Get(headerDate) if v := headers.Get(headerXMSDate); v != "" { @@ -188,7 +188,7 @@ func buildCanonicalizedString(verb string, headers http.Header, canonicalizedRes verb, headers.Get(headerContentEncoding), headers.Get(headerContentLanguage), - contentLength, + contentLengthString, headers.Get(headerContentMD5), headers.Get(headerContentType), date, diff --git a/vendor/modules.txt b/vendor/modules.txt index cb96e4e7f1f5..63648a8b1cb0 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -153,7 +153,7 @@ github.com/hashicorp/go-azure-helpers/resourcemanager/tags github.com/hashicorp/go-azure-helpers/resourcemanager/zones github.com/hashicorp/go-azure-helpers/sender github.com/hashicorp/go-azure-helpers/storage -# github.com/hashicorp/go-azure-sdk/resource-manager v0.20240227.1172434 +# github.com/hashicorp/go-azure-sdk/resource-manager v0.20240228.1142829 ## explicit; go 1.21 github.com/hashicorp/go-azure-sdk/resource-manager/aad/2021-05-01/domainservices github.com/hashicorp/go-azure-sdk/resource-manager/aadb2c/2021-04-01-preview @@ -1054,7 +1054,7 @@ github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/resourceprovid github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/webapps github.com/hashicorp/go-azure-sdk/resource-manager/webpubsub/2023-02-01 github.com/hashicorp/go-azure-sdk/resource-manager/webpubsub/2023-02-01/webpubsub -# github.com/hashicorp/go-azure-sdk/sdk v0.20240227.1172434 +# github.com/hashicorp/go-azure-sdk/sdk v0.20240228.1142829 ## explicit; go 1.21 github.com/hashicorp/go-azure-sdk/sdk/auth github.com/hashicorp/go-azure-sdk/sdk/auth/autorest