1package managementgroups 2 3// Copyright (c) Microsoft and contributors. All rights reserved. 4// 5// Licensed under the Apache License, Version 2.0 (the "License"); 6// you may not use this file except in compliance with the License. 7// You may obtain a copy of the License at 8// http://www.apache.org/licenses/LICENSE-2.0 9// 10// Unless required by applicable law or agreed to in writing, software 11// distributed under the License is distributed on an "AS IS" BASIS, 12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13// 14// See the License for the specific language governing permissions and 15// limitations under the License. 16// 17// Code generated by Microsoft (R) AutoRest Code Generator. 18// Changes may cause incorrect behavior and will be lost if the code is regenerated. 19 20import ( 21 "context" 22 "github.com/Azure/go-autorest/autorest" 23 "github.com/Azure/go-autorest/autorest/azure" 24 "net/http" 25) 26 27// Deprecated: Please use package github.com/Azure/azure-sdk-for-go/services/preview/resources/mgmt/2018-01-01-preview/management instead. 28// EntitiesClient is the the Azure Management Groups API enables consolidation of multiple 29// subscriptions/resources into an organizational hierarchy and centrally 30// manage access control, policies, alerting and reporting for those resources. 31type EntitiesClient struct { 32 BaseClient 33} 34 35// Deprecated: Please use package github.com/Azure/azure-sdk-for-go/services/preview/resources/mgmt/2018-01-01-preview/management instead. 36// NewEntitiesClient creates an instance of the EntitiesClient client. 37func NewEntitiesClient(operationResultID string, skiptoken string) EntitiesClient { 38 return NewEntitiesClientWithBaseURI(DefaultBaseURI, operationResultID, skiptoken) 39} 40 41// Deprecated: Please use package github.com/Azure/azure-sdk-for-go/services/preview/resources/mgmt/2018-01-01-preview/management instead. 42// NewEntitiesClientWithBaseURI creates an instance of the EntitiesClient client. 43func NewEntitiesClientWithBaseURI(baseURI string, operationResultID string, skiptoken string) EntitiesClient { 44 return EntitiesClient{NewWithBaseURI(baseURI, operationResultID, skiptoken)} 45} 46 47// Deprecated: Please use package github.com/Azure/azure-sdk-for-go/services/preview/resources/mgmt/2018-01-01-preview/management instead. 48// List list all entities (Management Groups, Subscriptions, etc.) for the authenticated user. 49// 50// groupName is a filter which allows the call to be filtered for a specific group. cacheControl is indicates that 51// the request shouldn't utilize any caches. 52func (client EntitiesClient) List(ctx context.Context, groupName string, cacheControl string) (result EntityListResultPage, err error) { 53 result.fn = client.listNextResults 54 req, err := client.ListPreparer(ctx, groupName, cacheControl) 55 if err != nil { 56 err = autorest.NewErrorWithError(err, "managementgroups.EntitiesClient", "List", nil, "Failure preparing request") 57 return 58 } 59 60 resp, err := client.ListSender(req) 61 if err != nil { 62 result.elr.Response = autorest.Response{Response: resp} 63 err = autorest.NewErrorWithError(err, "managementgroups.EntitiesClient", "List", resp, "Failure sending request") 64 return 65 } 66 67 result.elr, err = client.ListResponder(resp) 68 if err != nil { 69 err = autorest.NewErrorWithError(err, "managementgroups.EntitiesClient", "List", resp, "Failure responding to request") 70 } 71 72 return 73} 74 75// Deprecated: Please use package github.com/Azure/azure-sdk-for-go/services/preview/resources/mgmt/2018-01-01-preview/management instead. 76// ListPreparer prepares the List request. 77func (client EntitiesClient) ListPreparer(ctx context.Context, groupName string, cacheControl string) (*http.Request, error) { 78 const APIVersion = "2018-01-01-preview" 79 queryParameters := map[string]interface{}{ 80 "api-version": APIVersion, 81 } 82 if len(client.Skiptoken) > 0 { 83 queryParameters["$skiptoken"] = autorest.Encode("query", client.Skiptoken) 84 } 85 if len(groupName) > 0 { 86 queryParameters["groupName"] = autorest.Encode("query", groupName) 87 } 88 89 preparer := autorest.CreatePreparer( 90 autorest.AsPost(), 91 autorest.WithBaseURL(client.BaseURI), 92 autorest.WithPath("/providers/Microsoft.Management/getEntities"), 93 autorest.WithQueryParameters(queryParameters)) 94 if len(cacheControl) > 0 { 95 preparer = autorest.DecoratePreparer(preparer, 96 autorest.WithHeader("Cache-Control", autorest.String(cacheControl))) 97 } else { 98 preparer = autorest.DecoratePreparer(preparer, 99 autorest.WithHeader("Cache-Control", autorest.String("no-cache"))) 100 } 101 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 102} 103 104// Deprecated: Please use package github.com/Azure/azure-sdk-for-go/services/preview/resources/mgmt/2018-01-01-preview/management instead. 105// ListSender sends the List request. The method will close the 106// http.Response Body if it receives an error. 107func (client EntitiesClient) ListSender(req *http.Request) (*http.Response, error) { 108 return autorest.SendWithSender(client, req, 109 autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 110} 111 112// Deprecated: Please use package github.com/Azure/azure-sdk-for-go/services/preview/resources/mgmt/2018-01-01-preview/management instead. 113// ListResponder handles the response to the List request. The method always 114// closes the http.Response Body. 115func (client EntitiesClient) ListResponder(resp *http.Response) (result EntityListResult, err error) { 116 err = autorest.Respond( 117 resp, 118 client.ByInspecting(), 119 azure.WithErrorUnlessStatusCode(http.StatusOK), 120 autorest.ByUnmarshallingJSON(&result), 121 autorest.ByClosing()) 122 result.Response = autorest.Response{Response: resp} 123 return 124} 125 126// listNextResults retrieves the next set of results, if any. 127func (client EntitiesClient) listNextResults(lastResults EntityListResult) (result EntityListResult, err error) { 128 req, err := lastResults.entityListResultPreparer() 129 if err != nil { 130 return result, autorest.NewErrorWithError(err, "managementgroups.EntitiesClient", "listNextResults", nil, "Failure preparing next results request") 131 } 132 if req == nil { 133 return 134 } 135 resp, err := client.ListSender(req) 136 if err != nil { 137 result.Response = autorest.Response{Response: resp} 138 return result, autorest.NewErrorWithError(err, "managementgroups.EntitiesClient", "listNextResults", resp, "Failure sending next results request") 139 } 140 result, err = client.ListResponder(resp) 141 if err != nil { 142 err = autorest.NewErrorWithError(err, "managementgroups.EntitiesClient", "listNextResults", resp, "Failure responding to next results request") 143 } 144 return 145} 146 147// Deprecated: Please use package github.com/Azure/azure-sdk-for-go/services/preview/resources/mgmt/2018-01-01-preview/management instead. 148// ListComplete enumerates all values, automatically crossing page boundaries as required. 149func (client EntitiesClient) ListComplete(ctx context.Context, groupName string, cacheControl string) (result EntityListResultIterator, err error) { 150 result.page, err = client.List(ctx, groupName, cacheControl) 151 return 152} 153