From 8207c2de1ed9abf0de9fa4ed359cec8b36792d81 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Mon, 1 Jul 2019 20:25:08 +0000 Subject: [PATCH] Generated from 77db60c613fff13703dc99ca4aaa81bfbd4900ef Update jitNetworkAccessPolicies.json --- .../preview/security/mgmt/security/models.go | 31 +- .../mgmt/security/securityapi/models.go | 1 + .../security/mgmt/v1.0/security/models.go | 4 + .../security/mgmt/v2.0/security/models.go | 4 + .../security/mgmt/v3.0/security/models.go | 134 +++++- .../v3.0/security/securityapi/interfaces.go | 10 + .../security/servervulnerabilityassessment.go | 414 ++++++++++++++++++ 7 files changed, 582 insertions(+), 16 deletions(-) create mode 100644 services/preview/security/mgmt/v3.0/security/servervulnerabilityassessment.go diff --git a/profiles/preview/preview/security/mgmt/security/models.go b/profiles/preview/preview/security/mgmt/security/models.go index 5d58773cfc7f..cfbee9f1de94 100644 --- a/profiles/preview/preview/security/mgmt/security/models.go +++ b/profiles/preview/preview/security/mgmt/security/models.go @@ -106,6 +106,16 @@ const ( UDP Protocol = original.UDP ) +type ProvisioningState = original.ProvisioningState + +const ( + Canceled ProvisioningState = original.Canceled + Deprovisioning ProvisioningState = original.Deprovisioning + Failed ProvisioningState = original.Failed + Provisioning ProvisioningState = original.Provisioning + Succeeded ProvisioningState = original.Succeeded +) + type ReportedSeverity = original.ReportedSeverity const ( @@ -134,10 +144,10 @@ const ( type State = original.State const ( - Failed State = original.Failed - Passed State = original.Passed - Skipped State = original.Skipped - Unsupported State = original.Unsupported + StateFailed State = original.StateFailed + StatePassed State = original.StatePassed + StateSkipped State = original.StateSkipped + StateUnsupported State = original.StateUnsupported ) type Status = original.Status @@ -286,6 +296,10 @@ type RegulatoryComplianceStandardProperties = original.RegulatoryComplianceStand type RegulatoryComplianceStandardsClient = original.RegulatoryComplianceStandardsClient type Resource = original.Resource type SensitivityLabel = original.SensitivityLabel +type ServerVulnerabilityAssessment = original.ServerVulnerabilityAssessment +type ServerVulnerabilityAssessmentClient = original.ServerVulnerabilityAssessmentClient +type ServerVulnerabilityAssessmentProperties = original.ServerVulnerabilityAssessmentProperties +type ServerVulnerabilityAssessmentsList = original.ServerVulnerabilityAssessmentsList type Setting = original.Setting type SettingResource = original.SettingResource type SettingsClient = original.SettingsClient @@ -510,6 +524,12 @@ func NewRegulatoryComplianceStandardsClient(subscriptionID string, ascLocation s func NewRegulatoryComplianceStandardsClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) RegulatoryComplianceStandardsClient { return original.NewRegulatoryComplianceStandardsClientWithBaseURI(baseURI, subscriptionID, ascLocation) } +func NewServerVulnerabilityAssessmentClient(subscriptionID string, ascLocation string) ServerVulnerabilityAssessmentClient { + return original.NewServerVulnerabilityAssessmentClient(subscriptionID, ascLocation) +} +func NewServerVulnerabilityAssessmentClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) ServerVulnerabilityAssessmentClient { + return original.NewServerVulnerabilityAssessmentClientWithBaseURI(baseURI, subscriptionID, ascLocation) +} func NewSettingsClient(subscriptionID string, ascLocation string) SettingsClient { return original.NewSettingsClient(subscriptionID, ascLocation) } @@ -591,6 +611,9 @@ func PossiblePricingTierValues() []PricingTier { func PossibleProtocolValues() []Protocol { return original.PossibleProtocolValues() } +func PossibleProvisioningStateValues() []ProvisioningState { + return original.PossibleProvisioningStateValues() +} func PossibleReportedSeverityValues() []ReportedSeverity { return original.PossibleReportedSeverityValues() } diff --git a/profiles/preview/preview/security/mgmt/security/securityapi/models.go b/profiles/preview/preview/security/mgmt/security/securityapi/models.go index ca076e9ddf44..87d60a743168 100644 --- a/profiles/preview/preview/security/mgmt/security/securityapi/models.go +++ b/profiles/preview/preview/security/mgmt/security/securityapi/models.go @@ -38,6 +38,7 @@ type PricingsClientAPI = original.PricingsClientAPI type RegulatoryComplianceAssessmentsClientAPI = original.RegulatoryComplianceAssessmentsClientAPI type RegulatoryComplianceControlsClientAPI = original.RegulatoryComplianceControlsClientAPI type RegulatoryComplianceStandardsClientAPI = original.RegulatoryComplianceStandardsClientAPI +type ServerVulnerabilityAssessmentClientAPI = original.ServerVulnerabilityAssessmentClientAPI type SettingsClientAPI = original.SettingsClientAPI type TasksClientAPI = original.TasksClientAPI type TopologyClientAPI = original.TopologyClientAPI diff --git a/services/preview/security/mgmt/v1.0/security/models.go b/services/preview/security/mgmt/v1.0/security/models.go index 080fc7f2e087..a3517580ed06 100644 --- a/services/preview/security/mgmt/v1.0/security/models.go +++ b/services/preview/security/mgmt/v1.0/security/models.go @@ -4117,6 +4117,8 @@ type JitNetworkAccessPolicyVirtualMachine struct { ID *string `json:"id,omitempty"` // Ports - Port configurations for the virtual machine Ports *[]JitNetworkAccessPortRule `json:"ports,omitempty"` + // PublicIPAddress - Public IP address of the Azure Firewall that is linked to this policy, if applicable + PublicIPAddress *string `json:"publicIpAddress,omitempty"` } // JitNetworkAccessPortRule ... @@ -4155,6 +4157,8 @@ type JitNetworkAccessRequestPort struct { Status Status `json:"status,omitempty"` // StatusReason - A description of why the `status` has its value. Possible values include: 'Expired', 'UserRequested', 'NewerRequestInitiated' StatusReason StatusReason `json:"statusReason,omitempty"` + // MappedPort - The port which is mapped to this port's `number` in the Azure Firewall, if applicable + MappedPort *int32 `json:"mappedPort,omitempty"` } // JitNetworkAccessRequestVirtualMachine ... diff --git a/services/preview/security/mgmt/v2.0/security/models.go b/services/preview/security/mgmt/v2.0/security/models.go index 995f0b8637e0..88c0d9fc630b 100644 --- a/services/preview/security/mgmt/v2.0/security/models.go +++ b/services/preview/security/mgmt/v2.0/security/models.go @@ -4117,6 +4117,8 @@ type JitNetworkAccessPolicyVirtualMachine struct { ID *string `json:"id,omitempty"` // Ports - Port configurations for the virtual machine Ports *[]JitNetworkAccessPortRule `json:"ports,omitempty"` + // PublicIPAddress - Public IP address of the Azure Firewall that is linked to this policy, if applicable + PublicIPAddress *string `json:"publicIpAddress,omitempty"` } // JitNetworkAccessPortRule ... @@ -4155,6 +4157,8 @@ type JitNetworkAccessRequestPort struct { Status Status `json:"status,omitempty"` // StatusReason - A description of why the `status` has its value. Possible values include: 'Expired', 'UserRequested', 'NewerRequestInitiated' StatusReason StatusReason `json:"statusReason,omitempty"` + // MappedPort - The port which is mapped to this port's `number` in the Azure Firewall, if applicable + MappedPort *int32 `json:"mappedPort,omitempty"` } // JitNetworkAccessRequestVirtualMachine ... diff --git a/services/preview/security/mgmt/v3.0/security/models.go b/services/preview/security/mgmt/v3.0/security/models.go index 70631dc94ea3..8187d3f8cf07 100644 --- a/services/preview/security/mgmt/v3.0/security/models.go +++ b/services/preview/security/mgmt/v3.0/security/models.go @@ -195,6 +195,27 @@ func PossibleProtocolValues() []Protocol { return []Protocol{All, TCP, UDP} } +// ProvisioningState enumerates the values for provisioning state. +type ProvisioningState string + +const ( + // Canceled ... + Canceled ProvisioningState = "Canceled" + // Deprovisioning ... + Deprovisioning ProvisioningState = "Deprovisioning" + // Failed ... + Failed ProvisioningState = "Failed" + // Provisioning ... + Provisioning ProvisioningState = "Provisioning" + // Succeeded ... + Succeeded ProvisioningState = "Succeeded" +) + +// PossibleProvisioningStateValues returns an array of possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{Canceled, Deprovisioning, Failed, Provisioning, Succeeded} +} + // ReportedSeverity enumerates the values for reported severity. type ReportedSeverity string @@ -252,19 +273,20 @@ func PossibleSettingKindValues() []SettingKind { type State string const ( - // Failed At least one supported regulatory compliance control in the given standard has a state of failed - Failed State = "Failed" - // Passed All supported regulatory compliance controls in the given standard have a passed state - Passed State = "Passed" - // Skipped All supported regulatory compliance controls in the given standard have a state of skipped - Skipped State = "Skipped" - // Unsupported No supported regulatory compliance data for the given standard - Unsupported State = "Unsupported" + // StateFailed At least one supported regulatory compliance control in the given standard has a state of + // failed + StateFailed State = "Failed" + // StatePassed All supported regulatory compliance controls in the given standard have a passed state + StatePassed State = "Passed" + // StateSkipped All supported regulatory compliance controls in the given standard have a state of skipped + StateSkipped State = "Skipped" + // StateUnsupported No supported regulatory compliance data for the given standard + StateUnsupported State = "Unsupported" ) // PossibleStateValues returns an array of possible values for the State const type. func PossibleStateValues() []State { - return []State{Failed, Passed, Skipped, Unsupported} + return []State{StateFailed, StatePassed, StateSkipped, StateUnsupported} } // Status enumerates the values for status. @@ -3768,6 +3790,8 @@ type JitNetworkAccessPolicyVirtualMachine struct { ID *string `json:"id,omitempty"` // Ports - Port configurations for the virtual machine Ports *[]JitNetworkAccessPortRule `json:"ports,omitempty"` + // PublicIPAddress - Public IP address of the Azure Firewall that is linked to this policy, if applicable + PublicIPAddress *string `json:"publicIpAddress,omitempty"` } // JitNetworkAccessPortRule ... @@ -3806,6 +3830,8 @@ type JitNetworkAccessRequestPort struct { Status Status `json:"status,omitempty"` // StatusReason - A description of why the `status` has its value. Possible values include: 'Expired', 'UserRequested', 'NewerRequestInitiated' StatusReason StatusReason `json:"statusReason,omitempty"` + // MappedPort - The port which is mapped to this port's `number` in the Azure Firewall, if applicable + MappedPort *int32 `json:"mappedPort,omitempty"` } // JitNetworkAccessRequestVirtualMachine ... @@ -4310,7 +4336,7 @@ type RegulatoryComplianceAssessmentProperties struct { AssessmentType *string `json:"assessmentType,omitempty"` // AssessmentDetailsLink - READ-ONLY; Link to more detailed assessment results data. The response type will be according to the assessmentType field AssessmentDetailsLink *string `json:"assessmentDetailsLink,omitempty"` - // State - Aggregative state based on the assessment's scanned resources states. Possible values include: 'Passed', 'Failed', 'Skipped', 'Unsupported' + // State - Aggregative state based on the assessment's scanned resources states. Possible values include: 'StatePassed', 'StateFailed', 'StateSkipped', 'StateUnsupported' State State `json:"state,omitempty"` // PassedResources - READ-ONLY; The given assessment's related resources count with passed state. PassedResources *int32 `json:"passedResources,omitempty"` @@ -4546,7 +4572,7 @@ func NewRegulatoryComplianceControlListPage(getNextPage func(context.Context, Re type RegulatoryComplianceControlProperties struct { // Description - READ-ONLY; The description of the regulatory compliance control Description *string `json:"description,omitempty"` - // State - Aggregative state based on the control's supported assessments states. Possible values include: 'Passed', 'Failed', 'Skipped', 'Unsupported' + // State - Aggregative state based on the control's supported assessments states. Possible values include: 'StatePassed', 'StateFailed', 'StateSkipped', 'StateUnsupported' State State `json:"state,omitempty"` // PassedAssessments - READ-ONLY; The number of supported regulatory compliance assessments of the given control with a passed state PassedAssessments *int32 `json:"passedAssessments,omitempty"` @@ -4777,7 +4803,7 @@ func NewRegulatoryComplianceStandardListPage(getNextPage func(context.Context, R // RegulatoryComplianceStandardProperties regulatory compliance standard data type RegulatoryComplianceStandardProperties struct { - // State - Aggregative state based on the standard's supported controls states. Possible values include: 'Passed', 'Failed', 'Skipped', 'Unsupported' + // State - Aggregative state based on the standard's supported controls states. Possible values include: 'StatePassed', 'StateFailed', 'StateSkipped', 'StateUnsupported' State State `json:"state,omitempty"` // PassedControls - READ-ONLY; The number of supported regulatory compliance controls of the given standard with a passed state PassedControls *int32 `json:"passedControls,omitempty"` @@ -4809,6 +4835,90 @@ type SensitivityLabel struct { Enabled *bool `json:"enabled,omitempty"` } +// ServerVulnerabilityAssessment describes the server vulnerability assessment details on a resource +type ServerVulnerabilityAssessment struct { + autorest.Response `json:"-"` + *ServerVulnerabilityAssessmentProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerVulnerabilityAssessment. +func (sva ServerVulnerabilityAssessment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sva.ServerVulnerabilityAssessmentProperties != nil { + objectMap["properties"] = sva.ServerVulnerabilityAssessmentProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServerVulnerabilityAssessment struct. +func (sva *ServerVulnerabilityAssessment) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var serverVulnerabilityAssessmentProperties ServerVulnerabilityAssessmentProperties + err = json.Unmarshal(*v, &serverVulnerabilityAssessmentProperties) + if err != nil { + return err + } + sva.ServerVulnerabilityAssessmentProperties = &serverVulnerabilityAssessmentProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sva.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sva.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sva.Type = &typeVar + } + } + } + + return nil +} + +// ServerVulnerabilityAssessmentProperties describes ServerVulnerabilityAssessment properties. +type ServerVulnerabilityAssessmentProperties struct { + // ProvisioningState - READ-ONLY; The provisioningState of the vulnerability assessment capability on the VM. Possible values include: 'Succeeded', 'Failed', 'Canceled', 'Provisioning', 'Deprovisioning' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` +} + +// ServerVulnerabilityAssessmentsList list of server vulnerability assessments +type ServerVulnerabilityAssessmentsList struct { + autorest.Response `json:"-"` + Value *[]ServerVulnerabilityAssessment `json:"value,omitempty"` +} + // Setting represents a security setting in Azure Security Center. type Setting struct { autorest.Response `json:"-"` diff --git a/services/preview/security/mgmt/v3.0/security/securityapi/interfaces.go b/services/preview/security/mgmt/v3.0/security/securityapi/interfaces.go index 6bbfd6af5631..cf6808518f0e 100644 --- a/services/preview/security/mgmt/v3.0/security/securityapi/interfaces.go +++ b/services/preview/security/mgmt/v3.0/security/securityapi/interfaces.go @@ -220,3 +220,13 @@ type RegulatoryComplianceAssessmentsClientAPI interface { } var _ RegulatoryComplianceAssessmentsClientAPI = (*security.RegulatoryComplianceAssessmentsClient)(nil) + +// ServerVulnerabilityAssessmentClientAPI contains the set of methods on the ServerVulnerabilityAssessmentClient type. +type ServerVulnerabilityAssessmentClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string) (result security.ServerVulnerabilityAssessment, err error) + Delete(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string) (result security.ServerVulnerabilityAssessment, err error) + ListByExtendedResource(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string) (result security.ServerVulnerabilityAssessmentsList, err error) +} + +var _ ServerVulnerabilityAssessmentClientAPI = (*security.ServerVulnerabilityAssessmentClient)(nil) diff --git a/services/preview/security/mgmt/v3.0/security/servervulnerabilityassessment.go b/services/preview/security/mgmt/v3.0/security/servervulnerabilityassessment.go new file mode 100644 index 000000000000..43e66501b767 --- /dev/null +++ b/services/preview/security/mgmt/v3.0/security/servervulnerabilityassessment.go @@ -0,0 +1,414 @@ +package security + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ServerVulnerabilityAssessmentClient is the API spec for Microsoft.Security (Azure Security Center) resource provider +type ServerVulnerabilityAssessmentClient struct { + BaseClient +} + +// NewServerVulnerabilityAssessmentClient creates an instance of the ServerVulnerabilityAssessmentClient client. +func NewServerVulnerabilityAssessmentClient(subscriptionID string, ascLocation string) ServerVulnerabilityAssessmentClient { + return NewServerVulnerabilityAssessmentClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewServerVulnerabilityAssessmentClientWithBaseURI creates an instance of the ServerVulnerabilityAssessmentClient +// client. +func NewServerVulnerabilityAssessmentClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) ServerVulnerabilityAssessmentClient { + return ServerVulnerabilityAssessmentClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// CreateOrUpdate creating a server vulnerability assessment on a resource, which will onboard a resource for having a +// vulnerability assessment on it +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// resourceNamespace - the Namespace of the resource. +// resourceType - the type of the resource. +// resourceName - name of the resource. +func (client ServerVulnerabilityAssessmentClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string) (result ServerVulnerabilityAssessment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerVulnerabilityAssessmentClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.ServerVulnerabilityAssessmentClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, resourceNamespace, resourceType, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.ServerVulnerabilityAssessmentClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.ServerVulnerabilityAssessmentClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.ServerVulnerabilityAssessmentClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ServerVulnerabilityAssessmentClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "resourceNamespace": autorest.Encode("path", resourceNamespace), + "resourceType": autorest.Encode("path", resourceType), + "serverVulnerabilityAssessment": autorest.Encode("path", "default"), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/serverVulnerabilityAssessments/{serverVulnerabilityAssessment}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ServerVulnerabilityAssessmentClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ServerVulnerabilityAssessmentClient) CreateOrUpdateResponder(resp *http.Response) (result ServerVulnerabilityAssessment, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete removing server vulnerability assessment from a resource. +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// resourceNamespace - the Namespace of the resource. +// resourceType - the type of the resource. +// resourceName - name of the resource. +func (client ServerVulnerabilityAssessmentClient) Delete(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerVulnerabilityAssessmentClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.ServerVulnerabilityAssessmentClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, resourceNamespace, resourceType, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.ServerVulnerabilityAssessmentClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "security.ServerVulnerabilityAssessmentClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.ServerVulnerabilityAssessmentClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ServerVulnerabilityAssessmentClient) DeletePreparer(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "resourceNamespace": autorest.Encode("path", resourceNamespace), + "resourceType": autorest.Encode("path", resourceType), + "serverVulnerabilityAssessment": autorest.Encode("path", "default"), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/serverVulnerabilityAssessments/{serverVulnerabilityAssessment}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ServerVulnerabilityAssessmentClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ServerVulnerabilityAssessmentClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a server vulnerability assessment onboarding statuses on a given resource. +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// resourceNamespace - the Namespace of the resource. +// resourceType - the type of the resource. +// resourceName - name of the resource. +func (client ServerVulnerabilityAssessmentClient) Get(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string) (result ServerVulnerabilityAssessment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerVulnerabilityAssessmentClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.ServerVulnerabilityAssessmentClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, resourceNamespace, resourceType, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.ServerVulnerabilityAssessmentClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.ServerVulnerabilityAssessmentClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.ServerVulnerabilityAssessmentClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServerVulnerabilityAssessmentClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "resourceNamespace": autorest.Encode("path", resourceNamespace), + "resourceType": autorest.Encode("path", resourceType), + "serverVulnerabilityAssessment": autorest.Encode("path", "default"), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/serverVulnerabilityAssessments/{serverVulnerabilityAssessment}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ServerVulnerabilityAssessmentClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServerVulnerabilityAssessmentClient) GetResponder(resp *http.Response) (result ServerVulnerabilityAssessment, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByExtendedResource gets a list of server vulnerability assessment onboarding statuses on a given resource. +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// resourceNamespace - the Namespace of the resource. +// resourceType - the type of the resource. +// resourceName - name of the resource. +func (client ServerVulnerabilityAssessmentClient) ListByExtendedResource(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string) (result ServerVulnerabilityAssessmentsList, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerVulnerabilityAssessmentClient.ListByExtendedResource") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.ServerVulnerabilityAssessmentClient", "ListByExtendedResource", err.Error()) + } + + req, err := client.ListByExtendedResourcePreparer(ctx, resourceGroupName, resourceNamespace, resourceType, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.ServerVulnerabilityAssessmentClient", "ListByExtendedResource", nil, "Failure preparing request") + return + } + + resp, err := client.ListByExtendedResourceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.ServerVulnerabilityAssessmentClient", "ListByExtendedResource", resp, "Failure sending request") + return + } + + result, err = client.ListByExtendedResourceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.ServerVulnerabilityAssessmentClient", "ListByExtendedResource", resp, "Failure responding to request") + } + + return +} + +// ListByExtendedResourcePreparer prepares the ListByExtendedResource request. +func (client ServerVulnerabilityAssessmentClient) ListByExtendedResourcePreparer(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "resourceNamespace": autorest.Encode("path", resourceNamespace), + "resourceType": autorest.Encode("path", resourceType), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/serverVulnerabilityAssessments", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByExtendedResourceSender sends the ListByExtendedResource request. The method will close the +// http.Response Body if it receives an error. +func (client ServerVulnerabilityAssessmentClient) ListByExtendedResourceSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByExtendedResourceResponder handles the response to the ListByExtendedResource request. The method always +// closes the http.Response Body. +func (client ServerVulnerabilityAssessmentClient) ListByExtendedResourceResponder(resp *http.Response) (result ServerVulnerabilityAssessmentsList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +}