1package sql 2 3// Copyright (c) Microsoft Corporation. All rights reserved. 4// Licensed under the MIT License. See License.txt in the project root for license information. 5// 6// Code generated by Microsoft (R) AutoRest Code Generator. 7// Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 9import ( 10 "context" 11 "github.com/Azure/go-autorest/autorest" 12 "github.com/Azure/go-autorest/autorest/azure" 13 "github.com/Azure/go-autorest/autorest/date" 14 "github.com/Azure/go-autorest/tracing" 15 "github.com/gofrs/uuid" 16 "net/http" 17) 18 19// JobStepExecutionsClient is the the Azure SQL Database management API provides a RESTful set of web services that 20// interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, 21// and delete databases. 22type JobStepExecutionsClient struct { 23 BaseClient 24} 25 26// NewJobStepExecutionsClient creates an instance of the JobStepExecutionsClient client. 27func NewJobStepExecutionsClient(subscriptionID string) JobStepExecutionsClient { 28 return NewJobStepExecutionsClientWithBaseURI(DefaultBaseURI, subscriptionID) 29} 30 31// NewJobStepExecutionsClientWithBaseURI creates an instance of the JobStepExecutionsClient client using a custom 32// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure 33// stack). 34func NewJobStepExecutionsClientWithBaseURI(baseURI string, subscriptionID string) JobStepExecutionsClient { 35 return JobStepExecutionsClient{NewWithBaseURI(baseURI, subscriptionID)} 36} 37 38// Get gets a step execution of a job execution. 39// Parameters: 40// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value 41// from the Azure Resource Manager API or the portal. 42// serverName - the name of the server. 43// jobAgentName - the name of the job agent. 44// jobName - the name of the job to get. 45// jobExecutionID - the unique id of the job execution 46// stepName - the name of the step. 47func (client JobStepExecutionsClient) Get(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID, stepName string) (result JobExecution, err error) { 48 if tracing.IsEnabled() { 49 ctx = tracing.StartSpan(ctx, fqdn+"/JobStepExecutionsClient.Get") 50 defer func() { 51 sc := -1 52 if result.Response.Response != nil { 53 sc = result.Response.Response.StatusCode 54 } 55 tracing.EndSpan(ctx, sc, err) 56 }() 57 } 58 req, err := client.GetPreparer(ctx, resourceGroupName, serverName, jobAgentName, jobName, jobExecutionID, stepName) 59 if err != nil { 60 err = autorest.NewErrorWithError(err, "sql.JobStepExecutionsClient", "Get", nil, "Failure preparing request") 61 return 62 } 63 64 resp, err := client.GetSender(req) 65 if err != nil { 66 result.Response = autorest.Response{Response: resp} 67 err = autorest.NewErrorWithError(err, "sql.JobStepExecutionsClient", "Get", resp, "Failure sending request") 68 return 69 } 70 71 result, err = client.GetResponder(resp) 72 if err != nil { 73 err = autorest.NewErrorWithError(err, "sql.JobStepExecutionsClient", "Get", resp, "Failure responding to request") 74 return 75 } 76 77 return 78} 79 80// GetPreparer prepares the Get request. 81func (client JobStepExecutionsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID, stepName string) (*http.Request, error) { 82 pathParameters := map[string]interface{}{ 83 "jobAgentName": autorest.Encode("path", jobAgentName), 84 "jobExecutionId": autorest.Encode("path", jobExecutionID), 85 "jobName": autorest.Encode("path", jobName), 86 "resourceGroupName": autorest.Encode("path", resourceGroupName), 87 "serverName": autorest.Encode("path", serverName), 88 "stepName": autorest.Encode("path", stepName), 89 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 90 } 91 92 const APIVersion = "2017-03-01-preview" 93 queryParameters := map[string]interface{}{ 94 "api-version": APIVersion, 95 } 96 97 preparer := autorest.CreatePreparer( 98 autorest.AsGet(), 99 autorest.WithBaseURL(client.BaseURI), 100 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}/steps/{stepName}", pathParameters), 101 autorest.WithQueryParameters(queryParameters)) 102 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 103} 104 105// GetSender sends the Get request. The method will close the 106// http.Response Body if it receives an error. 107func (client JobStepExecutionsClient) GetSender(req *http.Request) (*http.Response, error) { 108 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 109} 110 111// GetResponder handles the response to the Get request. The method always 112// closes the http.Response Body. 113func (client JobStepExecutionsClient) GetResponder(resp *http.Response) (result JobExecution, err error) { 114 err = autorest.Respond( 115 resp, 116 azure.WithErrorUnlessStatusCode(http.StatusOK), 117 autorest.ByUnmarshallingJSON(&result), 118 autorest.ByClosing()) 119 result.Response = autorest.Response{Response: resp} 120 return 121} 122 123// ListByJobExecution lists the step executions of a job execution. 124// Parameters: 125// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value 126// from the Azure Resource Manager API or the portal. 127// serverName - the name of the server. 128// jobAgentName - the name of the job agent. 129// jobName - the name of the job to get. 130// jobExecutionID - the id of the job execution 131// createTimeMin - if specified, only job executions created at or after the specified time are included. 132// createTimeMax - if specified, only job executions created before the specified time are included. 133// endTimeMin - if specified, only job executions completed at or after the specified time are included. 134// endTimeMax - if specified, only job executions completed before the specified time are included. 135// isActive - if specified, only active or only completed job executions are included. 136// skip - the number of elements in the collection to skip. 137// top - the number of elements to return from the collection. 138func (client JobStepExecutionsClient) ListByJobExecution(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID, createTimeMin *date.Time, createTimeMax *date.Time, endTimeMin *date.Time, endTimeMax *date.Time, isActive *bool, skip *int32, top *int32) (result JobExecutionListResultPage, err error) { 139 if tracing.IsEnabled() { 140 ctx = tracing.StartSpan(ctx, fqdn+"/JobStepExecutionsClient.ListByJobExecution") 141 defer func() { 142 sc := -1 143 if result.jelr.Response.Response != nil { 144 sc = result.jelr.Response.Response.StatusCode 145 } 146 tracing.EndSpan(ctx, sc, err) 147 }() 148 } 149 result.fn = client.listByJobExecutionNextResults 150 req, err := client.ListByJobExecutionPreparer(ctx, resourceGroupName, serverName, jobAgentName, jobName, jobExecutionID, createTimeMin, createTimeMax, endTimeMin, endTimeMax, isActive, skip, top) 151 if err != nil { 152 err = autorest.NewErrorWithError(err, "sql.JobStepExecutionsClient", "ListByJobExecution", nil, "Failure preparing request") 153 return 154 } 155 156 resp, err := client.ListByJobExecutionSender(req) 157 if err != nil { 158 result.jelr.Response = autorest.Response{Response: resp} 159 err = autorest.NewErrorWithError(err, "sql.JobStepExecutionsClient", "ListByJobExecution", resp, "Failure sending request") 160 return 161 } 162 163 result.jelr, err = client.ListByJobExecutionResponder(resp) 164 if err != nil { 165 err = autorest.NewErrorWithError(err, "sql.JobStepExecutionsClient", "ListByJobExecution", resp, "Failure responding to request") 166 return 167 } 168 if result.jelr.hasNextLink() && result.jelr.IsEmpty() { 169 err = result.NextWithContext(ctx) 170 return 171 } 172 173 return 174} 175 176// ListByJobExecutionPreparer prepares the ListByJobExecution request. 177func (client JobStepExecutionsClient) ListByJobExecutionPreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID, createTimeMin *date.Time, createTimeMax *date.Time, endTimeMin *date.Time, endTimeMax *date.Time, isActive *bool, skip *int32, top *int32) (*http.Request, error) { 178 pathParameters := map[string]interface{}{ 179 "jobAgentName": autorest.Encode("path", jobAgentName), 180 "jobExecutionId": autorest.Encode("path", jobExecutionID), 181 "jobName": autorest.Encode("path", jobName), 182 "resourceGroupName": autorest.Encode("path", resourceGroupName), 183 "serverName": autorest.Encode("path", serverName), 184 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 185 } 186 187 const APIVersion = "2017-03-01-preview" 188 queryParameters := map[string]interface{}{ 189 "api-version": APIVersion, 190 } 191 if createTimeMin != nil { 192 queryParameters["createTimeMin"] = autorest.Encode("query", *createTimeMin) 193 } 194 if createTimeMax != nil { 195 queryParameters["createTimeMax"] = autorest.Encode("query", *createTimeMax) 196 } 197 if endTimeMin != nil { 198 queryParameters["endTimeMin"] = autorest.Encode("query", *endTimeMin) 199 } 200 if endTimeMax != nil { 201 queryParameters["endTimeMax"] = autorest.Encode("query", *endTimeMax) 202 } 203 if isActive != nil { 204 queryParameters["isActive"] = autorest.Encode("query", *isActive) 205 } 206 if skip != nil { 207 queryParameters["$skip"] = autorest.Encode("query", *skip) 208 } 209 if top != nil { 210 queryParameters["$top"] = autorest.Encode("query", *top) 211 } 212 213 preparer := autorest.CreatePreparer( 214 autorest.AsGet(), 215 autorest.WithBaseURL(client.BaseURI), 216 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}/steps", pathParameters), 217 autorest.WithQueryParameters(queryParameters)) 218 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 219} 220 221// ListByJobExecutionSender sends the ListByJobExecution request. The method will close the 222// http.Response Body if it receives an error. 223func (client JobStepExecutionsClient) ListByJobExecutionSender(req *http.Request) (*http.Response, error) { 224 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 225} 226 227// ListByJobExecutionResponder handles the response to the ListByJobExecution request. The method always 228// closes the http.Response Body. 229func (client JobStepExecutionsClient) ListByJobExecutionResponder(resp *http.Response) (result JobExecutionListResult, err error) { 230 err = autorest.Respond( 231 resp, 232 azure.WithErrorUnlessStatusCode(http.StatusOK), 233 autorest.ByUnmarshallingJSON(&result), 234 autorest.ByClosing()) 235 result.Response = autorest.Response{Response: resp} 236 return 237} 238 239// listByJobExecutionNextResults retrieves the next set of results, if any. 240func (client JobStepExecutionsClient) listByJobExecutionNextResults(ctx context.Context, lastResults JobExecutionListResult) (result JobExecutionListResult, err error) { 241 req, err := lastResults.jobExecutionListResultPreparer(ctx) 242 if err != nil { 243 return result, autorest.NewErrorWithError(err, "sql.JobStepExecutionsClient", "listByJobExecutionNextResults", nil, "Failure preparing next results request") 244 } 245 if req == nil { 246 return 247 } 248 resp, err := client.ListByJobExecutionSender(req) 249 if err != nil { 250 result.Response = autorest.Response{Response: resp} 251 return result, autorest.NewErrorWithError(err, "sql.JobStepExecutionsClient", "listByJobExecutionNextResults", resp, "Failure sending next results request") 252 } 253 result, err = client.ListByJobExecutionResponder(resp) 254 if err != nil { 255 err = autorest.NewErrorWithError(err, "sql.JobStepExecutionsClient", "listByJobExecutionNextResults", resp, "Failure responding to next results request") 256 } 257 return 258} 259 260// ListByJobExecutionComplete enumerates all values, automatically crossing page boundaries as required. 261func (client JobStepExecutionsClient) ListByJobExecutionComplete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID, createTimeMin *date.Time, createTimeMax *date.Time, endTimeMin *date.Time, endTimeMax *date.Time, isActive *bool, skip *int32, top *int32) (result JobExecutionListResultIterator, err error) { 262 if tracing.IsEnabled() { 263 ctx = tracing.StartSpan(ctx, fqdn+"/JobStepExecutionsClient.ListByJobExecution") 264 defer func() { 265 sc := -1 266 if result.Response().Response.Response != nil { 267 sc = result.page.Response().Response.Response.StatusCode 268 } 269 tracing.EndSpan(ctx, sc, err) 270 }() 271 } 272 result.page, err = client.ListByJobExecution(ctx, resourceGroupName, serverName, jobAgentName, jobName, jobExecutionID, createTimeMin, createTimeMax, endTimeMin, endTimeMax, isActive, skip, top) 273 return 274} 275