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..0ccf45dc4548 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,14 @@ 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) + GetDefaultByLocation(ctx context.Context, location 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) + ListDefault(ctx context.Context) (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 7490592ec414..cb5fa926d9a3 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 @@ -101,7 +101,6 @@ func (client OperationsClient) ListSender(req *http.Request) (*http.Response, er func (client OperationsClient) ListResponder(resp *http.Response) (result OperationList, err error) { err = autorest.Respond( resp, - client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) 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 a29dc36e892e..d5165a91dbe4 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,11 +111,8 @@ 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)) } @@ -127,7 +127,6 @@ func (client ProvidersClient) CreateSender(req *http.Request) (*http.Response, e func (client ProvidersClient) CreateResponder(resp *http.Response) (result Provider, err error) { err = autorest.Respond( resp, - client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) @@ -213,7 +212,6 @@ func (client ProvidersClient) DeleteSender(req *http.Request) (*http.Response, e func (client ProvidersClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { err = autorest.Respond( resp, - client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), autorest.ByClosing()) result.Response = resp @@ -298,7 +296,87 @@ func (client ProvidersClient) GetSender(req *http.Request) (*http.Response, erro func (client ProvidersClient) GetResponder(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 +} + +// GetDefaultByLocation get the default provider by location. +// Parameters: +// location - the location of the default provider. +func (client ProvidersClient) GetDefaultByLocation(ctx context.Context, location string) (result Provider, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProvidersClient.GetDefaultByLocation") + 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: location, + Constraints: []validation.Constraint{{Target: "location", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("attestation.ProvidersClient", "GetDefaultByLocation", err.Error()) + } + + req, err := client.GetDefaultByLocationPreparer(ctx, location) + if err != nil { + err = autorest.NewErrorWithError(err, "attestation.ProvidersClient", "GetDefaultByLocation", nil, "Failure preparing request") + return + } + + resp, err := client.GetDefaultByLocationSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "attestation.ProvidersClient", "GetDefaultByLocation", resp, "Failure sending request") + return + } + + result, err = client.GetDefaultByLocationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "attestation.ProvidersClient", "GetDefaultByLocation", resp, "Failure responding to request") + } + + return +} + +// GetDefaultByLocationPreparer prepares the GetDefaultByLocation request. +func (client ProvidersClient) GetDefaultByLocationPreparer(ctx context.Context, location string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "location": autorest.Encode("path", location), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Attestation/locations/{location}/defaultProvider", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetDefaultByLocationSender sends the GetDefaultByLocation request. The method will close the +// http.Response Body if it receives an error. +func (client ProvidersClient) GetDefaultByLocationSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetDefaultByLocationResponder handles the response to the GetDefaultByLocation request. The method always +// closes the http.Response Body. +func (client ProvidersClient) GetDefaultByLocationResponder(resp *http.Response) (result Provider, err error) { + err = autorest.Respond( + resp, azure.WithErrorUnlessStatusCode(http.StatusOK), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) @@ -375,7 +453,6 @@ func (client ProvidersClient) ListSender(req *http.Request) (*http.Response, err func (client ProvidersClient) ListResponder(resp *http.Response) (result ProviderListResult, err error) { err = autorest.Respond( resp, - client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) @@ -459,7 +536,170 @@ func (client ProvidersClient) ListByResourceGroupSender(req *http.Request) (*htt func (client ProvidersClient) ListByResourceGroupResponder(resp *http.Response) (result ProviderListResult, err error) { err = autorest.Respond( resp, - client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListDefault get the default provider +func (client ProvidersClient) ListDefault(ctx context.Context) (result ProviderListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProvidersClient.ListDefault") + 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}}}}); err != nil { + return result, validation.NewError("attestation.ProvidersClient", "ListDefault", err.Error()) + } + + req, err := client.ListDefaultPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "attestation.ProvidersClient", "ListDefault", nil, "Failure preparing request") + return + } + + resp, err := client.ListDefaultSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "attestation.ProvidersClient", "ListDefault", resp, "Failure sending request") + return + } + + result, err = client.ListDefaultResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "attestation.ProvidersClient", "ListDefault", resp, "Failure responding to request") + } + + return +} + +// ListDefaultPreparer prepares the ListDefault request. +func (client ProvidersClient) ListDefaultPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Attestation/defaultProviders", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListDefaultSender sends the ListDefault request. The method will close the +// http.Response Body if it receives an error. +func (client ProvidersClient) ListDefaultSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListDefaultResponder handles the response to the ListDefault request. The method always +// closes the http.Response Body. +func (client ProvidersClient) ListDefaultResponder(resp *http.Response) (result ProviderListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + 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, azure.WithErrorUnlessStatusCode(http.StatusOK), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) diff --git a/services/preview/attestation/mgmt/2018-09-01-preview/attestation/version.go b/services/preview/attestation/mgmt/2018-09-01-preview/attestation/version.go index 6c0e2271bb5b..0370f916b9f4 100644 --- a/services/preview/attestation/mgmt/2018-09-01-preview/attestation/version.go +++ b/services/preview/attestation/mgmt/2018-09-01-preview/attestation/version.go @@ -21,7 +21,7 @@ import "github.com/Azure/azure-sdk-for-go/version" // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/" + version.Number + " attestation/2018-09-01-preview" + return "Azure-SDK-For-Go/" + Version() + " attestation/2018-09-01-preview" } // Version returns the semantic version (see http://semver.org) of the client.