diff --git a/services/domainservices/mgmt/2017-06-01/aad/aadapi/interfaces.go b/services/domainservices/mgmt/2017-06-01/aad/aadapi/interfaces.go index 1f03df950c61..b74ffec75d88 100644 --- a/services/domainservices/mgmt/2017-06-01/aad/aadapi/interfaces.go +++ b/services/domainservices/mgmt/2017-06-01/aad/aadapi/interfaces.go @@ -43,3 +43,23 @@ type DomainServicesClientAPI interface { } var _ DomainServicesClientAPI = (*aad.DomainServicesClient)(nil) + +// OuContainerOperationsClientAPI contains the set of methods on the OuContainerOperationsClient type. +type OuContainerOperationsClientAPI interface { + List(ctx context.Context) (result aad.OperationEntityListResultPage, err error) + ListComplete(ctx context.Context) (result aad.OperationEntityListResultIterator, err error) +} + +var _ OuContainerOperationsClientAPI = (*aad.OuContainerOperationsClient)(nil) + +// OuContainerClientAPI contains the set of methods on the OuContainerClient type. +type OuContainerClientAPI interface { + Create(ctx context.Context, resourceGroupName string, domainServiceName string, ouContainerName string, containerAccount aad.ContainerAccount) (result aad.OuContainerCreateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, domainServiceName string, ouContainerName string) (result aad.OuContainerDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, domainServiceName string, ouContainerName string) (result aad.OuContainer, err error) + List(ctx context.Context, resourceGroupName string, domainServiceName string) (result aad.OuContainerListResultPage, err error) + ListComplete(ctx context.Context, resourceGroupName string, domainServiceName string) (result aad.OuContainerListResultIterator, err error) + Update(ctx context.Context, resourceGroupName string, domainServiceName string, ouContainerName string, containerAccount aad.ContainerAccount) (result aad.OuContainerUpdateFuture, err error) +} + +var _ OuContainerClientAPI = (*aad.OuContainerClient)(nil) diff --git a/services/domainservices/mgmt/2017-06-01/aad/models.go b/services/domainservices/mgmt/2017-06-01/aad/models.go index 29a26983786d..7e82b6ed673b 100644 --- a/services/domainservices/mgmt/2017-06-01/aad/models.go +++ b/services/domainservices/mgmt/2017-06-01/aad/models.go @@ -31,6 +31,34 @@ import ( // The package's fully qualified name. const fqdn = "github.com/Azure/azure-sdk-for-go/services/domainservices/mgmt/2017-06-01/aad" +// CloudError an error response from the Domain Services. +type CloudError struct { + // Error - An error response from the Domain Services. + Error *CloudErrorBody `json:"error,omitempty"` +} + +// CloudErrorBody an error response from the Domain Services. +type CloudErrorBody struct { + // Code - An identifier for the error. Codes are invariant and are intended to be consumed programmatically. + Code *string `json:"code,omitempty"` + // Message - A message describing the error, intended to be suitable for display in a user interface. + Message *string `json:"message,omitempty"` + // Target - The target of the particular error. For example, the name of the property in error. + Target *string `json:"target,omitempty"` + // Details - A list of additional details about the error. + Details *[]CloudErrorBody `json:"details,omitempty"` +} + +// ContainerAccount container Account Description +type ContainerAccount struct { + // AccountName - The account name + AccountName *string `json:"accountName,omitempty"` + // Spn - The account spn + Spn *string `json:"spn,omitempty"` + // Password - The account password + Password *string `json:"password,omitempty"` +} + // DomainSecuritySettings domain Security Settings type DomainSecuritySettings struct { // NtlmV1 - A flag to determine whether or not NtlmV1 is enabled or disabled. Possible values include: 'NtlmV1Enabled', 'NtlmV1Disabled' @@ -721,6 +749,394 @@ func NewOperationEntityListResultPage(getNextPage func(context.Context, Operatio return OperationEntityListResultPage{fn: getNextPage} } +// OuContainer resource for OuContainer. +type OuContainer struct { + autorest.Response `json:"-"` + // OuContainerProperties - OuContainer properties + *OuContainerProperties `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"` + // Location - Resource location + Location *string `json:"location,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` + // Etag - Resource etag + Etag *string `json:"etag,omitempty"` +} + +// MarshalJSON is the custom marshaler for OuContainer. +func (oc OuContainer) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if oc.OuContainerProperties != nil { + objectMap["properties"] = oc.OuContainerProperties + } + if oc.Location != nil { + objectMap["location"] = oc.Location + } + if oc.Tags != nil { + objectMap["tags"] = oc.Tags + } + if oc.Etag != nil { + objectMap["etag"] = oc.Etag + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for OuContainer struct. +func (oc *OuContainer) 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 ouContainerProperties OuContainerProperties + err = json.Unmarshal(*v, &ouContainerProperties) + if err != nil { + return err + } + oc.OuContainerProperties = &ouContainerProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + oc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + oc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + oc.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + oc.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + oc.Tags = tags + } + case "etag": + if v != nil { + var etag string + err = json.Unmarshal(*v, &etag) + if err != nil { + return err + } + oc.Etag = &etag + } + } + } + + return nil +} + +// OuContainerCreateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type OuContainerCreateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *OuContainerCreateFuture) Result(client OuContainerClient) (oc OuContainer, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "aad.OuContainerCreateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("aad.OuContainerCreateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if oc.Response.Response, err = future.GetResult(sender); err == nil && oc.Response.Response.StatusCode != http.StatusNoContent { + oc, err = client.CreateResponder(oc.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "aad.OuContainerCreateFuture", "Result", oc.Response.Response, "Failure responding to request") + } + } + return +} + +// OuContainerDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type OuContainerDeleteFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *OuContainerDeleteFuture) Result(client OuContainerClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "aad.OuContainerDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("aad.OuContainerDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// OuContainerListResult the response from the List OuContainer operation. +type OuContainerListResult struct { + autorest.Response `json:"-"` + // Value - The list of OuContainer. + Value *[]OuContainer `json:"value,omitempty"` + // NextLink - READ-ONLY; The continuation token for the next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for OuContainerListResult. +func (oclr OuContainerListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if oclr.Value != nil { + objectMap["value"] = oclr.Value + } + return json.Marshal(objectMap) +} + +// OuContainerListResultIterator provides access to a complete listing of OuContainer values. +type OuContainerListResultIterator struct { + i int + page OuContainerListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *OuContainerListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OuContainerListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *OuContainerListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter OuContainerListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter OuContainerListResultIterator) Response() OuContainerListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter OuContainerListResultIterator) Value() OuContainer { + if !iter.page.NotDone() { + return OuContainer{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the OuContainerListResultIterator type. +func NewOuContainerListResultIterator(page OuContainerListResultPage) OuContainerListResultIterator { + return OuContainerListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (oclr OuContainerListResult) IsEmpty() bool { + return oclr.Value == nil || len(*oclr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (oclr OuContainerListResult) hasNextLink() bool { + return oclr.NextLink != nil && len(*oclr.NextLink) != 0 +} + +// ouContainerListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (oclr OuContainerListResult) ouContainerListResultPreparer(ctx context.Context) (*http.Request, error) { + if !oclr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(oclr.NextLink))) +} + +// OuContainerListResultPage contains a page of OuContainer values. +type OuContainerListResultPage struct { + fn func(context.Context, OuContainerListResult) (OuContainerListResult, error) + oclr OuContainerListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *OuContainerListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OuContainerListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.oclr) + if err != nil { + return err + } + page.oclr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *OuContainerListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page OuContainerListResultPage) NotDone() bool { + return !page.oclr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page OuContainerListResultPage) Response() OuContainerListResult { + return page.oclr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page OuContainerListResultPage) Values() []OuContainer { + if page.oclr.IsEmpty() { + return nil + } + return *page.oclr.Value +} + +// Creates a new instance of the OuContainerListResultPage type. +func NewOuContainerListResultPage(getNextPage func(context.Context, OuContainerListResult) (OuContainerListResult, error)) OuContainerListResultPage { + return OuContainerListResultPage{fn: getNextPage} +} + +// OuContainerProperties properties of the OuContainer. +type OuContainerProperties struct { + // TenantID - READ-ONLY; Azure Active Directory tenant id + TenantID *string `json:"tenantId,omitempty"` + // DomainName - READ-ONLY; The domain name of Domain Services. + DomainName *string `json:"domainName,omitempty"` + // DeploymentID - READ-ONLY; The Deployment id + DeploymentID *string `json:"deploymentId,omitempty"` + // ContainerID - READ-ONLY; The OuContainer name + ContainerID *string `json:"containerId,omitempty"` + // Accounts - The list of container accounts + Accounts *[]ContainerAccount `json:"accounts,omitempty"` + // ServiceStatus - READ-ONLY; Status of OuContainer instance + ServiceStatus *string `json:"serviceStatus,omitempty"` + // ProvisioningState - READ-ONLY; The current deployment or provisioning state, which only appears in the response. + ProvisioningState *string `json:"provisioningState,omitempty"` +} + +// MarshalJSON is the custom marshaler for OuContainerProperties. +func (ocp OuContainerProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ocp.Accounts != nil { + objectMap["accounts"] = ocp.Accounts + } + return json.Marshal(objectMap) +} + +// OuContainerUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type OuContainerUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *OuContainerUpdateFuture) Result(client OuContainerClient) (oc OuContainer, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "aad.OuContainerUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("aad.OuContainerUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if oc.Response.Response, err = future.GetResult(sender); err == nil && oc.Response.Response.StatusCode != http.StatusNoContent { + oc, err = client.UpdateResponder(oc.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "aad.OuContainerUpdateFuture", "Result", oc.Response.Response, "Failure responding to request") + } + } + return +} + // Resource the Resource model definition. type Resource struct { // ID - READ-ONLY; Resource Id diff --git a/services/domainservices/mgmt/2017-06-01/aad/oucontainer.go b/services/domainservices/mgmt/2017-06-01/aad/oucontainer.go new file mode 100644 index 000000000000..45c8a3547306 --- /dev/null +++ b/services/domainservices/mgmt/2017-06-01/aad/oucontainer.go @@ -0,0 +1,517 @@ +package aad + +// 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" +) + +// OuContainerClient is the the AAD Domain Services API. +type OuContainerClient struct { + BaseClient +} + +// NewOuContainerClient creates an instance of the OuContainerClient client. +func NewOuContainerClient(subscriptionID string) OuContainerClient { + return NewOuContainerClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOuContainerClientWithBaseURI creates an instance of the OuContainerClient 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 NewOuContainerClientWithBaseURI(baseURI string, subscriptionID string) OuContainerClient { + return OuContainerClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create the Create OuContainer operation creates a new OuContainer under the specified Domain Service instance. +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// domainServiceName - the name of the domain service. +// ouContainerName - the name of the OuContainer. +// containerAccount - container Account Description. +func (client OuContainerClient) Create(ctx context.Context, resourceGroupName string, domainServiceName string, ouContainerName string, containerAccount ContainerAccount) (result OuContainerCreateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OuContainerClient.Create") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {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("aad.OuContainerClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, domainServiceName, ouContainerName, containerAccount) + if err != nil { + err = autorest.NewErrorWithError(err, "aad.OuContainerClient", "Create", nil, "Failure preparing request") + return + } + + result, err = client.CreateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "aad.OuContainerClient", "Create", result.Response(), "Failure sending request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client OuContainerClient) CreatePreparer(ctx context.Context, resourceGroupName string, domainServiceName string, ouContainerName string, containerAccount ContainerAccount) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "domainServiceName": autorest.Encode("path", domainServiceName), + "ouContainerName": autorest.Encode("path", ouContainerName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Aad/domainServices/{domainServiceName}/ouContainer/{ouContainerName}", pathParameters), + autorest.WithJSON(containerAccount), + autorest.WithQueryParameters(queryParameters)) + 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 OuContainerClient) CreateSender(req *http.Request) (future OuContainerCreateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client OuContainerClient) CreateResponder(resp *http.Response) (result OuContainer, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete the Delete OuContainer operation deletes specified OuContainer. +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// domainServiceName - the name of the domain service. +// ouContainerName - the name of the OuContainer. +func (client OuContainerClient) Delete(ctx context.Context, resourceGroupName string, domainServiceName string, ouContainerName string) (result OuContainerDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OuContainerClient.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: 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("aad.OuContainerClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, domainServiceName, ouContainerName) + if err != nil { + err = autorest.NewErrorWithError(err, "aad.OuContainerClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "aad.OuContainerClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client OuContainerClient) DeletePreparer(ctx context.Context, resourceGroupName string, domainServiceName string, ouContainerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "domainServiceName": autorest.Encode("path", domainServiceName), + "ouContainerName": autorest.Encode("path", ouContainerName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Aad/domainServices/{domainServiceName}/ouContainer/{ouContainerName}", 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 OuContainerClient) DeleteSender(req *http.Request) (future OuContainerDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client OuContainerClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get OuContainer in DomainService instance. +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// domainServiceName - the name of the domain service. +// ouContainerName - the name of the OuContainer. +func (client OuContainerClient) Get(ctx context.Context, resourceGroupName string, domainServiceName string, ouContainerName string) (result OuContainer, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OuContainerClient.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: 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("aad.OuContainerClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, domainServiceName, ouContainerName) + if err != nil { + err = autorest.NewErrorWithError(err, "aad.OuContainerClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "aad.OuContainerClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "aad.OuContainerClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client OuContainerClient) GetPreparer(ctx context.Context, resourceGroupName string, domainServiceName string, ouContainerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "domainServiceName": autorest.Encode("path", domainServiceName), + "ouContainerName": autorest.Encode("path", ouContainerName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Aad/domainServices/{domainServiceName}/ouContainer/{ouContainerName}", 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 OuContainerClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client OuContainerClient) GetResponder(resp *http.Response) (result OuContainer, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List the List of OuContainers in DomainService instance. +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// domainServiceName - the name of the domain service. +func (client OuContainerClient) List(ctx context.Context, resourceGroupName string, domainServiceName string) (result OuContainerListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OuContainerClient.List") + defer func() { + sc := -1 + if result.oclr.Response.Response != nil { + sc = result.oclr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {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("aad.OuContainerClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, domainServiceName) + if err != nil { + err = autorest.NewErrorWithError(err, "aad.OuContainerClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.oclr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "aad.OuContainerClient", "List", resp, "Failure sending request") + return + } + + result.oclr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "aad.OuContainerClient", "List", resp, "Failure responding to request") + } + if result.oclr.hasNextLink() && result.oclr.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client OuContainerClient) ListPreparer(ctx context.Context, resourceGroupName string, domainServiceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "domainServiceName": autorest.Encode("path", domainServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Aad/domainServices/{domainServiceName}/ouContainer", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OuContainerClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OuContainerClient) ListResponder(resp *http.Response) (result OuContainerListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client OuContainerClient) listNextResults(ctx context.Context, lastResults OuContainerListResult) (result OuContainerListResult, err error) { + req, err := lastResults.ouContainerListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "aad.OuContainerClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "aad.OuContainerClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "aad.OuContainerClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client OuContainerClient) ListComplete(ctx context.Context, resourceGroupName string, domainServiceName string) (result OuContainerListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OuContainerClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, resourceGroupName, domainServiceName) + return +} + +// Update the Update OuContainer operation can be used to update the existing OuContainers. +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// domainServiceName - the name of the domain service. +// ouContainerName - the name of the OuContainer. +// containerAccount - container Account Description. +func (client OuContainerClient) Update(ctx context.Context, resourceGroupName string, domainServiceName string, ouContainerName string, containerAccount ContainerAccount) (result OuContainerUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OuContainerClient.Update") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {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("aad.OuContainerClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, domainServiceName, ouContainerName, containerAccount) + if err != nil { + err = autorest.NewErrorWithError(err, "aad.OuContainerClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "aad.OuContainerClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client OuContainerClient) UpdatePreparer(ctx context.Context, resourceGroupName string, domainServiceName string, ouContainerName string, containerAccount ContainerAccount) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "domainServiceName": autorest.Encode("path", domainServiceName), + "ouContainerName": autorest.Encode("path", ouContainerName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-06-01" + 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.Aad/domainServices/{domainServiceName}/ouContainer/{ouContainerName}", pathParameters), + autorest.WithJSON(containerAccount), + 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 OuContainerClient) UpdateSender(req *http.Request) (future OuContainerUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client OuContainerClient) UpdateResponder(resp *http.Response) (result OuContainer, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/domainservices/mgmt/2017-06-01/aad/oucontaineroperations.go b/services/domainservices/mgmt/2017-06-01/aad/oucontaineroperations.go new file mode 100644 index 000000000000..d3a975dea95f --- /dev/null +++ b/services/domainservices/mgmt/2017-06-01/aad/oucontaineroperations.go @@ -0,0 +1,150 @@ +package aad + +// 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" +) + +// OuContainerOperationsClient is the the AAD Domain Services API. +type OuContainerOperationsClient struct { + BaseClient +} + +// NewOuContainerOperationsClient creates an instance of the OuContainerOperationsClient client. +func NewOuContainerOperationsClient(subscriptionID string) OuContainerOperationsClient { + return NewOuContainerOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOuContainerOperationsClientWithBaseURI creates an instance of the OuContainerOperationsClient 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 NewOuContainerOperationsClientWithBaseURI(baseURI string, subscriptionID string) OuContainerOperationsClient { + return OuContainerOperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all the available OuContainer operations. +func (client OuContainerOperationsClient) List(ctx context.Context) (result OperationEntityListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OuContainerOperationsClient.List") + defer func() { + sc := -1 + if result.oelr.Response.Response != nil { + sc = result.oelr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "aad.OuContainerOperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.oelr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "aad.OuContainerOperationsClient", "List", resp, "Failure sending request") + return + } + + result.oelr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "aad.OuContainerOperationsClient", "List", resp, "Failure responding to request") + } + if result.oelr.hasNextLink() && result.oelr.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client OuContainerOperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Aad/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OuContainerOperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OuContainerOperationsClient) ListResponder(resp *http.Response) (result OperationEntityListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client OuContainerOperationsClient) listNextResults(ctx context.Context, lastResults OperationEntityListResult) (result OperationEntityListResult, err error) { + req, err := lastResults.operationEntityListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "aad.OuContainerOperationsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "aad.OuContainerOperationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "aad.OuContainerOperationsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client OuContainerOperationsClient) ListComplete(ctx context.Context) (result OperationEntityListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OuContainerOperationsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +}