...

Source file src/github.com/Azure/azure-sdk-for-go/services/preview/automation/mgmt/2021-06-22-preview/automation/dsccompilationjobstream.go

Documentation: github.com/Azure/azure-sdk-for-go/services/preview/automation/mgmt/2021-06-22-preview/automation

     1  package automation
     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  
     9  import (
    10  	"context"
    11  	"github.com/Azure/go-autorest/autorest"
    12  	"github.com/Azure/go-autorest/autorest/azure"
    13  	"github.com/Azure/go-autorest/autorest/validation"
    14  	"github.com/Azure/go-autorest/tracing"
    15  	"github.com/gofrs/uuid"
    16  	"net/http"
    17  )
    18  
    19  // DscCompilationJobStreamClient is the automation Client
    20  type DscCompilationJobStreamClient struct {
    21  	BaseClient
    22  }
    23  
    24  // NewDscCompilationJobStreamClient creates an instance of the DscCompilationJobStreamClient client.
    25  func NewDscCompilationJobStreamClient(subscriptionID string) DscCompilationJobStreamClient {
    26  	return NewDscCompilationJobStreamClientWithBaseURI(DefaultBaseURI, subscriptionID)
    27  }
    28  
    29  // NewDscCompilationJobStreamClientWithBaseURI creates an instance of the DscCompilationJobStreamClient client using a
    30  // custom endpoint.  Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds,
    31  // Azure stack).
    32  func NewDscCompilationJobStreamClientWithBaseURI(baseURI string, subscriptionID string) DscCompilationJobStreamClient {
    33  	return DscCompilationJobStreamClient{NewWithBaseURI(baseURI, subscriptionID)}
    34  }
    35  
    36  // ListByJob retrieve all the job streams for the compilation Job.
    37  // Parameters:
    38  // resourceGroupName - name of an Azure Resource group.
    39  // automationAccountName - the name of the automation account.
    40  // jobID - the job id.
    41  func (client DscCompilationJobStreamClient) ListByJob(ctx context.Context, resourceGroupName string, automationAccountName string, jobID uuid.UUID) (result JobStreamListResult, err error) {
    42  	if tracing.IsEnabled() {
    43  		ctx = tracing.StartSpan(ctx, fqdn+"/DscCompilationJobStreamClient.ListByJob")
    44  		defer func() {
    45  			sc := -1
    46  			if result.Response.Response != nil {
    47  				sc = result.Response.Response.StatusCode
    48  			}
    49  			tracing.EndSpan(ctx, sc, err)
    50  		}()
    51  	}
    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.DscCompilationJobStreamClient", "ListByJob", err.Error())
    58  	}
    59  
    60  	req, err := client.ListByJobPreparer(ctx, resourceGroupName, automationAccountName, jobID)
    61  	if err != nil {
    62  		err = autorest.NewErrorWithError(err, "automation.DscCompilationJobStreamClient", "ListByJob", nil, "Failure preparing request")
    63  		return
    64  	}
    65  
    66  	resp, err := client.ListByJobSender(req)
    67  	if err != nil {
    68  		result.Response = autorest.Response{Response: resp}
    69  		err = autorest.NewErrorWithError(err, "automation.DscCompilationJobStreamClient", "ListByJob", resp, "Failure sending request")
    70  		return
    71  	}
    72  
    73  	result, err = client.ListByJobResponder(resp)
    74  	if err != nil {
    75  		err = autorest.NewErrorWithError(err, "automation.DscCompilationJobStreamClient", "ListByJob", resp, "Failure responding to request")
    76  		return
    77  	}
    78  
    79  	return
    80  }
    81  
    82  // ListByJobPreparer prepares the ListByJob request.
    83  func (client DscCompilationJobStreamClient) ListByJobPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, jobID uuid.UUID) (*http.Request, error) {
    84  	pathParameters := map[string]interface{}{
    85  		"automationAccountName": autorest.Encode("path", automationAccountName),
    86  		"jobId":                 autorest.Encode("path", jobID),
    87  		"resourceGroupName":     autorest.Encode("path", resourceGroupName),
    88  		"subscriptionId":        autorest.Encode("path", client.SubscriptionID),
    89  	}
    90  
    91  	const APIVersion = "2020-01-13-preview"
    92  	queryParameters := map[string]interface{}{
    93  		"api-version": APIVersion,
    94  	}
    95  
    96  	preparer := autorest.CreatePreparer(
    97  		autorest.AsGet(),
    98  		autorest.WithBaseURL(client.BaseURI),
    99  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{jobId}/streams", pathParameters),
   100  		autorest.WithQueryParameters(queryParameters))
   101  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   102  }
   103  
   104  // ListByJobSender sends the ListByJob request. The method will close the
   105  // http.Response Body if it receives an error.
   106  func (client DscCompilationJobStreamClient) ListByJobSender(req *http.Request) (*http.Response, error) {
   107  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   108  }
   109  
   110  // ListByJobResponder handles the response to the ListByJob request. The method always
   111  // closes the http.Response Body.
   112  func (client DscCompilationJobStreamClient) ListByJobResponder(resp *http.Response) (result JobStreamListResult, err error) {
   113  	err = autorest.Respond(
   114  		resp,
   115  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   116  		autorest.ByUnmarshallingJSON(&result),
   117  		autorest.ByClosing())
   118  	result.Response = autorest.Response{Response: resp}
   119  	return
   120  }
   121  

View as plain text