1package automation 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 "github.com/Azure/go-autorest/autorest/validation" 25 "github.com/satori/go.uuid" 26 "net/http" 27) 28 29// SoftwareUpdateConfigurationRunsClient is the automation Client 30type SoftwareUpdateConfigurationRunsClient struct { 31 BaseClient 32} 33 34// NewSoftwareUpdateConfigurationRunsClient creates an instance of the SoftwareUpdateConfigurationRunsClient client. 35func NewSoftwareUpdateConfigurationRunsClient(subscriptionID string) SoftwareUpdateConfigurationRunsClient { 36 return NewSoftwareUpdateConfigurationRunsClientWithBaseURI(DefaultBaseURI, subscriptionID) 37} 38 39// NewSoftwareUpdateConfigurationRunsClientWithBaseURI creates an instance of the SoftwareUpdateConfigurationRunsClient 40// client. 41func NewSoftwareUpdateConfigurationRunsClientWithBaseURI(baseURI string, subscriptionID string) SoftwareUpdateConfigurationRunsClient { 42 return SoftwareUpdateConfigurationRunsClient{NewWithBaseURI(baseURI, subscriptionID)} 43} 44 45// GetByID get a single software update configuration Run by Id. 46// Parameters: 47// resourceGroupName - name of an Azure Resource group. 48// automationAccountName - the name of the automation account. 49// softwareUpdateConfigurationRunID - the Id of the software update configuration run. 50// clientRequestID - identifies this specific client request. 51func (client SoftwareUpdateConfigurationRunsClient) GetByID(ctx context.Context, resourceGroupName string, automationAccountName string, softwareUpdateConfigurationRunID uuid.UUID, clientRequestID string) (result SoftwareUpdateConfigurationRun, err error) { 52 if err := validation.Validate([]validation.Validation{ 53 {TargetValue: resourceGroupName, 54 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 55 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 56 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { 57 return result, validation.NewError("automation.SoftwareUpdateConfigurationRunsClient", "GetByID", err.Error()) 58 } 59 60 req, err := client.GetByIDPreparer(ctx, resourceGroupName, automationAccountName, softwareUpdateConfigurationRunID, clientRequestID) 61 if err != nil { 62 err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationRunsClient", "GetByID", nil, "Failure preparing request") 63 return 64 } 65 66 resp, err := client.GetByIDSender(req) 67 if err != nil { 68 result.Response = autorest.Response{Response: resp} 69 err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationRunsClient", "GetByID", resp, "Failure sending request") 70 return 71 } 72 73 result, err = client.GetByIDResponder(resp) 74 if err != nil { 75 err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationRunsClient", "GetByID", resp, "Failure responding to request") 76 } 77 78 return 79} 80 81// GetByIDPreparer prepares the GetByID request. 82func (client SoftwareUpdateConfigurationRunsClient) GetByIDPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, softwareUpdateConfigurationRunID uuid.UUID, clientRequestID string) (*http.Request, error) { 83 pathParameters := map[string]interface{}{ 84 "automationAccountName": autorest.Encode("path", automationAccountName), 85 "resourceGroupName": autorest.Encode("path", resourceGroupName), 86 "softwareUpdateConfigurationRunId": autorest.Encode("path", softwareUpdateConfigurationRunID), 87 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 88 } 89 90 const APIVersion = "2017-05-15-preview" 91 queryParameters := map[string]interface{}{ 92 "api-version": APIVersion, 93 } 94 95 preparer := autorest.CreatePreparer( 96 autorest.AsGet(), 97 autorest.WithBaseURL(client.BaseURI), 98 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationRuns/{softwareUpdateConfigurationRunId}", pathParameters), 99 autorest.WithQueryParameters(queryParameters)) 100 if len(clientRequestID) > 0 { 101 preparer = autorest.DecoratePreparer(preparer, 102 autorest.WithHeader("clientRequestId", autorest.String(clientRequestID))) 103 } 104 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 105} 106 107// GetByIDSender sends the GetByID request. The method will close the 108// http.Response Body if it receives an error. 109func (client SoftwareUpdateConfigurationRunsClient) GetByIDSender(req *http.Request) (*http.Response, error) { 110 return autorest.SendWithSender(client, req, 111 azure.DoRetryWithRegistration(client.Client)) 112} 113 114// GetByIDResponder handles the response to the GetByID request. The method always 115// closes the http.Response Body. 116func (client SoftwareUpdateConfigurationRunsClient) GetByIDResponder(resp *http.Response) (result SoftwareUpdateConfigurationRun, err error) { 117 err = autorest.Respond( 118 resp, 119 client.ByInspecting(), 120 azure.WithErrorUnlessStatusCode(http.StatusOK), 121 autorest.ByUnmarshallingJSON(&result), 122 autorest.ByClosing()) 123 result.Response = autorest.Response{Response: resp} 124 return 125} 126 127// List return list of software update configuration runs 128// Parameters: 129// resourceGroupName - name of an Azure Resource group. 130// automationAccountName - the name of the automation account. 131// clientRequestID - identifies this specific client request. 132// filter - the filter to apply on the operation. You can use the following filters: 'properties/osType', 133// 'properties/status', 'properties/startTime', and 'properties/softwareUpdateConfiguration/name' 134// skip - number of entries you skip before returning results 135// top - maximum number of entries returned in the results collection 136func (client SoftwareUpdateConfigurationRunsClient) List(ctx context.Context, resourceGroupName string, automationAccountName string, clientRequestID string, filter string, skip string, top string) (result SoftwareUpdateConfigurationRunListResult, err error) { 137 if err := validation.Validate([]validation.Validation{ 138 {TargetValue: resourceGroupName, 139 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 140 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 141 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { 142 return result, validation.NewError("automation.SoftwareUpdateConfigurationRunsClient", "List", err.Error()) 143 } 144 145 req, err := client.ListPreparer(ctx, resourceGroupName, automationAccountName, clientRequestID, filter, skip, top) 146 if err != nil { 147 err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationRunsClient", "List", nil, "Failure preparing request") 148 return 149 } 150 151 resp, err := client.ListSender(req) 152 if err != nil { 153 result.Response = autorest.Response{Response: resp} 154 err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationRunsClient", "List", resp, "Failure sending request") 155 return 156 } 157 158 result, err = client.ListResponder(resp) 159 if err != nil { 160 err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationRunsClient", "List", resp, "Failure responding to request") 161 } 162 163 return 164} 165 166// ListPreparer prepares the List request. 167func (client SoftwareUpdateConfigurationRunsClient) ListPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, clientRequestID string, filter string, skip string, top string) (*http.Request, error) { 168 pathParameters := map[string]interface{}{ 169 "automationAccountName": autorest.Encode("path", automationAccountName), 170 "resourceGroupName": autorest.Encode("path", resourceGroupName), 171 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 172 } 173 174 const APIVersion = "2017-05-15-preview" 175 queryParameters := map[string]interface{}{ 176 "api-version": APIVersion, 177 } 178 if len(filter) > 0 { 179 queryParameters["$filter"] = autorest.Encode("query", filter) 180 } 181 if len(skip) > 0 { 182 queryParameters["$skip"] = autorest.Encode("query", skip) 183 } 184 if len(top) > 0 { 185 queryParameters["$top"] = autorest.Encode("query", top) 186 } 187 188 preparer := autorest.CreatePreparer( 189 autorest.AsGet(), 190 autorest.WithBaseURL(client.BaseURI), 191 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationRuns", pathParameters), 192 autorest.WithQueryParameters(queryParameters)) 193 if len(clientRequestID) > 0 { 194 preparer = autorest.DecoratePreparer(preparer, 195 autorest.WithHeader("clientRequestId", autorest.String(clientRequestID))) 196 } 197 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 198} 199 200// ListSender sends the List request. The method will close the 201// http.Response Body if it receives an error. 202func (client SoftwareUpdateConfigurationRunsClient) ListSender(req *http.Request) (*http.Response, error) { 203 return autorest.SendWithSender(client, req, 204 azure.DoRetryWithRegistration(client.Client)) 205} 206 207// ListResponder handles the response to the List request. The method always 208// closes the http.Response Body. 209func (client SoftwareUpdateConfigurationRunsClient) ListResponder(resp *http.Response) (result SoftwareUpdateConfigurationRunListResult, err error) { 210 err = autorest.Respond( 211 resp, 212 client.ByInspecting(), 213 azure.WithErrorUnlessStatusCode(http.StatusOK), 214 autorest.ByUnmarshallingJSON(&result), 215 autorest.ByClosing()) 216 result.Response = autorest.Response{Response: resp} 217 return 218} 219