2017-08-05 18:30:20 +00:00
|
|
|
package hdinsight
|
|
|
|
|
|
|
|
// Copyright (c) Microsoft and contributors. All rights reserved.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
//
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
//
|
2017-10-01 08:13:39 +00:00
|
|
|
// Code generated by Microsoft (R) AutoRest Code Generator.
|
|
|
|
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
2017-08-05 18:30:20 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/Azure/go-autorest/autorest"
|
|
|
|
"github.com/Azure/go-autorest/autorest/azure"
|
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
|
2017-10-01 08:13:39 +00:00
|
|
|
// ApplicationsClient is the hDInsight Management Client
|
2017-08-05 18:30:20 +00:00
|
|
|
type ApplicationsClient struct {
|
|
|
|
ManagementClient
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewApplicationsClient creates an instance of the ApplicationsClient client.
|
|
|
|
func NewApplicationsClient(subscriptionID string) ApplicationsClient {
|
|
|
|
return NewApplicationsClientWithBaseURI(DefaultBaseURI, subscriptionID)
|
|
|
|
}
|
|
|
|
|
2017-10-01 08:13:39 +00:00
|
|
|
// NewApplicationsClientWithBaseURI creates an instance of the ApplicationsClient client.
|
2017-08-05 18:30:20 +00:00
|
|
|
func NewApplicationsClientWithBaseURI(baseURI string, subscriptionID string) ApplicationsClient {
|
|
|
|
return ApplicationsClient{NewWithBaseURI(baseURI, subscriptionID)}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create the operation creates applications for the HDInsight cluster.
|
|
|
|
//
|
2017-10-01 08:13:39 +00:00
|
|
|
// resourceGroupName is the name of the resource group. clusterName is the name of the cluster. applicationName is the
|
|
|
|
// constant value for the applicationName parameters is the application create request.
|
2017-08-05 18:30:20 +00:00
|
|
|
func (client ApplicationsClient) Create(resourceGroupName string, clusterName string, applicationName string, parameters ApplicationGetProperties) (result Application, err error) {
|
|
|
|
req, err := client.CreatePreparer(resourceGroupName, clusterName, applicationName, parameters)
|
|
|
|
if err != nil {
|
|
|
|
err = autorest.NewErrorWithError(err, "hdinsight.ApplicationsClient", "Create", nil, "Failure preparing request")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
resp, err := client.CreateSender(req)
|
|
|
|
if err != nil {
|
|
|
|
result.Response = autorest.Response{Response: resp}
|
|
|
|
err = autorest.NewErrorWithError(err, "hdinsight.ApplicationsClient", "Create", resp, "Failure sending request")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
result, err = client.CreateResponder(resp)
|
|
|
|
if err != nil {
|
|
|
|
err = autorest.NewErrorWithError(err, "hdinsight.ApplicationsClient", "Create", resp, "Failure responding to request")
|
|
|
|
}
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// CreatePreparer prepares the Create request.
|
|
|
|
func (client ApplicationsClient) CreatePreparer(resourceGroupName string, clusterName string, applicationName string, parameters ApplicationGetProperties) (*http.Request, error) {
|
|
|
|
pathParameters := map[string]interface{}{
|
|
|
|
"applicationName": autorest.Encode("path", applicationName),
|
|
|
|
"clusterName": autorest.Encode("path", clusterName),
|
|
|
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
|
|
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
|
|
|
}
|
|
|
|
|
|
|
|
const APIVersion = "2015-03-01-preview"
|
|
|
|
queryParameters := map[string]interface{}{
|
|
|
|
"api-version": APIVersion,
|
|
|
|
}
|
|
|
|
|
|
|
|
preparer := autorest.CreatePreparer(
|
|
|
|
autorest.AsJSON(),
|
|
|
|
autorest.AsPut(),
|
|
|
|
autorest.WithBaseURL(client.BaseURI),
|
|
|
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/applications/{applicationName}", pathParameters),
|
|
|
|
autorest.WithJSON(parameters),
|
|
|
|
autorest.WithQueryParameters(queryParameters))
|
|
|
|
return preparer.Prepare(&http.Request{})
|
|
|
|
}
|
|
|
|
|
|
|
|
// CreateSender sends the Create request. The method will close the
|
|
|
|
// http.Response Body if it receives an error.
|
|
|
|
func (client ApplicationsClient) CreateSender(req *http.Request) (*http.Response, error) {
|
2017-12-03 20:01:25 +00:00
|
|
|
return autorest.SendWithSender(client,
|
|
|
|
req,
|
|
|
|
azure.DoRetryWithRegistration(client.Client))
|
2017-08-05 18:30:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// CreateResponder handles the response to the Create request. The method always
|
|
|
|
// closes the http.Response Body.
|
|
|
|
func (client ApplicationsClient) CreateResponder(resp *http.Response) (result Application, err error) {
|
|
|
|
err = autorest.Respond(
|
|
|
|
resp,
|
|
|
|
client.ByInspecting(),
|
|
|
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
|
|
|
autorest.ByUnmarshallingJSON(&result),
|
|
|
|
autorest.ByClosing())
|
|
|
|
result.Response = autorest.Response{Response: resp}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-10-01 08:13:39 +00:00
|
|
|
// Delete lists all of the applications HDInsight cluster. This method may poll for completion. Polling can be canceled
|
|
|
|
// by passing the cancel channel argument. The channel will be used to cancel polling and any outstanding HTTP
|
|
|
|
// requests.
|
2017-08-05 18:30:20 +00:00
|
|
|
//
|
2017-10-01 08:13:39 +00:00
|
|
|
// resourceGroupName is the name of the resource group. clusterName is the name of the cluster. applicationName is the
|
|
|
|
// constant value for the applicationName.
|
2017-08-05 18:30:20 +00:00
|
|
|
func (client ApplicationsClient) Delete(resourceGroupName string, clusterName string, applicationName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) {
|
|
|
|
resultChan := make(chan autorest.Response, 1)
|
|
|
|
errChan := make(chan error, 1)
|
|
|
|
go func() {
|
|
|
|
var err error
|
|
|
|
var result autorest.Response
|
|
|
|
defer func() {
|
2017-10-01 08:13:39 +00:00
|
|
|
if err != nil {
|
|
|
|
errChan <- err
|
|
|
|
}
|
2017-08-05 18:30:20 +00:00
|
|
|
resultChan <- result
|
|
|
|
close(resultChan)
|
|
|
|
close(errChan)
|
|
|
|
}()
|
|
|
|
req, err := client.DeletePreparer(resourceGroupName, clusterName, applicationName, cancel)
|
|
|
|
if err != nil {
|
|
|
|
err = autorest.NewErrorWithError(err, "hdinsight.ApplicationsClient", "Delete", nil, "Failure preparing request")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
resp, err := client.DeleteSender(req)
|
|
|
|
if err != nil {
|
|
|
|
result.Response = resp
|
|
|
|
err = autorest.NewErrorWithError(err, "hdinsight.ApplicationsClient", "Delete", resp, "Failure sending request")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
result, err = client.DeleteResponder(resp)
|
|
|
|
if err != nil {
|
|
|
|
err = autorest.NewErrorWithError(err, "hdinsight.ApplicationsClient", "Delete", resp, "Failure responding to request")
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
return resultChan, errChan
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeletePreparer prepares the Delete request.
|
|
|
|
func (client ApplicationsClient) DeletePreparer(resourceGroupName string, clusterName string, applicationName string, cancel <-chan struct{}) (*http.Request, error) {
|
|
|
|
pathParameters := map[string]interface{}{
|
|
|
|
"applicationName": autorest.Encode("path", applicationName),
|
|
|
|
"clusterName": autorest.Encode("path", clusterName),
|
|
|
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
|
|
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
|
|
|
}
|
|
|
|
|
|
|
|
const APIVersion = "2015-03-01-preview"
|
|
|
|
queryParameters := map[string]interface{}{
|
|
|
|
"api-version": APIVersion,
|
|
|
|
}
|
|
|
|
|
|
|
|
preparer := autorest.CreatePreparer(
|
|
|
|
autorest.AsDelete(),
|
|
|
|
autorest.WithBaseURL(client.BaseURI),
|
|
|
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/applications/{applicationName}", pathParameters),
|
|
|
|
autorest.WithQueryParameters(queryParameters))
|
|
|
|
return preparer.Prepare(&http.Request{Cancel: cancel})
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeleteSender sends the Delete request. The method will close the
|
|
|
|
// http.Response Body if it receives an error.
|
|
|
|
func (client ApplicationsClient) DeleteSender(req *http.Request) (*http.Response, error) {
|
|
|
|
return autorest.SendWithSender(client,
|
|
|
|
req,
|
2017-12-03 20:01:25 +00:00
|
|
|
azure.DoRetryWithRegistration(client.Client),
|
2017-08-05 18:30:20 +00:00
|
|
|
azure.DoPollForAsynchronous(client.PollingDelay))
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeleteResponder handles the response to the Delete request. The method always
|
|
|
|
// closes the http.Response Body.
|
|
|
|
func (client ApplicationsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
|
|
|
|
err = autorest.Respond(
|
|
|
|
resp,
|
|
|
|
client.ByInspecting(),
|
|
|
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
|
|
|
autorest.ByClosing())
|
|
|
|
result.Response = resp
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get lists properties of the application.
|
|
|
|
//
|
2017-10-01 08:13:39 +00:00
|
|
|
// resourceGroupName is the name of the resource group. clusterName is the name of the cluster. applicationName is the
|
|
|
|
// constant value for the applicationName
|
|
|
|
func (client ApplicationsClient) Get(resourceGroupName string, clusterName string, applicationName ApplicationName) (result Application, err error) {
|
2017-08-05 18:30:20 +00:00
|
|
|
req, err := client.GetPreparer(resourceGroupName, clusterName, applicationName)
|
|
|
|
if err != nil {
|
|
|
|
err = autorest.NewErrorWithError(err, "hdinsight.ApplicationsClient", "Get", nil, "Failure preparing request")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
resp, err := client.GetSender(req)
|
|
|
|
if err != nil {
|
|
|
|
result.Response = autorest.Response{Response: resp}
|
|
|
|
err = autorest.NewErrorWithError(err, "hdinsight.ApplicationsClient", "Get", resp, "Failure sending request")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
result, err = client.GetResponder(resp)
|
|
|
|
if err != nil {
|
|
|
|
err = autorest.NewErrorWithError(err, "hdinsight.ApplicationsClient", "Get", resp, "Failure responding to request")
|
|
|
|
}
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetPreparer prepares the Get request.
|
2017-10-01 08:13:39 +00:00
|
|
|
func (client ApplicationsClient) GetPreparer(resourceGroupName string, clusterName string, applicationName ApplicationName) (*http.Request, error) {
|
2017-08-05 18:30:20 +00:00
|
|
|
pathParameters := map[string]interface{}{
|
|
|
|
"applicationName": autorest.Encode("path", applicationName),
|
|
|
|
"clusterName": autorest.Encode("path", clusterName),
|
|
|
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
|
|
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
|
|
|
}
|
|
|
|
|
|
|
|
const APIVersion = "2015-03-01-preview"
|
|
|
|
queryParameters := map[string]interface{}{
|
|
|
|
"api-version": APIVersion,
|
|
|
|
}
|
|
|
|
|
|
|
|
preparer := autorest.CreatePreparer(
|
|
|
|
autorest.AsGet(),
|
|
|
|
autorest.WithBaseURL(client.BaseURI),
|
|
|
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/applications/{applicationName}", pathParameters),
|
|
|
|
autorest.WithQueryParameters(queryParameters))
|
|
|
|
return preparer.Prepare(&http.Request{})
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetSender sends the Get request. The method will close the
|
|
|
|
// http.Response Body if it receives an error.
|
|
|
|
func (client ApplicationsClient) GetSender(req *http.Request) (*http.Response, error) {
|
2017-12-03 20:01:25 +00:00
|
|
|
return autorest.SendWithSender(client,
|
|
|
|
req,
|
|
|
|
azure.DoRetryWithRegistration(client.Client))
|
2017-08-05 18:30:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetResponder handles the response to the Get request. The method always
|
|
|
|
// closes the http.Response Body.
|
|
|
|
func (client ApplicationsClient) GetResponder(resp *http.Response) (result Application, err error) {
|
|
|
|
err = autorest.Respond(
|
|
|
|
resp,
|
|
|
|
client.ByInspecting(),
|
|
|
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
|
|
|
autorest.ByUnmarshallingJSON(&result),
|
|
|
|
autorest.ByClosing())
|
|
|
|
result.Response = autorest.Response{Response: resp}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// List lists all of the applications HDInsight cluster.
|
|
|
|
//
|
2017-10-01 08:13:39 +00:00
|
|
|
// resourceGroupName is the name of the resource group. clusterName is the name of the cluster.
|
2017-08-05 18:30:20 +00:00
|
|
|
func (client ApplicationsClient) List(resourceGroupName string, clusterName string) (result ApplicationListResult, err error) {
|
|
|
|
req, err := client.ListPreparer(resourceGroupName, clusterName)
|
|
|
|
if err != nil {
|
|
|
|
err = autorest.NewErrorWithError(err, "hdinsight.ApplicationsClient", "List", nil, "Failure preparing request")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
resp, err := client.ListSender(req)
|
|
|
|
if err != nil {
|
|
|
|
result.Response = autorest.Response{Response: resp}
|
|
|
|
err = autorest.NewErrorWithError(err, "hdinsight.ApplicationsClient", "List", resp, "Failure sending request")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
result, err = client.ListResponder(resp)
|
|
|
|
if err != nil {
|
|
|
|
err = autorest.NewErrorWithError(err, "hdinsight.ApplicationsClient", "List", resp, "Failure responding to request")
|
|
|
|
}
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// ListPreparer prepares the List request.
|
|
|
|
func (client ApplicationsClient) ListPreparer(resourceGroupName string, clusterName string) (*http.Request, error) {
|
|
|
|
pathParameters := map[string]interface{}{
|
|
|
|
"clusterName": autorest.Encode("path", clusterName),
|
|
|
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
|
|
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
|
|
|
}
|
|
|
|
|
|
|
|
const APIVersion = "2015-03-01-preview"
|
|
|
|
queryParameters := map[string]interface{}{
|
|
|
|
"api-version": APIVersion,
|
|
|
|
}
|
|
|
|
|
|
|
|
preparer := autorest.CreatePreparer(
|
|
|
|
autorest.AsGet(),
|
|
|
|
autorest.WithBaseURL(client.BaseURI),
|
|
|
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/applications", pathParameters),
|
|
|
|
autorest.WithQueryParameters(queryParameters))
|
|
|
|
return preparer.Prepare(&http.Request{})
|
|
|
|
}
|
|
|
|
|
|
|
|
// ListSender sends the List request. The method will close the
|
|
|
|
// http.Response Body if it receives an error.
|
|
|
|
func (client ApplicationsClient) ListSender(req *http.Request) (*http.Response, error) {
|
2017-12-03 20:01:25 +00:00
|
|
|
return autorest.SendWithSender(client,
|
|
|
|
req,
|
|
|
|
azure.DoRetryWithRegistration(client.Client))
|
2017-08-05 18:30:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ListResponder handles the response to the List request. The method always
|
|
|
|
// closes the http.Response Body.
|
|
|
|
func (client ApplicationsClient) ListResponder(resp *http.Response) (result ApplicationListResult, err error) {
|
|
|
|
err = autorest.Respond(
|
|
|
|
resp,
|
|
|
|
client.ByInspecting(),
|
|
|
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
|
|
|
autorest.ByUnmarshallingJSON(&result),
|
|
|
|
autorest.ByClosing())
|
|
|
|
result.Response = autorest.Response{Response: resp}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// ListNextResults retrieves the next set of results, if any.
|
|
|
|
func (client ApplicationsClient) ListNextResults(lastResults ApplicationListResult) (result ApplicationListResult, err error) {
|
|
|
|
req, err := lastResults.ApplicationListResultPreparer()
|
|
|
|
if err != nil {
|
|
|
|
return result, autorest.NewErrorWithError(err, "hdinsight.ApplicationsClient", "List", nil, "Failure preparing next results request")
|
|
|
|
}
|
|
|
|
if req == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
resp, err := client.ListSender(req)
|
|
|
|
if err != nil {
|
|
|
|
result.Response = autorest.Response{Response: resp}
|
|
|
|
return result, autorest.NewErrorWithError(err, "hdinsight.ApplicationsClient", "List", resp, "Failure sending next results request")
|
|
|
|
}
|
|
|
|
|
|
|
|
result, err = client.ListResponder(resp)
|
|
|
|
if err != nil {
|
|
|
|
err = autorest.NewErrorWithError(err, "hdinsight.ApplicationsClient", "List", resp, "Failure responding to next results request")
|
|
|
|
}
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
2017-10-01 08:13:39 +00:00
|
|
|
|
|
|
|
// ListComplete gets all elements from the list without paging.
|
|
|
|
func (client ApplicationsClient) ListComplete(resourceGroupName string, clusterName string, cancel <-chan struct{}) (<-chan Application, <-chan error) {
|
|
|
|
resultChan := make(chan Application)
|
|
|
|
errChan := make(chan error, 1)
|
|
|
|
go func() {
|
|
|
|
defer func() {
|
|
|
|
close(resultChan)
|
|
|
|
close(errChan)
|
|
|
|
}()
|
|
|
|
list, err := client.List(resourceGroupName, clusterName)
|
|
|
|
if err != nil {
|
|
|
|
errChan <- err
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if list.Value != nil {
|
|
|
|
for _, item := range *list.Value {
|
|
|
|
select {
|
|
|
|
case <-cancel:
|
|
|
|
return
|
|
|
|
case resultChan <- item:
|
|
|
|
// Intentionally left blank
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for list.NextLink != nil {
|
|
|
|
list, err = client.ListNextResults(list)
|
|
|
|
if err != nil {
|
|
|
|
errChan <- err
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if list.Value != nil {
|
|
|
|
for _, item := range *list.Value {
|
|
|
|
select {
|
|
|
|
case <-cancel:
|
|
|
|
return
|
|
|
|
case resultChan <- item:
|
|
|
|
// Intentionally left blank
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
return resultChan, errChan
|
|
|
|
}
|