diff --git a/services/preview/msi/mgmt/2015-08-31-preview/msi/models.go b/services/preview/msi/mgmt/2015-08-31-preview/msi/models.go index eff1b71c9e01..cd8806013df0 100644 --- a/services/preview/msi/mgmt/2015-08-31-preview/msi/models.go +++ b/services/preview/msi/mgmt/2015-08-31-preview/msi/models.go @@ -30,17 +30,16 @@ import ( // The package's fully qualified name. const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/msi/mgmt/2015-08-31-preview/msi" -// UserAssignedIdentities enumerates the values for user assigned identities. -type UserAssignedIdentities string - -const ( - // MicrosoftManagedIdentityuserAssignedIdentities ... - MicrosoftManagedIdentityuserAssignedIdentities UserAssignedIdentities = "Microsoft.ManagedIdentity/userAssignedIdentities" -) - -// PossibleUserAssignedIdentitiesValues returns an array of possible values for the UserAssignedIdentities const type. -func PossibleUserAssignedIdentitiesValues() []UserAssignedIdentities { - return []UserAssignedIdentities{MicrosoftManagedIdentityuserAssignedIdentities} +// AzureEntityResource the resource model definition for a Azure Resource Manager resource with an etag. +type AzureEntityResource struct { + // Etag - READ-ONLY; Resource Etag. + Etag *string `json:"etag,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 + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + Type *string `json:"type,omitempty"` } // CloudError an error response from the ManagedServiceIdentity service. @@ -64,31 +63,28 @@ type CloudErrorBody struct { // Identity describes an identity resource. type Identity struct { autorest.Response `json:"-"` - // ID - READ-ONLY; The id of the created identity. + // IdentityProperties - READ-ONLY; The properties associated with the identity. + *IdentityProperties `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 created identity. + // Name - READ-ONLY; The name of the resource Name *string `json:"name,omitempty"` - // Location - The Azure region where the identity lives. - Location *string `json:"location,omitempty"` - // Tags - Resource tags - Tags map[string]*string `json:"tags"` - // IdentityProperties - The properties associated with the identity. - *IdentityProperties `json:"properties,omitempty"` - // Type - READ-ONLY; The type of resource i.e. Microsoft.ManagedIdentity/userAssignedIdentities. Possible values include: 'MicrosoftManagedIdentityuserAssignedIdentities' - Type UserAssignedIdentities `json:"type,omitempty"` + // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + Type *string `json:"type,omitempty"` } // MarshalJSON is the custom marshaler for Identity. func (i Identity) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - if i.Location != nil { - objectMap["location"] = i.Location - } if i.Tags != nil { objectMap["tags"] = i.Tags } - if i.IdentityProperties != nil { - objectMap["properties"] = i.IdentityProperties + if i.Location != nil { + objectMap["location"] = i.Location } return json.Marshal(objectMap) } @@ -102,23 +98,23 @@ func (i *Identity) UnmarshalJSON(body []byte) error { } for k, v := range m { switch k { - case "id": + case "properties": if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) + var identityProperties IdentityProperties + err = json.Unmarshal(*v, &identityProperties) if err != nil { return err } - i.ID = &ID + i.IdentityProperties = &identityProperties } - case "name": + case "tags": if v != nil { - var name string - err = json.Unmarshal(*v, &name) + var tags map[string]*string + err = json.Unmarshal(*v, &tags) if err != nil { return err } - i.Name = &name + i.Tags = tags } case "location": if v != nil { @@ -129,32 +125,32 @@ func (i *Identity) UnmarshalJSON(body []byte) error { } i.Location = &location } - case "tags": + case "id": if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) + var ID string + err = json.Unmarshal(*v, &ID) if err != nil { return err } - i.Tags = tags + i.ID = &ID } - case "properties": + case "name": if v != nil { - var identityProperties IdentityProperties - err = json.Unmarshal(*v, &identityProperties) + var name string + err = json.Unmarshal(*v, &name) if err != nil { return err } - i.IdentityProperties = &identityProperties + i.Name = &name } case "type": if v != nil { - var typeVar UserAssignedIdentities + var typeVar string err = json.Unmarshal(*v, &typeVar) if err != nil { return err } - i.Type = typeVar + i.Type = &typeVar } } } @@ -340,6 +336,151 @@ func NewOperationListResultPage(getNextPage func(context.Context, OperationListR return OperationListResultPage{fn: getNextPage} } +// ProxyResource the resource model definition for a ARM proxy resource. It will have everything other than +// required location and tags +type ProxyResource struct { + // 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 + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + Type *string `json:"type,omitempty"` +} + +// Resource ... +type Resource struct { + // 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 + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + Type *string `json:"type,omitempty"` +} + +// SystemAssignedIdentity describes a system assigned identity resource. +type SystemAssignedIdentity struct { + autorest.Response `json:"-"` + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` + // IdentityProperties - READ-ONLY; The properties associated with the identity. + *IdentityProperties `json:"properties,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 + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for SystemAssignedIdentity. +func (sai SystemAssignedIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sai.Location != nil { + objectMap["location"] = sai.Location + } + if sai.Tags != nil { + objectMap["tags"] = sai.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SystemAssignedIdentity struct. +func (sai *SystemAssignedIdentity) 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 "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + sai.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + sai.Tags = tags + } + case "properties": + if v != nil { + var identityProperties IdentityProperties + err = json.Unmarshal(*v, &identityProperties) + if err != nil { + return err + } + sai.IdentityProperties = &identityProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sai.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sai.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sai.Type = &typeVar + } + } + } + + return nil +} + +// TrackedResource the resource model definition for a ARM tracked top level resource +type TrackedResource struct { + // 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 + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for TrackedResource. +func (tr TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tr.Tags != nil { + objectMap["tags"] = tr.Tags + } + if tr.Location != nil { + objectMap["location"] = tr.Location + } + return json.Marshal(objectMap) +} + // UserAssignedIdentitiesListResult values returned by the List operation. type UserAssignedIdentitiesListResult struct { autorest.Response `json:"-"` diff --git a/services/preview/msi/mgmt/2015-08-31-preview/msi/msiapi/interfaces.go b/services/preview/msi/mgmt/2015-08-31-preview/msi/msiapi/interfaces.go index 855d26fd9cac..152257bac8b6 100644 --- a/services/preview/msi/mgmt/2015-08-31-preview/msi/msiapi/interfaces.go +++ b/services/preview/msi/mgmt/2015-08-31-preview/msi/msiapi/interfaces.go @@ -23,6 +23,13 @@ import ( "github.com/Azure/go-autorest/autorest" ) +// SystemAssignedIdentitiesClientAPI contains the set of methods on the SystemAssignedIdentitiesClient type. +type SystemAssignedIdentitiesClientAPI interface { + GetByScope(ctx context.Context, scope string) (result msi.SystemAssignedIdentity, err error) +} + +var _ SystemAssignedIdentitiesClientAPI = (*msi.SystemAssignedIdentitiesClient)(nil) + // OperationsClientAPI contains the set of methods on the OperationsClient type. type OperationsClientAPI interface { List(ctx context.Context) (result msi.OperationListResultPage, err error) diff --git a/services/preview/msi/mgmt/2015-08-31-preview/msi/operations.go b/services/preview/msi/mgmt/2015-08-31-preview/msi/operations.go index c4a4e64805ea..7c70d0cadd28 100644 --- a/services/preview/msi/mgmt/2015-08-31-preview/msi/operations.go +++ b/services/preview/msi/mgmt/2015-08-31-preview/msi/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/msi/mgmt/2015-08-31-preview/msi/systemassignedidentities.go b/services/preview/msi/mgmt/2015-08-31-preview/msi/systemassignedidentities.go new file mode 100644 index 000000000000..152a4db68b08 --- /dev/null +++ b/services/preview/msi/mgmt/2015-08-31-preview/msi/systemassignedidentities.go @@ -0,0 +1,116 @@ +package msi + +// 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/tracing" + "net/http" +) + +// SystemAssignedIdentitiesClient is the the Managed Service Identity Client. +type SystemAssignedIdentitiesClient struct { + BaseClient +} + +// NewSystemAssignedIdentitiesClient creates an instance of the SystemAssignedIdentitiesClient client. +func NewSystemAssignedIdentitiesClient(subscriptionID string) SystemAssignedIdentitiesClient { + return NewSystemAssignedIdentitiesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewSystemAssignedIdentitiesClientWithBaseURI creates an instance of the SystemAssignedIdentitiesClient client using +// a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewSystemAssignedIdentitiesClientWithBaseURI(baseURI string, subscriptionID string) SystemAssignedIdentitiesClient { + return SystemAssignedIdentitiesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// GetByScope gets the systemAssignedIdentity available under the specified RP scope. +// Parameters: +// scope - the resource provider scope of the resource. Parent resource being extended by Managed Identities. +func (client SystemAssignedIdentitiesClient) GetByScope(ctx context.Context, scope string) (result SystemAssignedIdentity, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SystemAssignedIdentitiesClient.GetByScope") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetByScopePreparer(ctx, scope) + if err != nil { + err = autorest.NewErrorWithError(err, "msi.SystemAssignedIdentitiesClient", "GetByScope", nil, "Failure preparing request") + return + } + + resp, err := client.GetByScopeSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "msi.SystemAssignedIdentitiesClient", "GetByScope", resp, "Failure sending request") + return + } + + result, err = client.GetByScopeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "msi.SystemAssignedIdentitiesClient", "GetByScope", resp, "Failure responding to request") + } + + return +} + +// GetByScopePreparer prepares the GetByScope request. +func (client SystemAssignedIdentitiesClient) GetByScopePreparer(ctx context.Context, scope string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "scope": scope, + } + + const APIVersion = "2015-08-31-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.ManagedIdentity/identities/default", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetByScopeSender sends the GetByScope request. The method will close the +// http.Response Body if it receives an error. +func (client SystemAssignedIdentitiesClient) GetByScopeSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetByScopeResponder handles the response to the GetByScope request. The method always +// closes the http.Response Body. +func (client SystemAssignedIdentitiesClient) GetByScopeResponder(resp *http.Response) (result SystemAssignedIdentity, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/msi/mgmt/2015-08-31-preview/msi/userassignedidentities.go b/services/preview/msi/mgmt/2015-08-31-preview/msi/userassignedidentities.go index 7a10c8cd0410..0e8db813ebbb 100644 --- a/services/preview/msi/mgmt/2015-08-31-preview/msi/userassignedidentities.go +++ b/services/preview/msi/mgmt/2015-08-31-preview/msi/userassignedidentities.go @@ -92,9 +92,7 @@ func (client UserAssignedIdentitiesClient) CreateOrUpdatePreparer(ctx context.Co "api-version": APIVersion, } - parameters.ID = nil - parameters.Name = nil - parameters.Type = "" + parameters.IdentityProperties = nil preparer := autorest.CreatePreparer( autorest.AsContentType("application/json; charset=utf-8"), autorest.AsPut(), @@ -108,8 +106,7 @@ func (client UserAssignedIdentitiesClient) CreateOrUpdatePreparer(ctx context.Co // CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the // http.Response Body if it receives an error. func (client UserAssignedIdentitiesClient) CreateOrUpdateSender(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)) } // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always @@ -185,8 +182,7 @@ func (client UserAssignedIdentitiesClient) DeletePreparer(ctx context.Context, r // DeleteSender sends the Delete request. The method will close the // http.Response Body if it receives an error. func (client UserAssignedIdentitiesClient) 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 @@ -261,8 +257,7 @@ func (client UserAssignedIdentitiesClient) GetPreparer(ctx context.Context, reso // GetSender sends the Get request. The method will close the // http.Response Body if it receives an error. func (client UserAssignedIdentitiesClient) 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 @@ -337,8 +332,7 @@ func (client UserAssignedIdentitiesClient) ListByResourceGroupPreparer(ctx conte // ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the // http.Response Body if it receives an error. func (client UserAssignedIdentitiesClient) 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 @@ -447,8 +441,7 @@ func (client UserAssignedIdentitiesClient) ListBySubscriptionPreparer(ctx contex // ListBySubscriptionSender sends the ListBySubscription request. The method will close the // http.Response Body if it receives an error. func (client UserAssignedIdentitiesClient) ListBySubscriptionSender(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)) } // ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always @@ -551,9 +544,7 @@ func (client UserAssignedIdentitiesClient) UpdatePreparer(ctx context.Context, r "api-version": APIVersion, } - parameters.ID = nil - parameters.Name = nil - parameters.Type = "" + parameters.IdentityProperties = nil preparer := autorest.CreatePreparer( autorest.AsContentType("application/json; charset=utf-8"), autorest.AsPatch(), @@ -567,8 +558,7 @@ func (client UserAssignedIdentitiesClient) UpdatePreparer(ctx context.Context, r // UpdateSender sends the Update request. The method will close the // http.Response Body if it receives an error. func (client UserAssignedIdentitiesClient) UpdateSender(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)) } // UpdateResponder handles the response to the Update request. The method always