1package migrate 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// AssessedMachinesClient is the move your workloads to Azure. 28type AssessedMachinesClient struct { 29 BaseClient 30} 31 32// NewAssessedMachinesClient creates an instance of the AssessedMachinesClient client. 33func NewAssessedMachinesClient(subscriptionID string, acceptLanguage string) AssessedMachinesClient { 34 return NewAssessedMachinesClientWithBaseURI(DefaultBaseURI, subscriptionID, acceptLanguage) 35} 36 37// NewAssessedMachinesClientWithBaseURI creates an instance of the AssessedMachinesClient client. 38func NewAssessedMachinesClientWithBaseURI(baseURI string, subscriptionID string, acceptLanguage string) AssessedMachinesClient { 39 return AssessedMachinesClient{NewWithBaseURI(baseURI, subscriptionID, acceptLanguage)} 40} 41 42// Get get an assessed machine with its size & cost estimnate that was evaluated in the specified assessment. 43// Parameters: 44// resourceGroupName - name of the Azure Resource Group that project is part of. 45// projectName - name of the Azure Migrate project. 46// groupName - unique name of a group within a project. 47// assessmentName - unique name of an assessment within a project. 48// assessedMachineName - unique name of an assessed machine evaluated as part of an assessment. 49func (client AssessedMachinesClient) Get(ctx context.Context, resourceGroupName string, projectName string, groupName string, assessmentName string, assessedMachineName string) (result AssessedMachine, err error) { 50 req, err := client.GetPreparer(ctx, resourceGroupName, projectName, groupName, assessmentName, assessedMachineName) 51 if err != nil { 52 err = autorest.NewErrorWithError(err, "migrate.AssessedMachinesClient", "Get", nil, "Failure preparing request") 53 return 54 } 55 56 resp, err := client.GetSender(req) 57 if err != nil { 58 result.Response = autorest.Response{Response: resp} 59 err = autorest.NewErrorWithError(err, "migrate.AssessedMachinesClient", "Get", resp, "Failure sending request") 60 return 61 } 62 63 result, err = client.GetResponder(resp) 64 if err != nil { 65 err = autorest.NewErrorWithError(err, "migrate.AssessedMachinesClient", "Get", resp, "Failure responding to request") 66 } 67 68 return 69} 70 71// GetPreparer prepares the Get request. 72func (client AssessedMachinesClient) GetPreparer(ctx context.Context, resourceGroupName string, projectName string, groupName string, assessmentName string, assessedMachineName string) (*http.Request, error) { 73 pathParameters := map[string]interface{}{ 74 "assessedMachineName": autorest.Encode("path", assessedMachineName), 75 "assessmentName": autorest.Encode("path", assessmentName), 76 "groupName": autorest.Encode("path", groupName), 77 "projectName": autorest.Encode("path", projectName), 78 "resourceGroupName": autorest.Encode("path", resourceGroupName), 79 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 80 } 81 82 const APIVersion = "2018-02-02" 83 queryParameters := map[string]interface{}{ 84 "api-version": APIVersion, 85 } 86 87 preparer := autorest.CreatePreparer( 88 autorest.AsGet(), 89 autorest.WithBaseURL(client.BaseURI), 90 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/projects/{projectName}/groups/{groupName}/assessments/{assessmentName}/assessedMachines/{assessedMachineName}", pathParameters), 91 autorest.WithQueryParameters(queryParameters)) 92 if len(client.AcceptLanguage) > 0 { 93 preparer = autorest.DecoratePreparer(preparer, 94 autorest.WithHeader("Accept-Language", autorest.String(client.AcceptLanguage))) 95 } 96 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 97} 98 99// GetSender sends the Get request. The method will close the 100// http.Response Body if it receives an error. 101func (client AssessedMachinesClient) GetSender(req *http.Request) (*http.Response, error) { 102 return autorest.SendWithSender(client, req, 103 azure.DoRetryWithRegistration(client.Client)) 104} 105 106// GetResponder handles the response to the Get request. The method always 107// closes the http.Response Body. 108func (client AssessedMachinesClient) GetResponder(resp *http.Response) (result AssessedMachine, err error) { 109 err = autorest.Respond( 110 resp, 111 client.ByInspecting(), 112 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusUnauthorized, http.StatusNotFound, http.StatusInternalServerError, http.StatusServiceUnavailable), 113 autorest.ByUnmarshallingJSON(&result), 114 autorest.ByClosing()) 115 result.Response = autorest.Response{Response: resp} 116 return 117} 118 119// ListByAssessment get list of machines that assessed as part of the specified assessment. Returns a json array of 120// objects of type 'assessedMachine' as specified in the Models section. 121// 122// Whenever an assessment is created or updated, it goes under computation. During this phase, the 'status' field of 123// Assessment object reports 'Computing'. 124// During the period when the assessment is under computation, the list of assessed machines is empty and no assessed 125// machines are returned by this call. 126// Parameters: 127// resourceGroupName - name of the Azure Resource Group that project is part of. 128// projectName - name of the Azure Migrate project. 129// groupName - unique name of a group within a project. 130// assessmentName - unique name of an assessment within a project. 131func (client AssessedMachinesClient) ListByAssessment(ctx context.Context, resourceGroupName string, projectName string, groupName string, assessmentName string) (result AssessedMachineResultList, err error) { 132 req, err := client.ListByAssessmentPreparer(ctx, resourceGroupName, projectName, groupName, assessmentName) 133 if err != nil { 134 err = autorest.NewErrorWithError(err, "migrate.AssessedMachinesClient", "ListByAssessment", nil, "Failure preparing request") 135 return 136 } 137 138 resp, err := client.ListByAssessmentSender(req) 139 if err != nil { 140 result.Response = autorest.Response{Response: resp} 141 err = autorest.NewErrorWithError(err, "migrate.AssessedMachinesClient", "ListByAssessment", resp, "Failure sending request") 142 return 143 } 144 145 result, err = client.ListByAssessmentResponder(resp) 146 if err != nil { 147 err = autorest.NewErrorWithError(err, "migrate.AssessedMachinesClient", "ListByAssessment", resp, "Failure responding to request") 148 } 149 150 return 151} 152 153// ListByAssessmentPreparer prepares the ListByAssessment request. 154func (client AssessedMachinesClient) ListByAssessmentPreparer(ctx context.Context, resourceGroupName string, projectName string, groupName string, assessmentName string) (*http.Request, error) { 155 pathParameters := map[string]interface{}{ 156 "assessmentName": autorest.Encode("path", assessmentName), 157 "groupName": autorest.Encode("path", groupName), 158 "projectName": autorest.Encode("path", projectName), 159 "resourceGroupName": autorest.Encode("path", resourceGroupName), 160 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 161 } 162 163 const APIVersion = "2018-02-02" 164 queryParameters := map[string]interface{}{ 165 "api-version": APIVersion, 166 } 167 168 preparer := autorest.CreatePreparer( 169 autorest.AsGet(), 170 autorest.WithBaseURL(client.BaseURI), 171 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/projects/{projectName}/groups/{groupName}/assessments/{assessmentName}/assessedMachines", pathParameters), 172 autorest.WithQueryParameters(queryParameters)) 173 if len(client.AcceptLanguage) > 0 { 174 preparer = autorest.DecoratePreparer(preparer, 175 autorest.WithHeader("Accept-Language", autorest.String(client.AcceptLanguage))) 176 } 177 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 178} 179 180// ListByAssessmentSender sends the ListByAssessment request. The method will close the 181// http.Response Body if it receives an error. 182func (client AssessedMachinesClient) ListByAssessmentSender(req *http.Request) (*http.Response, error) { 183 return autorest.SendWithSender(client, req, 184 azure.DoRetryWithRegistration(client.Client)) 185} 186 187// ListByAssessmentResponder handles the response to the ListByAssessment request. The method always 188// closes the http.Response Body. 189func (client AssessedMachinesClient) ListByAssessmentResponder(resp *http.Response) (result AssessedMachineResultList, err error) { 190 err = autorest.Respond( 191 resp, 192 client.ByInspecting(), 193 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusUnauthorized, http.StatusNotFound, http.StatusInternalServerError, http.StatusServiceUnavailable), 194 autorest.ByUnmarshallingJSON(&result), 195 autorest.ByClosing()) 196 result.Response = autorest.Response{Response: resp} 197 return 198} 199