diff --git a/services/preview/attestation/mgmt/2018-09-01-preview/attestation/attestationapi/interfaces.go b/services/preview/attestation/mgmt/2018-09-01-preview/attestation/attestationapi/interfaces.go index 85eb2edec9d3..3cf919e70480 100644 --- a/services/preview/attestation/mgmt/2018-09-01-preview/attestation/attestationapi/interfaces.go +++ b/services/preview/attestation/mgmt/2018-09-01-preview/attestation/attestationapi/interfaces.go @@ -32,11 +32,12 @@ var _ OperationsClientAPI = (*attestation.OperationsClient)(nil) // ProvidersClientAPI contains the set of methods on the ProvidersClient type. type ProvidersClientAPI interface { - Create(ctx context.Context, resourceGroupName string, providerName string, creationParams *attestation.ServiceCreationParams) (result attestation.Provider, err error) + Create(ctx context.Context, resourceGroupName string, providerName string, creationParams attestation.ServiceCreationParams) (result attestation.Provider, err error) Delete(ctx context.Context, resourceGroupName string, providerName string) (result autorest.Response, err error) Get(ctx context.Context, resourceGroupName string, providerName string) (result attestation.Provider, err error) List(ctx context.Context) (result attestation.ProviderListResult, err error) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result attestation.ProviderListResult, err error) + Update(ctx context.Context, resourceGroupName string, providerName string, updateParams attestation.ServicePatchParams) (result attestation.Provider, err error) } var _ ProvidersClientAPI = (*attestation.ProvidersClient)(nil) diff --git a/services/preview/attestation/mgmt/2018-09-01-preview/attestation/models.go b/services/preview/attestation/mgmt/2018-09-01-preview/attestation/models.go index d9ac341e6854..45035577fea1 100644 --- a/services/preview/attestation/mgmt/2018-09-01-preview/attestation/models.go +++ b/services/preview/attestation/mgmt/2018-09-01-preview/attestation/models.go @@ -172,6 +172,10 @@ type Provider struct { autorest.Response `json:"-"` // StatusResult - Describes Attestation service status. *StatusResult `json:"properties,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` // ID - READ-ONLY; Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} ID *string `json:"id,omitempty"` // Name - READ-ONLY; The name of the resource @@ -186,6 +190,12 @@ func (p Provider) MarshalJSON() ([]byte, error) { if p.StatusResult != nil { objectMap["properties"] = p.StatusResult } + if p.Tags != nil { + objectMap["tags"] = p.Tags + } + if p.Location != nil { + objectMap["location"] = p.Location + } return json.Marshal(objectMap) } @@ -207,6 +217,24 @@ func (p *Provider) UnmarshalJSON(body []byte) error { } p.StatusResult = &statusResult } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + p.Tags = tags + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + p.Location = &location + } case "id": if v != nil { var ID string @@ -268,16 +296,59 @@ type Resource struct { Type *string `json:"type,omitempty"` } -// ServiceCreationParams client supplied parameters passed to attestation service. +// ServiceCreationParams parameters for creating an attestation service instance type ServiceCreationParams struct { + // Location - The supported Azure location where the attestation service instance should be created. + Location *string `json:"location,omitempty"` + // Tags - The tags that will be assigned to the attestation service instance. + Tags map[string]*string `json:"tags"` + // Properties - Properties of the attestation service instance + Properties *ServiceCreationSpecificParams `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServiceCreationParams. +func (scp ServiceCreationParams) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if scp.Location != nil { + objectMap["location"] = scp.Location + } + if scp.Tags != nil { + objectMap["tags"] = scp.Tags + } + if scp.Properties != nil { + objectMap["properties"] = scp.Properties + } + return json.Marshal(objectMap) +} + +// ServiceCreationSpecificParams client supplied parameters used to create a new attestation service +// instance. +type ServiceCreationSpecificParams struct { // AttestationPolicy - Name of attestation policy. AttestationPolicy *string `json:"attestationPolicy,omitempty"` // PolicySigningCertificates - JSON Web Key Set defining a set of X.509 Certificates that will represent the parent certificate for the signing certificate used for policy operations PolicySigningCertificates *JSONWebKeySet `json:"policySigningCertificates,omitempty"` } +// ServicePatchParams parameters for patching an attestation service instance +type ServicePatchParams struct { + // Tags - The tags that will be assigned to the attestation service instance. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for ServicePatchParams. +func (spp ServicePatchParams) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if spp.Tags != nil { + objectMap["tags"] = spp.Tags + } + return json.Marshal(objectMap) +} + // StatusResult status of attestation service. type StatusResult struct { + // TrustModel - Trust model for the attestation service instance. + TrustModel *string `json:"trustModel,omitempty"` // Status - Status of attestation service. Possible values include: 'Ready', 'NotReady', 'Error' Status ServiceStatus `json:"status,omitempty"` // AttestURI - Gets the uri of attestation service diff --git a/services/preview/attestation/mgmt/2018-09-01-preview/attestation/operations.go b/services/preview/attestation/mgmt/2018-09-01-preview/attestation/operations.go index f8afd9343257..7490592ec414 100644 --- a/services/preview/attestation/mgmt/2018-09-01-preview/attestation/operations.go +++ b/services/preview/attestation/mgmt/2018-09-01-preview/attestation/operations.go @@ -93,8 +93,7 @@ func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, // ListSender sends the List request. The method will close the // http.Response Body if it receives an error. func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { - sd := autorest.GetSendDecorators(req.Context(), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - return autorest.SendWithSender(client, req, sd...) + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) } // ListResponder handles the response to the List request. The method always diff --git a/services/preview/attestation/mgmt/2018-09-01-preview/attestation/providers.go b/services/preview/attestation/mgmt/2018-09-01-preview/attestation/providers.go index 41af8e47ccc2..3d18acf0a396 100644 --- a/services/preview/attestation/mgmt/2018-09-01-preview/attestation/providers.go +++ b/services/preview/attestation/mgmt/2018-09-01-preview/attestation/providers.go @@ -48,7 +48,7 @@ func NewProvidersClientWithBaseURI(baseURI string, subscriptionID string) Provid // resourceGroupName - the name of the resource group. The name is case insensitive. // providerName - name of the attestation service // creationParams - client supplied parameters. -func (client ProvidersClient) Create(ctx context.Context, resourceGroupName string, providerName string, creationParams *ServiceCreationParams) (result Provider, err error) { +func (client ProvidersClient) Create(ctx context.Context, resourceGroupName string, providerName string, creationParams ServiceCreationParams) (result Provider, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/ProvidersClient.Create") defer func() { @@ -65,7 +65,10 @@ func (client ProvidersClient) Create(ctx context.Context, resourceGroupName stri {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 { + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: creationParams, + Constraints: []validation.Constraint{{Target: "creationParams.Location", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "creationParams.Properties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { return result, validation.NewError("attestation.ProvidersClient", "Create", err.Error()) } @@ -91,7 +94,7 @@ func (client ProvidersClient) Create(ctx context.Context, resourceGroupName stri } // CreatePreparer prepares the Create request. -func (client ProvidersClient) CreatePreparer(ctx context.Context, resourceGroupName string, providerName string, creationParams *ServiceCreationParams) (*http.Request, error) { +func (client ProvidersClient) CreatePreparer(ctx context.Context, resourceGroupName string, providerName string, creationParams ServiceCreationParams) (*http.Request, error) { pathParameters := map[string]interface{}{ "providerName": autorest.Encode("path", providerName), "resourceGroupName": autorest.Encode("path", resourceGroupName), @@ -108,19 +111,15 @@ func (client ProvidersClient) CreatePreparer(ctx context.Context, resourceGroupN autorest.AsPut(), autorest.WithBaseURL(client.BaseURI), autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Attestation/attestationProviders/{providerName}", pathParameters), + autorest.WithJSON(creationParams), autorest.WithQueryParameters(queryParameters)) - if creationParams != nil { - preparer = autorest.DecoratePreparer(preparer, - autorest.WithJSON(creationParams)) - } return preparer.Prepare((&http.Request{}).WithContext(ctx)) } // CreateSender sends the Create request. The method will close the // http.Response Body if it receives an error. func (client ProvidersClient) CreateSender(req *http.Request) (*http.Response, error) { - sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) - return autorest.SendWithSender(client, req, sd...) + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) } // CreateResponder handles the response to the Create request. The method always @@ -206,8 +205,7 @@ func (client ProvidersClient) DeletePreparer(ctx context.Context, resourceGroupN // DeleteSender sends the Delete request. The method will close the // http.Response Body if it receives an error. func (client ProvidersClient) DeleteSender(req *http.Request) (*http.Response, error) { - sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) - return autorest.SendWithSender(client, req, sd...) + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) } // DeleteResponder handles the response to the Delete request. The method always @@ -292,8 +290,7 @@ func (client ProvidersClient) GetPreparer(ctx context.Context, resourceGroupName // GetSender sends the Get request. The method will close the // http.Response Body if it receives an error. func (client ProvidersClient) GetSender(req *http.Request) (*http.Response, error) { - sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) - return autorest.SendWithSender(client, req, sd...) + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) } // GetResponder handles the response to the Get request. The method always @@ -370,8 +367,7 @@ func (client ProvidersClient) ListPreparer(ctx context.Context) (*http.Request, // ListSender sends the List request. The method will close the // http.Response Body if it receives an error. func (client ProvidersClient) ListSender(req *http.Request) (*http.Response, error) { - sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) - return autorest.SendWithSender(client, req, sd...) + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) } // ListResponder handles the response to the List request. The method always @@ -455,8 +451,7 @@ func (client ProvidersClient) ListByResourceGroupPreparer(ctx context.Context, r // ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the // http.Response Body if it receives an error. func (client ProvidersClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { - sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) - return autorest.SendWithSender(client, req, sd...) + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) } // ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always @@ -471,3 +466,92 @@ func (client ProvidersClient) ListByResourceGroupResponder(resp *http.Response) result.Response = autorest.Response{Response: resp} return } + +// Update updates the Attestation Provider. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// providerName - name of the attestation service +// updateParams - client supplied parameters. +func (client ProvidersClient) Update(ctx context.Context, resourceGroupName string, providerName string, updateParams ServicePatchParams) (result Provider, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProvidersClient.Update") + 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.MinLength, Rule: 1, 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("attestation.ProvidersClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, providerName, updateParams) + if err != nil { + err = autorest.NewErrorWithError(err, "attestation.ProvidersClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "attestation.ProvidersClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "attestation.ProvidersClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ProvidersClient) UpdatePreparer(ctx context.Context, resourceGroupName string, providerName string, updateParams ServicePatchParams) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "providerName": autorest.Encode("path", providerName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Attestation/attestationProviders/{providerName}", pathParameters), + autorest.WithJSON(updateParams), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client ProvidersClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ProvidersClient) UpdateResponder(resp *http.Response) (result Provider, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +}