vendor: add github.com/Azure/azure-sdk-for-go and dependencies

This commit is contained in:
Nick Craig-Wood
2017-08-04 22:54:27 +01:00
parent 132f71d504
commit 91cfcc21ff
958 changed files with 320589 additions and 0 deletions
+53
View File
@@ -0,0 +1,53 @@
// Package servermanagement implements the Azure ARM Servermanagement service
// API version 2016-07-01-preview.
//
// REST API for Azure Server Management Service.
package servermanagement
// 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.
//
// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
import (
"github.com/Azure/go-autorest/autorest"
)
const (
// DefaultBaseURI is the default URI used for the service Servermanagement
DefaultBaseURI = "https://management.azure.com"
)
// ManagementClient is the base client for Servermanagement.
type ManagementClient struct {
autorest.Client
BaseURI string
SubscriptionID string
}
// New creates an instance of the ManagementClient client.
func New(subscriptionID string) ManagementClient {
return NewWithBaseURI(DefaultBaseURI, subscriptionID)
}
// NewWithBaseURI creates an instance of the ManagementClient client.
func NewWithBaseURI(baseURI string, subscriptionID string) ManagementClient {
return ManagementClient{
Client: autorest.NewClientWithUserAgent(UserAgent()),
BaseURI: baseURI,
SubscriptionID: subscriptionID,
}
}
+869
View File
@@ -0,0 +1,869 @@
package servermanagement
// 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.
//
// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
import (
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/go-autorest/autorest/validation"
"net/http"
)
// GatewayClient is the rEST API for Azure Server Management Service.
type GatewayClient struct {
ManagementClient
}
// NewGatewayClient creates an instance of the GatewayClient client.
func NewGatewayClient(subscriptionID string) GatewayClient {
return NewGatewayClientWithBaseURI(DefaultBaseURI, subscriptionID)
}
// NewGatewayClientWithBaseURI creates an instance of the GatewayClient client.
func NewGatewayClientWithBaseURI(baseURI string, subscriptionID string) GatewayClient {
return GatewayClient{NewWithBaseURI(baseURI, subscriptionID)}
}
// Create creates or updates a ManagementService gateway. 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.
//
// resourceGroupName is the resource group name uniquely identifies the
// resource group within the user subscriptionId. gatewayName is the gateway
// name (256 characters maximum). gatewayParameters is parameters supplied to
// the CreateOrUpdate operation.
func (client GatewayClient) Create(resourceGroupName string, gatewayName string, gatewayParameters GatewayParameters, cancel <-chan struct{}) (<-chan GatewayResource, <-chan error) {
resultChan := make(chan GatewayResource, 1)
errChan := make(chan error, 1)
if err := validation.Validate([]validation.Validation{
{TargetValue: resourceGroupName,
Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 3, Chain: nil},
{Target: "resourceGroupName", Name: validation.Pattern, Rule: `[a-zA-Z0-9]+`, Chain: nil}}},
{TargetValue: gatewayName,
Constraints: []validation.Constraint{{Target: "gatewayName", Name: validation.MaxLength, Rule: 256, Chain: nil},
{Target: "gatewayName", Name: validation.MinLength, Rule: 1, Chain: nil},
{Target: "gatewayName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9_.-]*$`, Chain: nil}}}}); err != nil {
errChan <- validation.NewErrorWithValidationError(err, "servermanagement.GatewayClient", "Create")
close(errChan)
close(resultChan)
return resultChan, errChan
}
go func() {
var err error
var result GatewayResource
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.CreatePreparer(resourceGroupName, gatewayName, gatewayParameters, cancel)
if err != nil {
err = autorest.NewErrorWithError(err, "servermanagement.GatewayClient", "Create", nil, "Failure preparing request")
return
}
resp, err := client.CreateSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "servermanagement.GatewayClient", "Create", resp, "Failure sending request")
return
}
result, err = client.CreateResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "servermanagement.GatewayClient", "Create", resp, "Failure responding to request")
}
}()
return resultChan, errChan
}
// CreatePreparer prepares the Create request.
func (client GatewayClient) CreatePreparer(resourceGroupName string, gatewayName string, gatewayParameters GatewayParameters, cancel <-chan struct{}) (*http.Request, error) {
pathParameters := map[string]interface{}{
"gatewayName": autorest.Encode("path", gatewayName),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
const APIVersion = "2016-07-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.ServerManagement/gateways/{gatewayName}", pathParameters),
autorest.WithJSON(gatewayParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{Cancel: cancel})
}
// CreateSender sends the Create request. The method will close the
// http.Response Body if it receives an error.
func (client GatewayClient) CreateSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client,
req,
azure.DoPollForAsynchronous(client.PollingDelay))
}
// CreateResponder handles the response to the Create request. The method always
// closes the http.Response Body.
func (client GatewayClient) CreateResponder(resp *http.Response) (result GatewayResource, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// Delete deletes a gateway from a resource group.
//
// resourceGroupName is the resource group name uniquely identifies the
// resource group within the user subscriptionId. gatewayName is the gateway
// name (256 characters maximum).
func (client GatewayClient) Delete(resourceGroupName string, gatewayName string) (result autorest.Response, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: resourceGroupName,
Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 3, Chain: nil},
{Target: "resourceGroupName", Name: validation.Pattern, Rule: `[a-zA-Z0-9]+`, Chain: nil}}},
{TargetValue: gatewayName,
Constraints: []validation.Constraint{{Target: "gatewayName", Name: validation.MaxLength, Rule: 256, Chain: nil},
{Target: "gatewayName", Name: validation.MinLength, Rule: 1, Chain: nil},
{Target: "gatewayName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9_.-]*$`, Chain: nil}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "servermanagement.GatewayClient", "Delete")
}
req, err := client.DeletePreparer(resourceGroupName, gatewayName)
if err != nil {
err = autorest.NewErrorWithError(err, "servermanagement.GatewayClient", "Delete", nil, "Failure preparing request")
return
}
resp, err := client.DeleteSender(req)
if err != nil {
result.Response = resp
err = autorest.NewErrorWithError(err, "servermanagement.GatewayClient", "Delete", resp, "Failure sending request")
return
}
result, err = client.DeleteResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "servermanagement.GatewayClient", "Delete", resp, "Failure responding to request")
}
return
}
// DeletePreparer prepares the Delete request.
func (client GatewayClient) DeletePreparer(resourceGroupName string, gatewayName string) (*http.Request, error) {
pathParameters := map[string]interface{}{
"gatewayName": autorest.Encode("path", gatewayName),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
const APIVersion = "2016-07-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.ServerManagement/gateways/{gatewayName}", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// DeleteSender sends the Delete request. The method will close the
// http.Response Body if it receives an error.
func (client GatewayClient) DeleteSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// DeleteResponder handles the response to the Delete request. The method always
// closes the http.Response Body.
func (client GatewayClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
autorest.ByClosing())
result.Response = resp
return
}
// Get gets a gateway.
//
// resourceGroupName is the resource group name uniquely identifies the
// resource group within the user subscriptionId. gatewayName is the gateway
// name (256 characters maximum) expand is gets subscription credentials which
// uniquely identify Microsoft Azure subscription. The subscription ID forms
// part of the URI for every service call.
func (client GatewayClient) Get(resourceGroupName string, gatewayName string, expand GatewayExpandOption) (result GatewayResource, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: resourceGroupName,
Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 3, Chain: nil},
{Target: "resourceGroupName", Name: validation.Pattern, Rule: `[a-zA-Z0-9]+`, Chain: nil}}},
{TargetValue: gatewayName,
Constraints: []validation.Constraint{{Target: "gatewayName", Name: validation.MaxLength, Rule: 256, Chain: nil},
{Target: "gatewayName", Name: validation.MinLength, Rule: 1, Chain: nil},
{Target: "gatewayName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9_.-]*$`, Chain: nil}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "servermanagement.GatewayClient", "Get")
}
req, err := client.GetPreparer(resourceGroupName, gatewayName, expand)
if err != nil {
err = autorest.NewErrorWithError(err, "servermanagement.GatewayClient", "Get", nil, "Failure preparing request")
return
}
resp, err := client.GetSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "servermanagement.GatewayClient", "Get", resp, "Failure sending request")
return
}
result, err = client.GetResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "servermanagement.GatewayClient", "Get", resp, "Failure responding to request")
}
return
}
// GetPreparer prepares the Get request.
func (client GatewayClient) GetPreparer(resourceGroupName string, gatewayName string, expand GatewayExpandOption) (*http.Request, error) {
pathParameters := map[string]interface{}{
"gatewayName": autorest.Encode("path", gatewayName),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
const APIVersion = "2016-07-01-preview"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
if len(string(expand)) > 0 {
queryParameters["$expand"] = autorest.Encode("query", expand)
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServerManagement/gateways/{gatewayName}", 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 GatewayClient) GetSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// GetResponder handles the response to the Get request. The method always
// closes the http.Response Body.
func (client GatewayClient) GetResponder(resp *http.Response) (result GatewayResource, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// GetProfile gets a gateway profile. 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.
//
// resourceGroupName is the resource group name uniquely identifies the
// resource group within the user subscriptionId. gatewayName is the gateway
// name (256 characters maximum).
func (client GatewayClient) GetProfile(resourceGroupName string, gatewayName string, cancel <-chan struct{}) (<-chan GatewayProfile, <-chan error) {
resultChan := make(chan GatewayProfile, 1)
errChan := make(chan error, 1)
if err := validation.Validate([]validation.Validation{
{TargetValue: resourceGroupName,
Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 3, Chain: nil},
{Target: "resourceGroupName", Name: validation.Pattern, Rule: `[a-zA-Z0-9]+`, Chain: nil}}},
{TargetValue: gatewayName,
Constraints: []validation.Constraint{{Target: "gatewayName", Name: validation.MaxLength, Rule: 256, Chain: nil},
{Target: "gatewayName", Name: validation.MinLength, Rule: 1, Chain: nil},
{Target: "gatewayName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9_.-]*$`, Chain: nil}}}}); err != nil {
errChan <- validation.NewErrorWithValidationError(err, "servermanagement.GatewayClient", "GetProfile")
close(errChan)
close(resultChan)
return resultChan, errChan
}
go func() {
var err error
var result GatewayProfile
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.GetProfilePreparer(resourceGroupName, gatewayName, cancel)
if err != nil {
err = autorest.NewErrorWithError(err, "servermanagement.GatewayClient", "GetProfile", nil, "Failure preparing request")
return
}
resp, err := client.GetProfileSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "servermanagement.GatewayClient", "GetProfile", resp, "Failure sending request")
return
}
result, err = client.GetProfileResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "servermanagement.GatewayClient", "GetProfile", resp, "Failure responding to request")
}
}()
return resultChan, errChan
}
// GetProfilePreparer prepares the GetProfile request.
func (client GatewayClient) GetProfilePreparer(resourceGroupName string, gatewayName string, cancel <-chan struct{}) (*http.Request, error) {
pathParameters := map[string]interface{}{
"gatewayName": autorest.Encode("path", gatewayName),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
const APIVersion = "2016-07-01-preview"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsPost(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServerManagement/gateways/{gatewayName}/profile", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{Cancel: cancel})
}
// GetProfileSender sends the GetProfile request. The method will close the
// http.Response Body if it receives an error.
func (client GatewayClient) GetProfileSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client,
req,
azure.DoPollForAsynchronous(client.PollingDelay))
}
// GetProfileResponder handles the response to the GetProfile request. The method always
// closes the http.Response Body.
func (client GatewayClient) GetProfileResponder(resp *http.Response) (result GatewayProfile, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// List returns gateways in a subscription.
func (client GatewayClient) List() (result GatewayResources, err error) {
req, err := client.ListPreparer()
if err != nil {
err = autorest.NewErrorWithError(err, "servermanagement.GatewayClient", "List", nil, "Failure preparing request")
return
}
resp, err := client.ListSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "servermanagement.GatewayClient", "List", resp, "Failure sending request")
return
}
result, err = client.ListResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "servermanagement.GatewayClient", "List", resp, "Failure responding to request")
}
return
}
// ListPreparer prepares the List request.
func (client GatewayClient) ListPreparer() (*http.Request, error) {
pathParameters := map[string]interface{}{
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
const APIVersion = "2016-07-01-preview"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.ServerManagement/gateways", 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 GatewayClient) ListSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// ListResponder handles the response to the List request. The method always
// closes the http.Response Body.
func (client GatewayClient) ListResponder(resp *http.Response) (result GatewayResources, 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 GatewayClient) ListNextResults(lastResults GatewayResources) (result GatewayResources, err error) {
req, err := lastResults.GatewayResourcesPreparer()
if err != nil {
return result, autorest.NewErrorWithError(err, "servermanagement.GatewayClient", "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, "servermanagement.GatewayClient", "List", resp, "Failure sending next results request")
}
result, err = client.ListResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "servermanagement.GatewayClient", "List", resp, "Failure responding to next results request")
}
return
}
// ListForResourceGroup returns gateways in a resource group.
//
// resourceGroupName is the resource group name uniquely identifies the
// resource group within the user subscriptionId.
func (client GatewayClient) ListForResourceGroup(resourceGroupName string) (result GatewayResources, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: resourceGroupName,
Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 3, Chain: nil},
{Target: "resourceGroupName", Name: validation.Pattern, Rule: `[a-zA-Z0-9]+`, Chain: nil}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "servermanagement.GatewayClient", "ListForResourceGroup")
}
req, err := client.ListForResourceGroupPreparer(resourceGroupName)
if err != nil {
err = autorest.NewErrorWithError(err, "servermanagement.GatewayClient", "ListForResourceGroup", nil, "Failure preparing request")
return
}
resp, err := client.ListForResourceGroupSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "servermanagement.GatewayClient", "ListForResourceGroup", resp, "Failure sending request")
return
}
result, err = client.ListForResourceGroupResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "servermanagement.GatewayClient", "ListForResourceGroup", resp, "Failure responding to request")
}
return
}
// ListForResourceGroupPreparer prepares the ListForResourceGroup request.
func (client GatewayClient) ListForResourceGroupPreparer(resourceGroupName string) (*http.Request, error) {
pathParameters := map[string]interface{}{
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
const APIVersion = "2016-07-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.ServerManagement/gateways", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// ListForResourceGroupSender sends the ListForResourceGroup request. The method will close the
// http.Response Body if it receives an error.
func (client GatewayClient) ListForResourceGroupSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// ListForResourceGroupResponder handles the response to the ListForResourceGroup request. The method always
// closes the http.Response Body.
func (client GatewayClient) ListForResourceGroupResponder(resp *http.Response) (result GatewayResources, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// ListForResourceGroupNextResults retrieves the next set of results, if any.
func (client GatewayClient) ListForResourceGroupNextResults(lastResults GatewayResources) (result GatewayResources, err error) {
req, err := lastResults.GatewayResourcesPreparer()
if err != nil {
return result, autorest.NewErrorWithError(err, "servermanagement.GatewayClient", "ListForResourceGroup", nil, "Failure preparing next results request")
}
if req == nil {
return
}
resp, err := client.ListForResourceGroupSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "servermanagement.GatewayClient", "ListForResourceGroup", resp, "Failure sending next results request")
}
result, err = client.ListForResourceGroupResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "servermanagement.GatewayClient", "ListForResourceGroup", resp, "Failure responding to next results request")
}
return
}
// RegenerateProfile regenerate a gateway's profile 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.
//
// resourceGroupName is the resource group name uniquely identifies the
// resource group within the user subscriptionId. gatewayName is the gateway
// name (256 characters maximum).
func (client GatewayClient) RegenerateProfile(resourceGroupName string, gatewayName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) {
resultChan := make(chan autorest.Response, 1)
errChan := make(chan error, 1)
if err := validation.Validate([]validation.Validation{
{TargetValue: resourceGroupName,
Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 3, Chain: nil},
{Target: "resourceGroupName", Name: validation.Pattern, Rule: `[a-zA-Z0-9]+`, Chain: nil}}},
{TargetValue: gatewayName,
Constraints: []validation.Constraint{{Target: "gatewayName", Name: validation.MaxLength, Rule: 256, Chain: nil},
{Target: "gatewayName", Name: validation.MinLength, Rule: 1, Chain: nil},
{Target: "gatewayName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9_.-]*$`, Chain: nil}}}}); err != nil {
errChan <- validation.NewErrorWithValidationError(err, "servermanagement.GatewayClient", "RegenerateProfile")
close(errChan)
close(resultChan)
return resultChan, errChan
}
go func() {
var err error
var result autorest.Response
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.RegenerateProfilePreparer(resourceGroupName, gatewayName, cancel)
if err != nil {
err = autorest.NewErrorWithError(err, "servermanagement.GatewayClient", "RegenerateProfile", nil, "Failure preparing request")
return
}
resp, err := client.RegenerateProfileSender(req)
if err != nil {
result.Response = resp
err = autorest.NewErrorWithError(err, "servermanagement.GatewayClient", "RegenerateProfile", resp, "Failure sending request")
return
}
result, err = client.RegenerateProfileResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "servermanagement.GatewayClient", "RegenerateProfile", resp, "Failure responding to request")
}
}()
return resultChan, errChan
}
// RegenerateProfilePreparer prepares the RegenerateProfile request.
func (client GatewayClient) RegenerateProfilePreparer(resourceGroupName string, gatewayName string, cancel <-chan struct{}) (*http.Request, error) {
pathParameters := map[string]interface{}{
"gatewayName": autorest.Encode("path", gatewayName),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
const APIVersion = "2016-07-01-preview"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsPost(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServerManagement/gateways/{gatewayName}/regenerateprofile", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{Cancel: cancel})
}
// RegenerateProfileSender sends the RegenerateProfile request. The method will close the
// http.Response Body if it receives an error.
func (client GatewayClient) RegenerateProfileSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client,
req,
azure.DoPollForAsynchronous(client.PollingDelay))
}
// RegenerateProfileResponder handles the response to the RegenerateProfile request. The method always
// closes the http.Response Body.
func (client GatewayClient) RegenerateProfileResponder(resp *http.Response) (result autorest.Response, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
autorest.ByClosing())
result.Response = resp
return
}
// Update updates a gateway belonging to a resource group. 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.
//
// resourceGroupName is the resource group name uniquely identifies the
// resource group within the user subscriptionId. gatewayName is the gateway
// name (256 characters maximum). gatewayParameters is parameters supplied to
// the Update operation.
func (client GatewayClient) Update(resourceGroupName string, gatewayName string, gatewayParameters GatewayParameters, cancel <-chan struct{}) (<-chan GatewayResource, <-chan error) {
resultChan := make(chan GatewayResource, 1)
errChan := make(chan error, 1)
if err := validation.Validate([]validation.Validation{
{TargetValue: resourceGroupName,
Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 3, Chain: nil},
{Target: "resourceGroupName", Name: validation.Pattern, Rule: `[a-zA-Z0-9]+`, Chain: nil}}},
{TargetValue: gatewayName,
Constraints: []validation.Constraint{{Target: "gatewayName", Name: validation.MaxLength, Rule: 256, Chain: nil},
{Target: "gatewayName", Name: validation.MinLength, Rule: 1, Chain: nil},
{Target: "gatewayName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9_.-]*$`, Chain: nil}}}}); err != nil {
errChan <- validation.NewErrorWithValidationError(err, "servermanagement.GatewayClient", "Update")
close(errChan)
close(resultChan)
return resultChan, errChan
}
go func() {
var err error
var result GatewayResource
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.UpdatePreparer(resourceGroupName, gatewayName, gatewayParameters, cancel)
if err != nil {
err = autorest.NewErrorWithError(err, "servermanagement.GatewayClient", "Update", nil, "Failure preparing request")
return
}
resp, err := client.UpdateSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "servermanagement.GatewayClient", "Update", resp, "Failure sending request")
return
}
result, err = client.UpdateResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "servermanagement.GatewayClient", "Update", resp, "Failure responding to request")
}
}()
return resultChan, errChan
}
// UpdatePreparer prepares the Update request.
func (client GatewayClient) UpdatePreparer(resourceGroupName string, gatewayName string, gatewayParameters GatewayParameters, cancel <-chan struct{}) (*http.Request, error) {
pathParameters := map[string]interface{}{
"gatewayName": autorest.Encode("path", gatewayName),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
const APIVersion = "2016-07-01-preview"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsJSON(),
autorest.AsPatch(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServerManagement/gateways/{gatewayName}", pathParameters),
autorest.WithJSON(gatewayParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{Cancel: cancel})
}
// UpdateSender sends the Update request. The method will close the
// http.Response Body if it receives an error.
func (client GatewayClient) UpdateSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client,
req,
azure.DoPollForAsynchronous(client.PollingDelay))
}
// UpdateResponder handles the response to the Update request. The method always
// closes the http.Response Body.
func (client GatewayClient) UpdateResponder(resp *http.Response) (result GatewayResource, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// Upgrade upgrades a gateway. 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.
//
// resourceGroupName is the resource group name uniquely identifies the
// resource group within the user subscriptionId. gatewayName is the gateway
// name (256 characters maximum).
func (client GatewayClient) Upgrade(resourceGroupName string, gatewayName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) {
resultChan := make(chan autorest.Response, 1)
errChan := make(chan error, 1)
if err := validation.Validate([]validation.Validation{
{TargetValue: resourceGroupName,
Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 3, Chain: nil},
{Target: "resourceGroupName", Name: validation.Pattern, Rule: `[a-zA-Z0-9]+`, Chain: nil}}},
{TargetValue: gatewayName,
Constraints: []validation.Constraint{{Target: "gatewayName", Name: validation.MaxLength, Rule: 256, Chain: nil},
{Target: "gatewayName", Name: validation.MinLength, Rule: 1, Chain: nil},
{Target: "gatewayName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9_.-]*$`, Chain: nil}}}}); err != nil {
errChan <- validation.NewErrorWithValidationError(err, "servermanagement.GatewayClient", "Upgrade")
close(errChan)
close(resultChan)
return resultChan, errChan
}
go func() {
var err error
var result autorest.Response
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.UpgradePreparer(resourceGroupName, gatewayName, cancel)
if err != nil {
err = autorest.NewErrorWithError(err, "servermanagement.GatewayClient", "Upgrade", nil, "Failure preparing request")
return
}
resp, err := client.UpgradeSender(req)
if err != nil {
result.Response = resp
err = autorest.NewErrorWithError(err, "servermanagement.GatewayClient", "Upgrade", resp, "Failure sending request")
return
}
result, err = client.UpgradeResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "servermanagement.GatewayClient", "Upgrade", resp, "Failure responding to request")
}
}()
return resultChan, errChan
}
// UpgradePreparer prepares the Upgrade request.
func (client GatewayClient) UpgradePreparer(resourceGroupName string, gatewayName string, cancel <-chan struct{}) (*http.Request, error) {
pathParameters := map[string]interface{}{
"gatewayName": autorest.Encode("path", gatewayName),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
const APIVersion = "2016-07-01-preview"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsPost(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServerManagement/gateways/{gatewayName}/upgradetolatest", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{Cancel: cancel})
}
// UpgradeSender sends the Upgrade request. The method will close the
// http.Response Body if it receives an error.
func (client GatewayClient) UpgradeSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client,
req,
azure.DoPollForAsynchronous(client.PollingDelay))
}
// UpgradeResponder handles the response to the Upgrade request. The method always
// closes the http.Response Body.
func (client GatewayClient) UpgradeResponder(resp *http.Response) (result autorest.Response, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
autorest.ByClosing())
result.Response = resp
return
}
+413
View File
@@ -0,0 +1,413 @@
package servermanagement
// 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.
//
// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
import (
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/date"
"github.com/Azure/go-autorest/autorest/to"
"net/http"
)
// CredentialDataFormat enumerates the values for credential data format.
type CredentialDataFormat string
const (
// RsaEncrypted specifies the rsa encrypted state for credential data
// format.
RsaEncrypted CredentialDataFormat = "RsaEncrypted"
)
// GatewayExpandOption enumerates the values for gateway expand option.
type GatewayExpandOption string
const (
// Download specifies the download state for gateway expand option.
Download GatewayExpandOption = "download"
// Status specifies the status state for gateway expand option.
Status GatewayExpandOption = "status"
)
// PowerShellExpandOption enumerates the values for power shell expand option.
type PowerShellExpandOption string
const (
// Output specifies the output state for power shell expand option.
Output PowerShellExpandOption = "output"
)
// PromptFieldType enumerates the values for prompt field type.
type PromptFieldType string
const (
// Credential specifies the credential state for prompt field type.
Credential PromptFieldType = "Credential"
// SecureString specifies the secure string state for prompt field type.
SecureString PromptFieldType = "SecureString"
// String specifies the string state for prompt field type.
String PromptFieldType = "String"
)
// RetentionPeriod enumerates the values for retention period.
type RetentionPeriod string
const (
// Persistent specifies the persistent state for retention period.
Persistent RetentionPeriod = "Persistent"
// Session specifies the session state for retention period.
Session RetentionPeriod = "Session"
)
// UpgradeMode enumerates the values for upgrade mode.
type UpgradeMode string
const (
// Automatic specifies the automatic state for upgrade mode.
Automatic UpgradeMode = "Automatic"
// Manual specifies the manual state for upgrade mode.
Manual UpgradeMode = "Manual"
)
// EncryptionJwkResource is the public key of the gateway.
type EncryptionJwkResource struct {
Kty *string `json:"kty,omitempty"`
Alg *string `json:"alg,omitempty"`
E *string `json:"e,omitempty"`
N *string `json:"n,omitempty"`
}
// Error is error message.
type Error struct {
Code *int32 `json:"code,omitempty"`
Message *string `json:"message,omitempty"`
Fields *string `json:"fields,omitempty"`
}
// GatewayParameters is collection of parameters for operations on a gateway
// resource.
type GatewayParameters struct {
Location *string `json:"location,omitempty"`
Tags *map[string]interface{} `json:"tags,omitempty"`
*GatewayParametersProperties `json:"properties,omitempty"`
}
// GatewayParametersProperties is collection of properties.
type GatewayParametersProperties struct {
UpgradeMode UpgradeMode `json:"upgradeMode,omitempty"`
}
// GatewayProfile is jSON properties that the gateway service uses know how to
// communicate with the resource.
type GatewayProfile struct {
autorest.Response `json:"-"`
DataPlaneServiceBaseAddress *string `json:"dataPlaneServiceBaseAddress,omitempty"`
GatewayID *string `json:"gatewayId,omitempty"`
Environment *string `json:"environment,omitempty"`
UpgradeManifestURL *string `json:"upgradeManifestUrl,omitempty"`
MessagingNamespace *string `json:"messagingNamespace,omitempty"`
MessagingAccount *string `json:"messagingAccount,omitempty"`
MessagingKey *string `json:"messagingKey,omitempty"`
RequestQueue *string `json:"requestQueue,omitempty"`
ResponseTopic *string `json:"responseTopic,omitempty"`
StatusBlobSignature *string `json:"statusBlobSignature,omitempty"`
}
// GatewayResource is data model for an arm gateway resource.
type GatewayResource struct {
autorest.Response `json:"-"`
ID *string `json:"id,omitempty"`
Type *string `json:"type,omitempty"`
Name *string `json:"name,omitempty"`
Location *string `json:"location,omitempty"`
Tags *map[string]*string `json:"tags,omitempty"`
Etag *string `json:"etag,omitempty"`
*GatewayResourceProperties `json:"properties,omitempty"`
}
// GatewayResourceProperties is collection of properties.
type GatewayResourceProperties struct {
Created *date.Time `json:"created,omitempty"`
Updated *date.Time `json:"updated,omitempty"`
UpgradeMode UpgradeMode `json:"upgradeMode,omitempty"`
DesiredVersion *string `json:"desiredVersion,omitempty"`
Instances *[]GatewayStatus `json:"instances,omitempty"`
ActiveMessageCount *int32 `json:"activeMessageCount,omitempty"`
LatestPublishedMsiVersion *string `json:"latestPublishedMsiVersion,omitempty"`
PublishedTimeUtc *date.Time `json:"publishedTimeUtc,omitempty"`
InstallerDownload *string `json:"installerDownload,omitempty"`
MinimumVersion *string `json:"minimumVersion,omitempty"`
}
// GatewayResources is collection of Gateway Resources.
type GatewayResources struct {
autorest.Response `json:"-"`
Value *[]GatewayResource `json:"value,omitempty"`
NextLink *string `json:"nextLink,omitempty"`
}
// GatewayResourcesPreparer prepares a request to retrieve the next set of results. It returns
// nil if no more results exist.
func (client GatewayResources) GatewayResourcesPreparer() (*http.Request, error) {
if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 {
return nil, nil
}
return autorest.Prepare(&http.Request{},
autorest.AsJSON(),
autorest.AsGet(),
autorest.WithBaseURL(to.String(client.NextLink)))
}
// GatewayStatus is expanded gateway status information.
type GatewayStatus struct {
AvailableMemoryMByte *float64 `json:"availableMemoryMByte,omitempty"`
GatewayCPUUtilizationPercent *float64 `json:"gatewayCpuUtilizationPercent,omitempty"`
TotalCPUUtilizationPercent *float64 `json:"totalCpuUtilizationPercent,omitempty"`
GatewayVersion *string `json:"gatewayVersion,omitempty"`
FriendlyOsName *string `json:"friendlyOsName,omitempty"`
InstalledDate *date.Time `json:"installedDate,omitempty"`
LogicalProcessorCount *int32 `json:"logicalProcessorCount,omitempty"`
Name *string `json:"name,omitempty"`
GatewayID *string `json:"gatewayId,omitempty"`
GatewayWorkingSetMByte *float64 `json:"gatewayWorkingSetMByte,omitempty"`
StatusUpdated *date.Time `json:"statusUpdated,omitempty"`
GroupPolicyError *string `json:"groupPolicyError,omitempty"`
AllowGatewayGroupPolicyStatus *bool `json:"allowGatewayGroupPolicyStatus,omitempty"`
RequireMfaGroupPolicyStatus *bool `json:"requireMfaGroupPolicyStatus,omitempty"`
EncryptionCertificateThumbprint *string `json:"encryptionCertificateThumbprint,omitempty"`
SecondaryEncryptionCertificateThumbprint *string `json:"secondaryEncryptionCertificateThumbprint,omitempty"`
EncryptionJwk *EncryptionJwkResource `json:"encryptionJwk,omitempty"`
SecondaryEncryptionJwk *EncryptionJwkResource `json:"secondaryEncryptionJwk,omitempty"`
ActiveMessageCount *int32 `json:"activeMessageCount,omitempty"`
LatestPublishedMsiVersion *string `json:"latestPublishedMsiVersion,omitempty"`
PublishedTimeUtc *date.Time `json:"publishedTimeUtc,omitempty"`
}
// NodeParameters is parameter collection for operations on arm node resource.
type NodeParameters struct {
Location *string `json:"location,omitempty"`
Tags *map[string]interface{} `json:"tags,omitempty"`
*NodeParametersProperties `json:"properties,omitempty"`
}
// NodeParametersProperties is collection of properties.
type NodeParametersProperties struct {
GatewayID *string `json:"gatewayId,omitempty"`
ConnectionName *string `json:"connectionName,omitempty"`
UserName *string `json:"userName,omitempty"`
Password *string `json:"password,omitempty"`
}
// NodeResource is a Node Resource.
type NodeResource struct {
autorest.Response `json:"-"`
ID *string `json:"id,omitempty"`
Type *string `json:"type,omitempty"`
Name *string `json:"name,omitempty"`
Location *string `json:"location,omitempty"`
Tags *map[string]*string `json:"tags,omitempty"`
Etag *string `json:"etag,omitempty"`
*NodeResourceProperties `json:"properties,omitempty"`
}
// NodeResourceProperties is collection of properties.
type NodeResourceProperties struct {
GatewayID *string `json:"gatewayId,omitempty"`
ConnectionName *string `json:"connectionName,omitempty"`
Created *date.Time `json:"created,omitempty"`
Updated *date.Time `json:"updated,omitempty"`
}
// NodeResources is a collection of node resource objects.
type NodeResources struct {
autorest.Response `json:"-"`
Value *[]NodeResource `json:"value,omitempty"`
NextLink *string `json:"nextLink,omitempty"`
}
// NodeResourcesPreparer prepares a request to retrieve the next set of results. It returns
// nil if no more results exist.
func (client NodeResources) NodeResourcesPreparer() (*http.Request, error) {
if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 {
return nil, nil
}
return autorest.Prepare(&http.Request{},
autorest.AsJSON(),
autorest.AsGet(),
autorest.WithBaseURL(to.String(client.NextLink)))
}
// PowerShellCommandParameters is the parameters to a PowerShell script
// execution command.
type PowerShellCommandParameters struct {
*PowerShellCommandParametersProperties `json:"properties,omitempty"`
}
// PowerShellCommandParametersProperties is collection of properties.
type PowerShellCommandParametersProperties struct {
Command *string `json:"command,omitempty"`
}
// PowerShellCommandResult is results from invoking a PowerShell command.
type PowerShellCommandResult struct {
MessageType *int32 `json:"messageType,omitempty"`
ForegroundColor *string `json:"foregroundColor,omitempty"`
BackgroundColor *string `json:"backgroundColor,omitempty"`
Value *string `json:"value,omitempty"`
Prompt *string `json:"prompt,omitempty"`
ExitCode *int32 `json:"exitCode,omitempty"`
ID *int32 `json:"id,omitempty"`
Caption *string `json:"caption,omitempty"`
Message *string `json:"message,omitempty"`
Descriptions *[]PromptFieldDescription `json:"descriptions,omitempty"`
}
// PowerShellCommandResults is a collection of results from a PowerShell
// command.
type PowerShellCommandResults struct {
autorest.Response `json:"-"`
Results *[]PowerShellCommandResult `json:"results,omitempty"`
Pssession *string `json:"pssession,omitempty"`
Command *string `json:"command,omitempty"`
Completed *bool `json:"completed,omitempty"`
}
// PowerShellCommandStatus is result status from invoking a PowerShell command.
type PowerShellCommandStatus struct {
autorest.Response `json:"-"`
ID *string `json:"id,omitempty"`
Type *string `json:"type,omitempty"`
Name *string `json:"name,omitempty"`
Location *string `json:"location,omitempty"`
Tags *map[string]*string `json:"tags,omitempty"`
Etag *string `json:"etag,omitempty"`
*PowerShellCommandResults `json:"properties,omitempty"`
}
// PowerShellSessionResource is a PowerShell session resource (practically
// equivalent to a runspace instance).
type PowerShellSessionResource struct {
autorest.Response `json:"-"`
ID *string `json:"id,omitempty"`
Type *string `json:"type,omitempty"`
Name *string `json:"name,omitempty"`
Location *string `json:"location,omitempty"`
Tags *map[string]*string `json:"tags,omitempty"`
Etag *string `json:"etag,omitempty"`
*PowerShellSessionResourceProperties `json:"properties,omitempty"`
}
// PowerShellSessionResourceProperties is collection of properties.
type PowerShellSessionResourceProperties struct {
SessionID *string `json:"sessionId,omitempty"`
State *string `json:"state,omitempty"`
RunspaceAvailability *string `json:"runspaceAvailability,omitempty"`
DisconnectedOn *date.Time `json:"disconnectedOn,omitempty"`
ExpiresOn *date.Time `json:"expiresOn,omitempty"`
Version *VersionServermanagement `json:"version,omitempty"`
Name *string `json:"name,omitempty"`
}
// PowerShellSessionResources is a collection of PowerShell session resources
type PowerShellSessionResources struct {
autorest.Response `json:"-"`
Value *[]PowerShellSessionResource `json:"value,omitempty"`
NextLink *string `json:"nextLink,omitempty"`
}
// PowerShellTabCompletionParameters is collection of parameters for PowerShell
// tab completion.
type PowerShellTabCompletionParameters struct {
Command *string `json:"command,omitempty"`
}
// PowerShellTabCompletionResults is an array of strings representing the
// different values that can be selected through.
type PowerShellTabCompletionResults struct {
autorest.Response `json:"-"`
Results *[]string `json:"results,omitempty"`
}
// PromptFieldDescription is field description for the implementation of
// PSHostUserInterface.Prompt
type PromptFieldDescription struct {
Name *string `json:"name,omitempty"`
Label *string `json:"label,omitempty"`
HelpMessage *string `json:"helpMessage,omitempty"`
PromptFieldTypeIsList *bool `json:"promptFieldTypeIsList,omitempty"`
PromptFieldType PromptFieldType `json:"promptFieldType,omitempty"`
}
// PromptMessageResponse is the response to a prompt message.
type PromptMessageResponse struct {
Response *[]string `json:"response,omitempty"`
}
// Resource is resource Manager Resource Information.
type Resource struct {
ID *string `json:"id,omitempty"`
Type *string `json:"type,omitempty"`
Name *string `json:"name,omitempty"`
Location *string `json:"location,omitempty"`
Tags *map[string]*string `json:"tags,omitempty"`
Etag *string `json:"etag,omitempty"`
}
// SessionParameters is parameter collection for creation and other operations
// on sessions.
type SessionParameters struct {
*SessionParametersProperties `json:"properties,omitempty"`
}
// SessionParametersProperties is collection of properties
type SessionParametersProperties struct {
UserName *string `json:"userName,omitempty"`
Password *string `json:"password,omitempty"`
RetentionPeriod RetentionPeriod `json:"retentionPeriod,omitempty"`
CredentialDataFormat CredentialDataFormat `json:"credentialDataFormat,omitempty"`
EncryptionCertificateThumbprint *string `json:"EncryptionCertificateThumbprint,omitempty"`
}
// SessionResource is the session object.
type SessionResource struct {
autorest.Response `json:"-"`
ID *string `json:"id,omitempty"`
Type *string `json:"type,omitempty"`
Name *string `json:"name,omitempty"`
Location *string `json:"location,omitempty"`
Tags *map[string]*string `json:"tags,omitempty"`
Etag *string `json:"etag,omitempty"`
*SessionResourceProperties `json:"properties,omitempty"`
}
// SessionResourceProperties is collection of properties.
type SessionResourceProperties struct {
UserName *string `json:"userName,omitempty"`
Created *date.Time `json:"created,omitempty"`
Updated *date.Time `json:"updated,omitempty"`
}
// VersionServermanagement is a multipart-numeric version number.
type VersionServermanagement struct {
Major *int32 `json:"major,omitempty"`
Minor *int32 `json:"minor,omitempty"`
Build *int32 `json:"build,omitempty"`
Revision *int32 `json:"revision,omitempty"`
MajorRevision *int32 `json:"majorRevision,omitempty"`
MinorRevision *int32 `json:"minorRevision,omitempty"`
}
+576
View File
@@ -0,0 +1,576 @@
package servermanagement
// 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.
//
// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
import (
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/go-autorest/autorest/validation"
"net/http"
)
// NodeClient is the rEST API for Azure Server Management Service.
type NodeClient struct {
ManagementClient
}
// NewNodeClient creates an instance of the NodeClient client.
func NewNodeClient(subscriptionID string) NodeClient {
return NewNodeClientWithBaseURI(DefaultBaseURI, subscriptionID)
}
// NewNodeClientWithBaseURI creates an instance of the NodeClient client.
func NewNodeClientWithBaseURI(baseURI string, subscriptionID string) NodeClient {
return NodeClient{NewWithBaseURI(baseURI, subscriptionID)}
}
// Create creates or updates a management node. 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.
//
// resourceGroupName is the resource group name uniquely identifies the
// resource group within the user subscriptionId. nodeName is the node name
// (256 characters maximum). gatewayParameters is parameters supplied to the
// CreateOrUpdate operation.
func (client NodeClient) Create(resourceGroupName string, nodeName string, gatewayParameters NodeParameters, cancel <-chan struct{}) (<-chan NodeResource, <-chan error) {
resultChan := make(chan NodeResource, 1)
errChan := make(chan error, 1)
if err := validation.Validate([]validation.Validation{
{TargetValue: resourceGroupName,
Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 3, Chain: nil},
{Target: "resourceGroupName", Name: validation.Pattern, Rule: `[a-zA-Z0-9]+`, Chain: nil}}},
{TargetValue: nodeName,
Constraints: []validation.Constraint{{Target: "nodeName", Name: validation.MaxLength, Rule: 256, Chain: nil},
{Target: "nodeName", Name: validation.MinLength, Rule: 1, Chain: nil},
{Target: "nodeName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9_.-]*$`, Chain: nil}}}}); err != nil {
errChan <- validation.NewErrorWithValidationError(err, "servermanagement.NodeClient", "Create")
close(errChan)
close(resultChan)
return resultChan, errChan
}
go func() {
var err error
var result NodeResource
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.CreatePreparer(resourceGroupName, nodeName, gatewayParameters, cancel)
if err != nil {
err = autorest.NewErrorWithError(err, "servermanagement.NodeClient", "Create", nil, "Failure preparing request")
return
}
resp, err := client.CreateSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "servermanagement.NodeClient", "Create", resp, "Failure sending request")
return
}
result, err = client.CreateResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "servermanagement.NodeClient", "Create", resp, "Failure responding to request")
}
}()
return resultChan, errChan
}
// CreatePreparer prepares the Create request.
func (client NodeClient) CreatePreparer(resourceGroupName string, nodeName string, gatewayParameters NodeParameters, cancel <-chan struct{}) (*http.Request, error) {
pathParameters := map[string]interface{}{
"nodeName": autorest.Encode("path", nodeName),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
const APIVersion = "2016-07-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.ServerManagement/nodes/{nodeName}", pathParameters),
autorest.WithJSON(gatewayParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{Cancel: cancel})
}
// CreateSender sends the Create request. The method will close the
// http.Response Body if it receives an error.
func (client NodeClient) CreateSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client,
req,
azure.DoPollForAsynchronous(client.PollingDelay))
}
// CreateResponder handles the response to the Create request. The method always
// closes the http.Response Body.
func (client NodeClient) CreateResponder(resp *http.Response) (result NodeResource, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// Delete deletes a management node
//
// resourceGroupName is the resource group name uniquely identifies the
// resource group within the user subscriptionId. nodeName is the node name
// (256 characters maximum).
func (client NodeClient) Delete(resourceGroupName string, nodeName string) (result autorest.Response, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: resourceGroupName,
Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 3, Chain: nil},
{Target: "resourceGroupName", Name: validation.Pattern, Rule: `[a-zA-Z0-9]+`, Chain: nil}}},
{TargetValue: nodeName,
Constraints: []validation.Constraint{{Target: "nodeName", Name: validation.MaxLength, Rule: 256, Chain: nil},
{Target: "nodeName", Name: validation.MinLength, Rule: 1, Chain: nil},
{Target: "nodeName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9_.-]*$`, Chain: nil}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "servermanagement.NodeClient", "Delete")
}
req, err := client.DeletePreparer(resourceGroupName, nodeName)
if err != nil {
err = autorest.NewErrorWithError(err, "servermanagement.NodeClient", "Delete", nil, "Failure preparing request")
return
}
resp, err := client.DeleteSender(req)
if err != nil {
result.Response = resp
err = autorest.NewErrorWithError(err, "servermanagement.NodeClient", "Delete", resp, "Failure sending request")
return
}
result, err = client.DeleteResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "servermanagement.NodeClient", "Delete", resp, "Failure responding to request")
}
return
}
// DeletePreparer prepares the Delete request.
func (client NodeClient) DeletePreparer(resourceGroupName string, nodeName string) (*http.Request, error) {
pathParameters := map[string]interface{}{
"nodeName": autorest.Encode("path", nodeName),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
const APIVersion = "2016-07-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.ServerManagement/nodes/{nodeName}", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// DeleteSender sends the Delete request. The method will close the
// http.Response Body if it receives an error.
func (client NodeClient) DeleteSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// DeleteResponder handles the response to the Delete request. The method always
// closes the http.Response Body.
func (client NodeClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
autorest.ByClosing())
result.Response = resp
return
}
// Get gets a management node.
//
// resourceGroupName is the resource group name uniquely identifies the
// resource group within the user subscriptionId. nodeName is the node name
// (256 characters maximum).
func (client NodeClient) Get(resourceGroupName string, nodeName string) (result NodeResource, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: resourceGroupName,
Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 3, Chain: nil},
{Target: "resourceGroupName", Name: validation.Pattern, Rule: `[a-zA-Z0-9]+`, Chain: nil}}},
{TargetValue: nodeName,
Constraints: []validation.Constraint{{Target: "nodeName", Name: validation.MaxLength, Rule: 256, Chain: nil},
{Target: "nodeName", Name: validation.MinLength, Rule: 1, Chain: nil},
{Target: "nodeName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9_.-]*$`, Chain: nil}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "servermanagement.NodeClient", "Get")
}
req, err := client.GetPreparer(resourceGroupName, nodeName)
if err != nil {
err = autorest.NewErrorWithError(err, "servermanagement.NodeClient", "Get", nil, "Failure preparing request")
return
}
resp, err := client.GetSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "servermanagement.NodeClient", "Get", resp, "Failure sending request")
return
}
result, err = client.GetResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "servermanagement.NodeClient", "Get", resp, "Failure responding to request")
}
return
}
// GetPreparer prepares the Get request.
func (client NodeClient) GetPreparer(resourceGroupName string, nodeName string) (*http.Request, error) {
pathParameters := map[string]interface{}{
"nodeName": autorest.Encode("path", nodeName),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
const APIVersion = "2016-07-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.ServerManagement/nodes/{nodeName}", 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 NodeClient) GetSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// GetResponder handles the response to the Get request. The method always
// closes the http.Response Body.
func (client NodeClient) GetResponder(resp *http.Response) (result NodeResource, 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 nodes in a subscription.
func (client NodeClient) List() (result NodeResources, err error) {
req, err := client.ListPreparer()
if err != nil {
err = autorest.NewErrorWithError(err, "servermanagement.NodeClient", "List", nil, "Failure preparing request")
return
}
resp, err := client.ListSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "servermanagement.NodeClient", "List", resp, "Failure sending request")
return
}
result, err = client.ListResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "servermanagement.NodeClient", "List", resp, "Failure responding to request")
}
return
}
// ListPreparer prepares the List request.
func (client NodeClient) ListPreparer() (*http.Request, error) {
pathParameters := map[string]interface{}{
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
const APIVersion = "2016-07-01-preview"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.ServerManagement/nodes", 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 NodeClient) ListSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// ListResponder handles the response to the List request. The method always
// closes the http.Response Body.
func (client NodeClient) ListResponder(resp *http.Response) (result NodeResources, 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 NodeClient) ListNextResults(lastResults NodeResources) (result NodeResources, err error) {
req, err := lastResults.NodeResourcesPreparer()
if err != nil {
return result, autorest.NewErrorWithError(err, "servermanagement.NodeClient", "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, "servermanagement.NodeClient", "List", resp, "Failure sending next results request")
}
result, err = client.ListResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "servermanagement.NodeClient", "List", resp, "Failure responding to next results request")
}
return
}
// ListForResourceGroup lists nodes in a resource group.
//
// resourceGroupName is the resource group name uniquely identifies the
// resource group within the user subscriptionId.
func (client NodeClient) ListForResourceGroup(resourceGroupName string) (result NodeResources, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: resourceGroupName,
Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 3, Chain: nil},
{Target: "resourceGroupName", Name: validation.Pattern, Rule: `[a-zA-Z0-9]+`, Chain: nil}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "servermanagement.NodeClient", "ListForResourceGroup")
}
req, err := client.ListForResourceGroupPreparer(resourceGroupName)
if err != nil {
err = autorest.NewErrorWithError(err, "servermanagement.NodeClient", "ListForResourceGroup", nil, "Failure preparing request")
return
}
resp, err := client.ListForResourceGroupSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "servermanagement.NodeClient", "ListForResourceGroup", resp, "Failure sending request")
return
}
result, err = client.ListForResourceGroupResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "servermanagement.NodeClient", "ListForResourceGroup", resp, "Failure responding to request")
}
return
}
// ListForResourceGroupPreparer prepares the ListForResourceGroup request.
func (client NodeClient) ListForResourceGroupPreparer(resourceGroupName string) (*http.Request, error) {
pathParameters := map[string]interface{}{
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
const APIVersion = "2016-07-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.ServerManagement/nodes", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// ListForResourceGroupSender sends the ListForResourceGroup request. The method will close the
// http.Response Body if it receives an error.
func (client NodeClient) ListForResourceGroupSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// ListForResourceGroupResponder handles the response to the ListForResourceGroup request. The method always
// closes the http.Response Body.
func (client NodeClient) ListForResourceGroupResponder(resp *http.Response) (result NodeResources, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// ListForResourceGroupNextResults retrieves the next set of results, if any.
func (client NodeClient) ListForResourceGroupNextResults(lastResults NodeResources) (result NodeResources, err error) {
req, err := lastResults.NodeResourcesPreparer()
if err != nil {
return result, autorest.NewErrorWithError(err, "servermanagement.NodeClient", "ListForResourceGroup", nil, "Failure preparing next results request")
}
if req == nil {
return
}
resp, err := client.ListForResourceGroupSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "servermanagement.NodeClient", "ListForResourceGroup", resp, "Failure sending next results request")
}
result, err = client.ListForResourceGroupResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "servermanagement.NodeClient", "ListForResourceGroup", resp, "Failure responding to next results request")
}
return
}
// Update updates a management node. 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.
//
// resourceGroupName is the resource group name uniquely identifies the
// resource group within the user subscriptionId. nodeName is the node name
// (256 characters maximum). nodeParameters is parameters supplied to the
// CreateOrUpdate operation.
func (client NodeClient) Update(resourceGroupName string, nodeName string, nodeParameters NodeParameters, cancel <-chan struct{}) (<-chan NodeResource, <-chan error) {
resultChan := make(chan NodeResource, 1)
errChan := make(chan error, 1)
if err := validation.Validate([]validation.Validation{
{TargetValue: resourceGroupName,
Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 3, Chain: nil},
{Target: "resourceGroupName", Name: validation.Pattern, Rule: `[a-zA-Z0-9]+`, Chain: nil}}},
{TargetValue: nodeName,
Constraints: []validation.Constraint{{Target: "nodeName", Name: validation.MaxLength, Rule: 256, Chain: nil},
{Target: "nodeName", Name: validation.MinLength, Rule: 1, Chain: nil},
{Target: "nodeName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9_.-]*$`, Chain: nil}}}}); err != nil {
errChan <- validation.NewErrorWithValidationError(err, "servermanagement.NodeClient", "Update")
close(errChan)
close(resultChan)
return resultChan, errChan
}
go func() {
var err error
var result NodeResource
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.UpdatePreparer(resourceGroupName, nodeName, nodeParameters, cancel)
if err != nil {
err = autorest.NewErrorWithError(err, "servermanagement.NodeClient", "Update", nil, "Failure preparing request")
return
}
resp, err := client.UpdateSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "servermanagement.NodeClient", "Update", resp, "Failure sending request")
return
}
result, err = client.UpdateResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "servermanagement.NodeClient", "Update", resp, "Failure responding to request")
}
}()
return resultChan, errChan
}
// UpdatePreparer prepares the Update request.
func (client NodeClient) UpdatePreparer(resourceGroupName string, nodeName string, nodeParameters NodeParameters, cancel <-chan struct{}) (*http.Request, error) {
pathParameters := map[string]interface{}{
"nodeName": autorest.Encode("path", nodeName),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
const APIVersion = "2016-07-01-preview"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsJSON(),
autorest.AsPatch(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServerManagement/nodes/{nodeName}", pathParameters),
autorest.WithJSON(nodeParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{Cancel: cancel})
}
// UpdateSender sends the Update request. The method will close the
// http.Response Body if it receives an error.
func (client NodeClient) UpdateSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client,
req,
azure.DoPollForAsynchronous(client.PollingDelay))
}
// UpdateResponder handles the response to the Update request. The method always
// closes the http.Response Body.
func (client NodeClient) UpdateResponder(resp *http.Response) (result NodeResource, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
+693
View File
@@ -0,0 +1,693 @@
package servermanagement
// 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.
//
// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
import (
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/go-autorest/autorest/validation"
"net/http"
)
// PowerShellClient is the rEST API for Azure Server Management Service.
type PowerShellClient struct {
ManagementClient
}
// NewPowerShellClient creates an instance of the PowerShellClient client.
func NewPowerShellClient(subscriptionID string) PowerShellClient {
return NewPowerShellClientWithBaseURI(DefaultBaseURI, subscriptionID)
}
// NewPowerShellClientWithBaseURI creates an instance of the PowerShellClient
// client.
func NewPowerShellClientWithBaseURI(baseURI string, subscriptionID string) PowerShellClient {
return PowerShellClient{NewWithBaseURI(baseURI, subscriptionID)}
}
// CancelCommand cancels a PowerShell command. 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.
//
// resourceGroupName is the resource group name uniquely identifies the
// resource group within the user subscriptionId. nodeName is the node name
// (256 characters maximum). session is the sessionId from the user. pssession
// is the PowerShell sessionId from the user.
func (client PowerShellClient) CancelCommand(resourceGroupName string, nodeName string, session string, pssession string, cancel <-chan struct{}) (<-chan PowerShellCommandResults, <-chan error) {
resultChan := make(chan PowerShellCommandResults, 1)
errChan := make(chan error, 1)
if err := validation.Validate([]validation.Validation{
{TargetValue: resourceGroupName,
Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 3, Chain: nil},
{Target: "resourceGroupName", Name: validation.Pattern, Rule: `[a-zA-Z0-9]+`, Chain: nil}}},
{TargetValue: nodeName,
Constraints: []validation.Constraint{{Target: "nodeName", Name: validation.MaxLength, Rule: 256, Chain: nil},
{Target: "nodeName", Name: validation.MinLength, Rule: 1, Chain: nil},
{Target: "nodeName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9_.-]*$`, Chain: nil}}}}); err != nil {
errChan <- validation.NewErrorWithValidationError(err, "servermanagement.PowerShellClient", "CancelCommand")
close(errChan)
close(resultChan)
return resultChan, errChan
}
go func() {
var err error
var result PowerShellCommandResults
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.CancelCommandPreparer(resourceGroupName, nodeName, session, pssession, cancel)
if err != nil {
err = autorest.NewErrorWithError(err, "servermanagement.PowerShellClient", "CancelCommand", nil, "Failure preparing request")
return
}
resp, err := client.CancelCommandSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "servermanagement.PowerShellClient", "CancelCommand", resp, "Failure sending request")
return
}
result, err = client.CancelCommandResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "servermanagement.PowerShellClient", "CancelCommand", resp, "Failure responding to request")
}
}()
return resultChan, errChan
}
// CancelCommandPreparer prepares the CancelCommand request.
func (client PowerShellClient) CancelCommandPreparer(resourceGroupName string, nodeName string, session string, pssession string, cancel <-chan struct{}) (*http.Request, error) {
pathParameters := map[string]interface{}{
"nodeName": autorest.Encode("path", nodeName),
"pssession": autorest.Encode("path", pssession),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"session": autorest.Encode("path", session),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
const APIVersion = "2016-07-01-preview"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsPost(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServerManagement/nodes/{nodeName}/sessions/{session}/features/powerShellConsole/pssessions/{pssession}/cancel", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{Cancel: cancel})
}
// CancelCommandSender sends the CancelCommand request. The method will close the
// http.Response Body if it receives an error.
func (client PowerShellClient) CancelCommandSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client,
req,
azure.DoPollForAsynchronous(client.PollingDelay))
}
// CancelCommandResponder handles the response to the CancelCommand request. The method always
// closes the http.Response Body.
func (client PowerShellClient) CancelCommandResponder(resp *http.Response) (result PowerShellCommandResults, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// CreateSession creates a PowerShell session. 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.
//
// resourceGroupName is the resource group name uniquely identifies the
// resource group within the user subscriptionId. nodeName is the node name
// (256 characters maximum). session is the sessionId from the user. pssession
// is the PowerShell sessionId from the user.
func (client PowerShellClient) CreateSession(resourceGroupName string, nodeName string, session string, pssession string, cancel <-chan struct{}) (<-chan PowerShellSessionResource, <-chan error) {
resultChan := make(chan PowerShellSessionResource, 1)
errChan := make(chan error, 1)
if err := validation.Validate([]validation.Validation{
{TargetValue: resourceGroupName,
Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 3, Chain: nil},
{Target: "resourceGroupName", Name: validation.Pattern, Rule: `[a-zA-Z0-9]+`, Chain: nil}}},
{TargetValue: nodeName,
Constraints: []validation.Constraint{{Target: "nodeName", Name: validation.MaxLength, Rule: 256, Chain: nil},
{Target: "nodeName", Name: validation.MinLength, Rule: 1, Chain: nil},
{Target: "nodeName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9_.-]*$`, Chain: nil}}}}); err != nil {
errChan <- validation.NewErrorWithValidationError(err, "servermanagement.PowerShellClient", "CreateSession")
close(errChan)
close(resultChan)
return resultChan, errChan
}
go func() {
var err error
var result PowerShellSessionResource
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.CreateSessionPreparer(resourceGroupName, nodeName, session, pssession, cancel)
if err != nil {
err = autorest.NewErrorWithError(err, "servermanagement.PowerShellClient", "CreateSession", nil, "Failure preparing request")
return
}
resp, err := client.CreateSessionSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "servermanagement.PowerShellClient", "CreateSession", resp, "Failure sending request")
return
}
result, err = client.CreateSessionResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "servermanagement.PowerShellClient", "CreateSession", resp, "Failure responding to request")
}
}()
return resultChan, errChan
}
// CreateSessionPreparer prepares the CreateSession request.
func (client PowerShellClient) CreateSessionPreparer(resourceGroupName string, nodeName string, session string, pssession string, cancel <-chan struct{}) (*http.Request, error) {
pathParameters := map[string]interface{}{
"nodeName": autorest.Encode("path", nodeName),
"pssession": autorest.Encode("path", pssession),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"session": autorest.Encode("path", session),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
const APIVersion = "2016-07-01-preview"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsPut(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServerManagement/nodes/{nodeName}/sessions/{session}/features/powerShellConsole/pssessions/{pssession}", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{Cancel: cancel})
}
// CreateSessionSender sends the CreateSession request. The method will close the
// http.Response Body if it receives an error.
func (client PowerShellClient) CreateSessionSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client,
req,
azure.DoPollForAsynchronous(client.PollingDelay))
}
// CreateSessionResponder handles the response to the CreateSession request. The method always
// closes the http.Response Body.
func (client PowerShellClient) CreateSessionResponder(resp *http.Response) (result PowerShellSessionResource, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// GetCommandStatus gets the status of a command.
//
// resourceGroupName is the resource group name uniquely identifies the
// resource group within the user subscriptionId. nodeName is the node name
// (256 characters maximum). session is the sessionId from the user. pssession
// is the PowerShell sessionId from the user. expand is gets current output
// from an ongoing call.
func (client PowerShellClient) GetCommandStatus(resourceGroupName string, nodeName string, session string, pssession string, expand PowerShellExpandOption) (result PowerShellCommandStatus, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: resourceGroupName,
Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 3, Chain: nil},
{Target: "resourceGroupName", Name: validation.Pattern, Rule: `[a-zA-Z0-9]+`, Chain: nil}}},
{TargetValue: nodeName,
Constraints: []validation.Constraint{{Target: "nodeName", Name: validation.MaxLength, Rule: 256, Chain: nil},
{Target: "nodeName", Name: validation.MinLength, Rule: 1, Chain: nil},
{Target: "nodeName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9_.-]*$`, Chain: nil}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "servermanagement.PowerShellClient", "GetCommandStatus")
}
req, err := client.GetCommandStatusPreparer(resourceGroupName, nodeName, session, pssession, expand)
if err != nil {
err = autorest.NewErrorWithError(err, "servermanagement.PowerShellClient", "GetCommandStatus", nil, "Failure preparing request")
return
}
resp, err := client.GetCommandStatusSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "servermanagement.PowerShellClient", "GetCommandStatus", resp, "Failure sending request")
return
}
result, err = client.GetCommandStatusResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "servermanagement.PowerShellClient", "GetCommandStatus", resp, "Failure responding to request")
}
return
}
// GetCommandStatusPreparer prepares the GetCommandStatus request.
func (client PowerShellClient) GetCommandStatusPreparer(resourceGroupName string, nodeName string, session string, pssession string, expand PowerShellExpandOption) (*http.Request, error) {
pathParameters := map[string]interface{}{
"nodeName": autorest.Encode("path", nodeName),
"pssession": autorest.Encode("path", pssession),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"session": autorest.Encode("path", session),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
const APIVersion = "2016-07-01-preview"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
if len(string(expand)) > 0 {
queryParameters["$expand"] = autorest.Encode("query", expand)
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServerManagement/nodes/{nodeName}/sessions/{session}/features/powerShellConsole/pssessions/{pssession}", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// GetCommandStatusSender sends the GetCommandStatus request. The method will close the
// http.Response Body if it receives an error.
func (client PowerShellClient) GetCommandStatusSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// GetCommandStatusResponder handles the response to the GetCommandStatus request. The method always
// closes the http.Response Body.
func (client PowerShellClient) GetCommandStatusResponder(resp *http.Response) (result PowerShellCommandStatus, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// InvokeCommand creates a PowerShell script and invokes it. 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.
//
// resourceGroupName is the resource group name uniquely identifies the
// resource group within the user subscriptionId. nodeName is the node name
// (256 characters maximum). session is the sessionId from the user. pssession
// is the PowerShell sessionId from the user. powerShellCommandParameters is
// parameters supplied to the Invoke PowerShell Command operation.
func (client PowerShellClient) InvokeCommand(resourceGroupName string, nodeName string, session string, pssession string, powerShellCommandParameters PowerShellCommandParameters, cancel <-chan struct{}) (<-chan PowerShellCommandResults, <-chan error) {
resultChan := make(chan PowerShellCommandResults, 1)
errChan := make(chan error, 1)
if err := validation.Validate([]validation.Validation{
{TargetValue: resourceGroupName,
Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 3, Chain: nil},
{Target: "resourceGroupName", Name: validation.Pattern, Rule: `[a-zA-Z0-9]+`, Chain: nil}}},
{TargetValue: nodeName,
Constraints: []validation.Constraint{{Target: "nodeName", Name: validation.MaxLength, Rule: 256, Chain: nil},
{Target: "nodeName", Name: validation.MinLength, Rule: 1, Chain: nil},
{Target: "nodeName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9_.-]*$`, Chain: nil}}}}); err != nil {
errChan <- validation.NewErrorWithValidationError(err, "servermanagement.PowerShellClient", "InvokeCommand")
close(errChan)
close(resultChan)
return resultChan, errChan
}
go func() {
var err error
var result PowerShellCommandResults
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.InvokeCommandPreparer(resourceGroupName, nodeName, session, pssession, powerShellCommandParameters, cancel)
if err != nil {
err = autorest.NewErrorWithError(err, "servermanagement.PowerShellClient", "InvokeCommand", nil, "Failure preparing request")
return
}
resp, err := client.InvokeCommandSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "servermanagement.PowerShellClient", "InvokeCommand", resp, "Failure sending request")
return
}
result, err = client.InvokeCommandResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "servermanagement.PowerShellClient", "InvokeCommand", resp, "Failure responding to request")
}
}()
return resultChan, errChan
}
// InvokeCommandPreparer prepares the InvokeCommand request.
func (client PowerShellClient) InvokeCommandPreparer(resourceGroupName string, nodeName string, session string, pssession string, powerShellCommandParameters PowerShellCommandParameters, cancel <-chan struct{}) (*http.Request, error) {
pathParameters := map[string]interface{}{
"nodeName": autorest.Encode("path", nodeName),
"pssession": autorest.Encode("path", pssession),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"session": autorest.Encode("path", session),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
const APIVersion = "2016-07-01-preview"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsJSON(),
autorest.AsPost(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServerManagement/nodes/{nodeName}/sessions/{session}/features/powerShellConsole/pssessions/{pssession}/invokeCommand", pathParameters),
autorest.WithJSON(powerShellCommandParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{Cancel: cancel})
}
// InvokeCommandSender sends the InvokeCommand request. The method will close the
// http.Response Body if it receives an error.
func (client PowerShellClient) InvokeCommandSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client,
req,
azure.DoPollForAsynchronous(client.PollingDelay))
}
// InvokeCommandResponder handles the response to the InvokeCommand request. The method always
// closes the http.Response Body.
func (client PowerShellClient) InvokeCommandResponder(resp *http.Response) (result PowerShellCommandResults, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// ListSession gets a list of the active sessions.
//
// resourceGroupName is the resource group name uniquely identifies the
// resource group within the user subscriptionId. nodeName is the node name
// (256 characters maximum). session is the sessionId from the user.
func (client PowerShellClient) ListSession(resourceGroupName string, nodeName string, session string) (result PowerShellSessionResources, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: resourceGroupName,
Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 3, Chain: nil},
{Target: "resourceGroupName", Name: validation.Pattern, Rule: `[a-zA-Z0-9]+`, Chain: nil}}},
{TargetValue: nodeName,
Constraints: []validation.Constraint{{Target: "nodeName", Name: validation.MaxLength, Rule: 256, Chain: nil},
{Target: "nodeName", Name: validation.MinLength, Rule: 1, Chain: nil},
{Target: "nodeName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9_.-]*$`, Chain: nil}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "servermanagement.PowerShellClient", "ListSession")
}
req, err := client.ListSessionPreparer(resourceGroupName, nodeName, session)
if err != nil {
err = autorest.NewErrorWithError(err, "servermanagement.PowerShellClient", "ListSession", nil, "Failure preparing request")
return
}
resp, err := client.ListSessionSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "servermanagement.PowerShellClient", "ListSession", resp, "Failure sending request")
return
}
result, err = client.ListSessionResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "servermanagement.PowerShellClient", "ListSession", resp, "Failure responding to request")
}
return
}
// ListSessionPreparer prepares the ListSession request.
func (client PowerShellClient) ListSessionPreparer(resourceGroupName string, nodeName string, session string) (*http.Request, error) {
pathParameters := map[string]interface{}{
"nodeName": autorest.Encode("path", nodeName),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"session": autorest.Encode("path", session),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
const APIVersion = "2016-07-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.ServerManagement/nodes/{nodeName}/sessions/{session}/features/powerShellConsole/pssessions", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// ListSessionSender sends the ListSession request. The method will close the
// http.Response Body if it receives an error.
func (client PowerShellClient) ListSessionSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// ListSessionResponder handles the response to the ListSession request. The method always
// closes the http.Response Body.
func (client PowerShellClient) ListSessionResponder(resp *http.Response) (result PowerShellSessionResources, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// TabCompletion gets tab completion values for a command.
//
// resourceGroupName is the resource group name uniquely identifies the
// resource group within the user subscriptionId. nodeName is the node name
// (256 characters maximum). session is the sessionId from the user. pssession
// is the PowerShell sessionId from the user. powerShellTabCompletionParamters
// is parameters supplied to the tab completion call.
func (client PowerShellClient) TabCompletion(resourceGroupName string, nodeName string, session string, pssession string, powerShellTabCompletionParamters PowerShellTabCompletionParameters) (result PowerShellTabCompletionResults, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: resourceGroupName,
Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 3, Chain: nil},
{Target: "resourceGroupName", Name: validation.Pattern, Rule: `[a-zA-Z0-9]+`, Chain: nil}}},
{TargetValue: nodeName,
Constraints: []validation.Constraint{{Target: "nodeName", Name: validation.MaxLength, Rule: 256, Chain: nil},
{Target: "nodeName", Name: validation.MinLength, Rule: 1, Chain: nil},
{Target: "nodeName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9_.-]*$`, Chain: nil}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "servermanagement.PowerShellClient", "TabCompletion")
}
req, err := client.TabCompletionPreparer(resourceGroupName, nodeName, session, pssession, powerShellTabCompletionParamters)
if err != nil {
err = autorest.NewErrorWithError(err, "servermanagement.PowerShellClient", "TabCompletion", nil, "Failure preparing request")
return
}
resp, err := client.TabCompletionSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "servermanagement.PowerShellClient", "TabCompletion", resp, "Failure sending request")
return
}
result, err = client.TabCompletionResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "servermanagement.PowerShellClient", "TabCompletion", resp, "Failure responding to request")
}
return
}
// TabCompletionPreparer prepares the TabCompletion request.
func (client PowerShellClient) TabCompletionPreparer(resourceGroupName string, nodeName string, session string, pssession string, powerShellTabCompletionParamters PowerShellTabCompletionParameters) (*http.Request, error) {
pathParameters := map[string]interface{}{
"nodeName": autorest.Encode("path", nodeName),
"pssession": autorest.Encode("path", pssession),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"session": autorest.Encode("path", session),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
const APIVersion = "2016-07-01-preview"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsJSON(),
autorest.AsPost(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServerManagement/nodes/{nodeName}/sessions/{session}/features/powerShellConsole/pssessions/{pssession}/tab", pathParameters),
autorest.WithJSON(powerShellTabCompletionParamters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// TabCompletionSender sends the TabCompletion request. The method will close the
// http.Response Body if it receives an error.
func (client PowerShellClient) TabCompletionSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// TabCompletionResponder handles the response to the TabCompletion request. The method always
// closes the http.Response Body.
func (client PowerShellClient) TabCompletionResponder(resp *http.Response) (result PowerShellTabCompletionResults, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// UpdateCommand updates a running PowerShell command with more data. 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.
//
// resourceGroupName is the resource group name uniquely identifies the
// resource group within the user subscriptionId. nodeName is the node name
// (256 characters maximum). session is the sessionId from the user. pssession
// is the PowerShell sessionId from the user.
func (client PowerShellClient) UpdateCommand(resourceGroupName string, nodeName string, session string, pssession string, cancel <-chan struct{}) (<-chan PowerShellCommandResults, <-chan error) {
resultChan := make(chan PowerShellCommandResults, 1)
errChan := make(chan error, 1)
if err := validation.Validate([]validation.Validation{
{TargetValue: resourceGroupName,
Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 3, Chain: nil},
{Target: "resourceGroupName", Name: validation.Pattern, Rule: `[a-zA-Z0-9]+`, Chain: nil}}},
{TargetValue: nodeName,
Constraints: []validation.Constraint{{Target: "nodeName", Name: validation.MaxLength, Rule: 256, Chain: nil},
{Target: "nodeName", Name: validation.MinLength, Rule: 1, Chain: nil},
{Target: "nodeName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9_.-]*$`, Chain: nil}}}}); err != nil {
errChan <- validation.NewErrorWithValidationError(err, "servermanagement.PowerShellClient", "UpdateCommand")
close(errChan)
close(resultChan)
return resultChan, errChan
}
go func() {
var err error
var result PowerShellCommandResults
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.UpdateCommandPreparer(resourceGroupName, nodeName, session, pssession, cancel)
if err != nil {
err = autorest.NewErrorWithError(err, "servermanagement.PowerShellClient", "UpdateCommand", nil, "Failure preparing request")
return
}
resp, err := client.UpdateCommandSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "servermanagement.PowerShellClient", "UpdateCommand", resp, "Failure sending request")
return
}
result, err = client.UpdateCommandResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "servermanagement.PowerShellClient", "UpdateCommand", resp, "Failure responding to request")
}
}()
return resultChan, errChan
}
// UpdateCommandPreparer prepares the UpdateCommand request.
func (client PowerShellClient) UpdateCommandPreparer(resourceGroupName string, nodeName string, session string, pssession string, cancel <-chan struct{}) (*http.Request, error) {
pathParameters := map[string]interface{}{
"nodeName": autorest.Encode("path", nodeName),
"pssession": autorest.Encode("path", pssession),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"session": autorest.Encode("path", session),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
const APIVersion = "2016-07-01-preview"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsPatch(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServerManagement/nodes/{nodeName}/sessions/{session}/features/powerShellConsole/pssessions/{pssession}", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{Cancel: cancel})
}
// UpdateCommandSender sends the UpdateCommand request. The method will close the
// http.Response Body if it receives an error.
func (client PowerShellClient) UpdateCommandSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client,
req,
azure.DoPollForAsynchronous(client.PollingDelay))
}
// UpdateCommandResponder handles the response to the UpdateCommand request. The method always
// closes the http.Response Body.
func (client PowerShellClient) UpdateCommandResponder(resp *http.Response) (result PowerShellCommandResults, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
+298
View File
@@ -0,0 +1,298 @@
package servermanagement
// 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.
//
// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
import (
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/go-autorest/autorest/validation"
"net/http"
)
// SessionClient is the rEST API for Azure Server Management Service.
type SessionClient struct {
ManagementClient
}
// NewSessionClient creates an instance of the SessionClient client.
func NewSessionClient(subscriptionID string) SessionClient {
return NewSessionClientWithBaseURI(DefaultBaseURI, subscriptionID)
}
// NewSessionClientWithBaseURI creates an instance of the SessionClient client.
func NewSessionClientWithBaseURI(baseURI string, subscriptionID string) SessionClient {
return SessionClient{NewWithBaseURI(baseURI, subscriptionID)}
}
// Create creates a session for a node. 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.
//
// resourceGroupName is the resource group name uniquely identifies the
// resource group within the user subscriptionId. nodeName is the node name
// (256 characters maximum). session is the sessionId from the user.
// sessionParameters is parameters supplied to the CreateOrUpdate operation.
func (client SessionClient) Create(resourceGroupName string, nodeName string, session string, sessionParameters SessionParameters, cancel <-chan struct{}) (<-chan SessionResource, <-chan error) {
resultChan := make(chan SessionResource, 1)
errChan := make(chan error, 1)
if err := validation.Validate([]validation.Validation{
{TargetValue: resourceGroupName,
Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 3, Chain: nil},
{Target: "resourceGroupName", Name: validation.Pattern, Rule: `[a-zA-Z0-9]+`, Chain: nil}}},
{TargetValue: nodeName,
Constraints: []validation.Constraint{{Target: "nodeName", Name: validation.MaxLength, Rule: 256, Chain: nil},
{Target: "nodeName", Name: validation.MinLength, Rule: 1, Chain: nil},
{Target: "nodeName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9_.-]*$`, Chain: nil}}}}); err != nil {
errChan <- validation.NewErrorWithValidationError(err, "servermanagement.SessionClient", "Create")
close(errChan)
close(resultChan)
return resultChan, errChan
}
go func() {
var err error
var result SessionResource
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.CreatePreparer(resourceGroupName, nodeName, session, sessionParameters, cancel)
if err != nil {
err = autorest.NewErrorWithError(err, "servermanagement.SessionClient", "Create", nil, "Failure preparing request")
return
}
resp, err := client.CreateSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "servermanagement.SessionClient", "Create", resp, "Failure sending request")
return
}
result, err = client.CreateResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "servermanagement.SessionClient", "Create", resp, "Failure responding to request")
}
}()
return resultChan, errChan
}
// CreatePreparer prepares the Create request.
func (client SessionClient) CreatePreparer(resourceGroupName string, nodeName string, session string, sessionParameters SessionParameters, cancel <-chan struct{}) (*http.Request, error) {
pathParameters := map[string]interface{}{
"nodeName": autorest.Encode("path", nodeName),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"session": autorest.Encode("path", session),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
const APIVersion = "2016-07-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.ServerManagement/nodes/{nodeName}/sessions/{session}", pathParameters),
autorest.WithJSON(sessionParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{Cancel: cancel})
}
// CreateSender sends the Create request. The method will close the
// http.Response Body if it receives an error.
func (client SessionClient) CreateSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client,
req,
azure.DoPollForAsynchronous(client.PollingDelay))
}
// CreateResponder handles the response to the Create request. The method always
// closes the http.Response Body.
func (client SessionClient) CreateResponder(resp *http.Response) (result SessionResource, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// Delete deletes a session for a node.
//
// resourceGroupName is the resource group name uniquely identifies the
// resource group within the user subscriptionId. nodeName is the node name
// (256 characters maximum). session is the sessionId from the user.
func (client SessionClient) Delete(resourceGroupName string, nodeName string, session string) (result autorest.Response, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: resourceGroupName,
Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 3, Chain: nil},
{Target: "resourceGroupName", Name: validation.Pattern, Rule: `[a-zA-Z0-9]+`, Chain: nil}}},
{TargetValue: nodeName,
Constraints: []validation.Constraint{{Target: "nodeName", Name: validation.MaxLength, Rule: 256, Chain: nil},
{Target: "nodeName", Name: validation.MinLength, Rule: 1, Chain: nil},
{Target: "nodeName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9_.-]*$`, Chain: nil}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "servermanagement.SessionClient", "Delete")
}
req, err := client.DeletePreparer(resourceGroupName, nodeName, session)
if err != nil {
err = autorest.NewErrorWithError(err, "servermanagement.SessionClient", "Delete", nil, "Failure preparing request")
return
}
resp, err := client.DeleteSender(req)
if err != nil {
result.Response = resp
err = autorest.NewErrorWithError(err, "servermanagement.SessionClient", "Delete", resp, "Failure sending request")
return
}
result, err = client.DeleteResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "servermanagement.SessionClient", "Delete", resp, "Failure responding to request")
}
return
}
// DeletePreparer prepares the Delete request.
func (client SessionClient) DeletePreparer(resourceGroupName string, nodeName string, session string) (*http.Request, error) {
pathParameters := map[string]interface{}{
"nodeName": autorest.Encode("path", nodeName),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"session": autorest.Encode("path", session),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
const APIVersion = "2016-07-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.ServerManagement/nodes/{nodeName}/sessions/{session}", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// DeleteSender sends the Delete request. The method will close the
// http.Response Body if it receives an error.
func (client SessionClient) DeleteSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// DeleteResponder handles the response to the Delete request. The method always
// closes the http.Response Body.
func (client SessionClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
autorest.ByClosing())
result.Response = resp
return
}
// Get gets a session for a node.
//
// resourceGroupName is the resource group name uniquely identifies the
// resource group within the user subscriptionId. nodeName is the node name
// (256 characters maximum). session is the sessionId from the user.
func (client SessionClient) Get(resourceGroupName string, nodeName string, session string) (result SessionResource, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: resourceGroupName,
Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 3, Chain: nil},
{Target: "resourceGroupName", Name: validation.Pattern, Rule: `[a-zA-Z0-9]+`, Chain: nil}}},
{TargetValue: nodeName,
Constraints: []validation.Constraint{{Target: "nodeName", Name: validation.MaxLength, Rule: 256, Chain: nil},
{Target: "nodeName", Name: validation.MinLength, Rule: 1, Chain: nil},
{Target: "nodeName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9_.-]*$`, Chain: nil}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "servermanagement.SessionClient", "Get")
}
req, err := client.GetPreparer(resourceGroupName, nodeName, session)
if err != nil {
err = autorest.NewErrorWithError(err, "servermanagement.SessionClient", "Get", nil, "Failure preparing request")
return
}
resp, err := client.GetSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "servermanagement.SessionClient", "Get", resp, "Failure sending request")
return
}
result, err = client.GetResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "servermanagement.SessionClient", "Get", resp, "Failure responding to request")
}
return
}
// GetPreparer prepares the Get request.
func (client SessionClient) GetPreparer(resourceGroupName string, nodeName string, session string) (*http.Request, error) {
pathParameters := map[string]interface{}{
"nodeName": autorest.Encode("path", nodeName),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"session": autorest.Encode("path", session),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
const APIVersion = "2016-07-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.ServerManagement/nodes/{nodeName}/sessions/{session}", 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 SessionClient) GetSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// GetResponder handles the response to the Get request. The method always
// closes the http.Response Body.
func (client SessionClient) GetResponder(resp *http.Response) (result SessionResource, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
+29
View File
@@ -0,0 +1,29 @@
package servermanagement
// 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.
//
// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// UserAgent returns the UserAgent string to use when sending http.Requests.
func UserAgent() string {
return "Azure-SDK-For-Go/v10.1.0-beta arm-servermanagement/2016-07-01-preview"
}
// Version returns the semantic version (see http://semver.org) of the client.
func Version() string {
return "v10.1.0-beta"
}