1package synapse
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/Azure/go-autorest/tracing"
26	"net/http"
27)
28
29// IntegrationRuntimeStatusClient is the azure Synapse Analytics Management Client
30type IntegrationRuntimeStatusClient struct {
31	BaseClient
32}
33
34// NewIntegrationRuntimeStatusClient creates an instance of the IntegrationRuntimeStatusClient client.
35func NewIntegrationRuntimeStatusClient(subscriptionID string) IntegrationRuntimeStatusClient {
36	return NewIntegrationRuntimeStatusClientWithBaseURI(DefaultBaseURI, subscriptionID)
37}
38
39// NewIntegrationRuntimeStatusClientWithBaseURI creates an instance of the IntegrationRuntimeStatusClient client using
40// a custom endpoint.  Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign
41// clouds, Azure stack).
42func NewIntegrationRuntimeStatusClientWithBaseURI(baseURI string, subscriptionID string) IntegrationRuntimeStatusClient {
43	return IntegrationRuntimeStatusClient{NewWithBaseURI(baseURI, subscriptionID)}
44}
45
46// Get get the integration runtime status
47// Parameters:
48// resourceGroupName - the name of the resource group. The name is case insensitive.
49// workspaceName - the name of the workspace.
50// integrationRuntimeName - integration runtime name
51func (client IntegrationRuntimeStatusClient) Get(ctx context.Context, resourceGroupName string, workspaceName string, integrationRuntimeName string) (result IntegrationRuntimeStatusResponse, err error) {
52	if tracing.IsEnabled() {
53		ctx = tracing.StartSpan(ctx, fqdn+"/IntegrationRuntimeStatusClient.Get")
54		defer func() {
55			sc := -1
56			if result.Response.Response != nil {
57				sc = result.Response.Response.StatusCode
58			}
59			tracing.EndSpan(ctx, sc, err)
60		}()
61	}
62	if err := validation.Validate([]validation.Validation{
63		{TargetValue: client.SubscriptionID,
64			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
65		{TargetValue: resourceGroupName,
66			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
67				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
68				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
69		return result, validation.NewError("synapse.IntegrationRuntimeStatusClient", "Get", err.Error())
70	}
71
72	req, err := client.GetPreparer(ctx, resourceGroupName, workspaceName, integrationRuntimeName)
73	if err != nil {
74		err = autorest.NewErrorWithError(err, "synapse.IntegrationRuntimeStatusClient", "Get", nil, "Failure preparing request")
75		return
76	}
77
78	resp, err := client.GetSender(req)
79	if err != nil {
80		result.Response = autorest.Response{Response: resp}
81		err = autorest.NewErrorWithError(err, "synapse.IntegrationRuntimeStatusClient", "Get", resp, "Failure sending request")
82		return
83	}
84
85	result, err = client.GetResponder(resp)
86	if err != nil {
87		err = autorest.NewErrorWithError(err, "synapse.IntegrationRuntimeStatusClient", "Get", resp, "Failure responding to request")
88		return
89	}
90
91	return
92}
93
94// GetPreparer prepares the Get request.
95func (client IntegrationRuntimeStatusClient) GetPreparer(ctx context.Context, resourceGroupName string, workspaceName string, integrationRuntimeName string) (*http.Request, error) {
96	pathParameters := map[string]interface{}{
97		"integrationRuntimeName": autorest.Encode("path", integrationRuntimeName),
98		"resourceGroupName":      autorest.Encode("path", resourceGroupName),
99		"subscriptionId":         autorest.Encode("path", client.SubscriptionID),
100		"workspaceName":          autorest.Encode("path", workspaceName),
101	}
102
103	const APIVersion = "2020-12-01"
104	queryParameters := map[string]interface{}{
105		"api-version": APIVersion,
106	}
107
108	preparer := autorest.CreatePreparer(
109		autorest.AsPost(),
110		autorest.WithBaseURL(client.BaseURI),
111		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/getStatus", pathParameters),
112		autorest.WithQueryParameters(queryParameters))
113	return preparer.Prepare((&http.Request{}).WithContext(ctx))
114}
115
116// GetSender sends the Get request. The method will close the
117// http.Response Body if it receives an error.
118func (client IntegrationRuntimeStatusClient) GetSender(req *http.Request) (*http.Response, error) {
119	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
120}
121
122// GetResponder handles the response to the Get request. The method always
123// closes the http.Response Body.
124func (client IntegrationRuntimeStatusClient) GetResponder(resp *http.Response) (result IntegrationRuntimeStatusResponse, err error) {
125	err = autorest.Respond(
126		resp,
127		azure.WithErrorUnlessStatusCode(http.StatusOK),
128		autorest.ByUnmarshallingJSON(&result),
129		autorest.ByClosing())
130	result.Response = autorest.Response{Response: resp}
131	return
132}
133