...

Source file src/github.com/Azure/azure-sdk-for-go/services/preview/synapse/2019-06-01-preview/artifacts/integrationruntimes.go

Documentation: github.com/Azure/azure-sdk-for-go/services/preview/synapse/2019-06-01-preview/artifacts

     1  package artifacts
     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/tracing"
    14  	"net/http"
    15  )
    16  
    17  // IntegrationRuntimesClient is the client for the IntegrationRuntimes methods of the Artifacts service.
    18  type IntegrationRuntimesClient struct {
    19  	BaseClient
    20  }
    21  
    22  // NewIntegrationRuntimesClient creates an instance of the IntegrationRuntimesClient client.
    23  func NewIntegrationRuntimesClient(endpoint string) IntegrationRuntimesClient {
    24  	return IntegrationRuntimesClient{New(endpoint)}
    25  }
    26  
    27  // Get get Integration Runtime
    28  // Parameters:
    29  // integrationRuntimeName - the Integration Runtime name
    30  func (client IntegrationRuntimesClient) Get(ctx context.Context, integrationRuntimeName string) (result IntegrationRuntimeResource, err error) {
    31  	if tracing.IsEnabled() {
    32  		ctx = tracing.StartSpan(ctx, fqdn+"/IntegrationRuntimesClient.Get")
    33  		defer func() {
    34  			sc := -1
    35  			if result.Response.Response != nil {
    36  				sc = result.Response.Response.StatusCode
    37  			}
    38  			tracing.EndSpan(ctx, sc, err)
    39  		}()
    40  	}
    41  	req, err := client.GetPreparer(ctx, integrationRuntimeName)
    42  	if err != nil {
    43  		err = autorest.NewErrorWithError(err, "artifacts.IntegrationRuntimesClient", "Get", nil, "Failure preparing request")
    44  		return
    45  	}
    46  
    47  	resp, err := client.GetSender(req)
    48  	if err != nil {
    49  		result.Response = autorest.Response{Response: resp}
    50  		err = autorest.NewErrorWithError(err, "artifacts.IntegrationRuntimesClient", "Get", resp, "Failure sending request")
    51  		return
    52  	}
    53  
    54  	result, err = client.GetResponder(resp)
    55  	if err != nil {
    56  		err = autorest.NewErrorWithError(err, "artifacts.IntegrationRuntimesClient", "Get", resp, "Failure responding to request")
    57  		return
    58  	}
    59  
    60  	return
    61  }
    62  
    63  // GetPreparer prepares the Get request.
    64  func (client IntegrationRuntimesClient) GetPreparer(ctx context.Context, integrationRuntimeName string) (*http.Request, error) {
    65  	urlParameters := map[string]interface{}{
    66  		"endpoint": client.Endpoint,
    67  	}
    68  
    69  	pathParameters := map[string]interface{}{
    70  		"integrationRuntimeName": autorest.Encode("path", integrationRuntimeName),
    71  	}
    72  
    73  	const APIVersion = "2019-06-01-preview"
    74  	queryParameters := map[string]interface{}{
    75  		"api-version": APIVersion,
    76  	}
    77  
    78  	preparer := autorest.CreatePreparer(
    79  		autorest.AsGet(),
    80  		autorest.WithCustomBaseURL("{endpoint}", urlParameters),
    81  		autorest.WithPathParameters("/integrationRuntimes/{integrationRuntimeName}", pathParameters),
    82  		autorest.WithQueryParameters(queryParameters))
    83  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
    84  }
    85  
    86  // GetSender sends the Get request. The method will close the
    87  // http.Response Body if it receives an error.
    88  func (client IntegrationRuntimesClient) GetSender(req *http.Request) (*http.Response, error) {
    89  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
    90  }
    91  
    92  // GetResponder handles the response to the Get request. The method always
    93  // closes the http.Response Body.
    94  func (client IntegrationRuntimesClient) GetResponder(resp *http.Response) (result IntegrationRuntimeResource, err error) {
    95  	err = autorest.Respond(
    96  		resp,
    97  		azure.WithErrorUnlessStatusCode(http.StatusOK),
    98  		autorest.ByUnmarshallingJSON(&result),
    99  		autorest.ByClosing())
   100  	result.Response = autorest.Response{Response: resp}
   101  	return
   102  }
   103  
   104  // List list Integration Runtimes
   105  func (client IntegrationRuntimesClient) List(ctx context.Context) (result IntegrationRuntimeListResponse, err error) {
   106  	if tracing.IsEnabled() {
   107  		ctx = tracing.StartSpan(ctx, fqdn+"/IntegrationRuntimesClient.List")
   108  		defer func() {
   109  			sc := -1
   110  			if result.Response.Response != nil {
   111  				sc = result.Response.Response.StatusCode
   112  			}
   113  			tracing.EndSpan(ctx, sc, err)
   114  		}()
   115  	}
   116  	req, err := client.ListPreparer(ctx)
   117  	if err != nil {
   118  		err = autorest.NewErrorWithError(err, "artifacts.IntegrationRuntimesClient", "List", nil, "Failure preparing request")
   119  		return
   120  	}
   121  
   122  	resp, err := client.ListSender(req)
   123  	if err != nil {
   124  		result.Response = autorest.Response{Response: resp}
   125  		err = autorest.NewErrorWithError(err, "artifacts.IntegrationRuntimesClient", "List", resp, "Failure sending request")
   126  		return
   127  	}
   128  
   129  	result, err = client.ListResponder(resp)
   130  	if err != nil {
   131  		err = autorest.NewErrorWithError(err, "artifacts.IntegrationRuntimesClient", "List", resp, "Failure responding to request")
   132  		return
   133  	}
   134  
   135  	return
   136  }
   137  
   138  // ListPreparer prepares the List request.
   139  func (client IntegrationRuntimesClient) ListPreparer(ctx context.Context) (*http.Request, error) {
   140  	urlParameters := map[string]interface{}{
   141  		"endpoint": client.Endpoint,
   142  	}
   143  
   144  	const APIVersion = "2019-06-01-preview"
   145  	queryParameters := map[string]interface{}{
   146  		"api-version": APIVersion,
   147  	}
   148  
   149  	preparer := autorest.CreatePreparer(
   150  		autorest.AsGet(),
   151  		autorest.WithCustomBaseURL("{endpoint}", urlParameters),
   152  		autorest.WithPath("/integrationRuntimes"),
   153  		autorest.WithQueryParameters(queryParameters))
   154  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   155  }
   156  
   157  // ListSender sends the List request. The method will close the
   158  // http.Response Body if it receives an error.
   159  func (client IntegrationRuntimesClient) ListSender(req *http.Request) (*http.Response, error) {
   160  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   161  }
   162  
   163  // ListResponder handles the response to the List request. The method always
   164  // closes the http.Response Body.
   165  func (client IntegrationRuntimesClient) ListResponder(resp *http.Response) (result IntegrationRuntimeListResponse, err error) {
   166  	err = autorest.Respond(
   167  		resp,
   168  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   169  		autorest.ByUnmarshallingJSON(&result),
   170  		autorest.ByClosing())
   171  	result.Response = autorest.Response{Response: resp}
   172  	return
   173  }
   174  

View as plain text