From 47e2e0ad1f47f1407a09425c9a6f04487ede6883 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Mon, 26 Mar 2018 18:53:35 +0000 Subject: [PATCH] Generated from 6d72ca973e5de84066a6a22502c9db18c11a112d Adding ListKeys support for Account --- .../mgmt/2015-10-31/automation/keys.go | 113 ++++++++++++++++++ .../mgmt/2015-10-31/automation/models.go | 45 +++++++ .../2017-05-15-preview/automation/keys.go | 113 ++++++++++++++++++ .../2017-05-15-preview/automation/models.go | 45 +++++++ 4 files changed, 316 insertions(+) create mode 100644 services/automation/mgmt/2015-10-31/automation/keys.go create mode 100644 services/automation/mgmt/2017-05-15-preview/automation/keys.go diff --git a/services/automation/mgmt/2015-10-31/automation/keys.go b/services/automation/mgmt/2015-10-31/automation/keys.go new file mode 100644 index 000000000000..88018fecd17a --- /dev/null +++ b/services/automation/mgmt/2015-10-31/automation/keys.go @@ -0,0 +1,113 @@ +package automation + +// 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. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// KeysClient is the automation Client +type KeysClient struct { + BaseClient +} + +// NewKeysClient creates an instance of the KeysClient client. +func NewKeysClient(subscriptionID string, resourceGroupName string) KeysClient { + return NewKeysClientWithBaseURI(DefaultBaseURI, subscriptionID, resourceGroupName) +} + +// NewKeysClientWithBaseURI creates an instance of the KeysClient client. +func NewKeysClientWithBaseURI(baseURI string, subscriptionID string, resourceGroupName string) KeysClient { + return KeysClient{NewWithBaseURI(baseURI, subscriptionID, resourceGroupName)} +} + +// ListByAutomationAccount retrieve the automation keys for an account. +// +// automationAccountName is the automation account name. +func (client KeysClient) ListByAutomationAccount(ctx context.Context, automationAccountName string) (result KeyListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.ResourceGroupName, + Constraints: []validation.Constraint{{Target: "client.ResourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.KeysClient", "ListByAutomationAccount", err.Error()) + } + + req, err := client.ListByAutomationAccountPreparer(ctx, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.KeysClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.KeysClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.KeysClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client KeysClient) ListByAutomationAccountPreparer(ctx context.Context, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/listKeys", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByAutomationAccountSender sends the ListByAutomationAccount request. The method will close the +// http.Response Body if it receives an error. +func (client KeysClient) ListByAutomationAccountSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByAutomationAccountResponder handles the response to the ListByAutomationAccount request. The method always +// closes the http.Response Body. +func (client KeysClient) ListByAutomationAccountResponder(resp *http.Response) (result KeyListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/automation/mgmt/2015-10-31/automation/models.go b/services/automation/mgmt/2015-10-31/automation/models.go index 2b1c94dcf7db..11b967f1df1a 100644 --- a/services/automation/mgmt/2015-10-31/automation/models.go +++ b/services/automation/mgmt/2015-10-31/automation/models.go @@ -291,6 +291,34 @@ func PossibleJobStreamTypeValues() []JobStreamType { return []JobStreamType{Any, Debug, Error, Output, Progress, Verbose, Warning} } +// KeyName enumerates the values for key name. +type KeyName string + +const ( + // KeyNamePrimary ... + KeyNamePrimary KeyName = "primary" + // KeyNameSecondary ... + KeyNameSecondary KeyName = "secondary" +) + +// PossibleKeyNameValues returns an array of possible values for the KeyName const type. +func PossibleKeyNameValues() []KeyName { + return []KeyName{KeyNamePrimary, KeyNameSecondary} +} + +// KeyPermissions enumerates the values for key permissions. +type KeyPermissions string + +const ( + // Full ... + Full KeyPermissions = "Full" +) + +// PossibleKeyPermissionsValues returns an array of possible values for the KeyPermissions const type. +func PossibleKeyPermissionsValues() []KeyPermissions { + return []KeyPermissions{Full} +} + // ModuleProvisioningState enumerates the values for module provisioning state. type ModuleProvisioningState string @@ -4721,6 +4749,23 @@ func (jsp JobStreamProperties) MarshalJSON() ([]byte, error) { return json.Marshal(objectMap) } +// Key automation key which is used to register a DSC Node +type Key struct { + // KeyName - Automation key name. Possible values include: 'KeyNamePrimary', 'KeyNameSecondary' + KeyName KeyName `json:"keyName,omitempty"` + // Permissions - Automation key permissions. Possible values include: 'Full' + Permissions KeyPermissions `json:"permissions,omitempty"` + // Value - Value of the Automation Key used for registration. + Value *string `json:"value,omitempty"` +} + +// KeyListResult ... +type KeyListResult struct { + autorest.Response `json:"-"` + // Value - Lists the automation keys. + Value *[]Key `json:"value,omitempty"` +} + // LinkedWorkspace definition of the linked workspace. type LinkedWorkspace struct { autorest.Response `json:"-"` diff --git a/services/automation/mgmt/2017-05-15-preview/automation/keys.go b/services/automation/mgmt/2017-05-15-preview/automation/keys.go new file mode 100644 index 000000000000..8f3d56a5506b --- /dev/null +++ b/services/automation/mgmt/2017-05-15-preview/automation/keys.go @@ -0,0 +1,113 @@ +package automation + +// 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. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// KeysClient is the automation Client +type KeysClient struct { + BaseClient +} + +// NewKeysClient creates an instance of the KeysClient client. +func NewKeysClient(subscriptionID string, resourceGroupName string, clientRequestID string, automationAccountName string) KeysClient { + return NewKeysClientWithBaseURI(DefaultBaseURI, subscriptionID, resourceGroupName, clientRequestID, automationAccountName) +} + +// NewKeysClientWithBaseURI creates an instance of the KeysClient client. +func NewKeysClientWithBaseURI(baseURI string, subscriptionID string, resourceGroupName string, clientRequestID string, automationAccountName string) KeysClient { + return KeysClient{NewWithBaseURI(baseURI, subscriptionID, resourceGroupName, clientRequestID, automationAccountName)} +} + +// ListByAutomationAccount retrieve the automation keys for an account. +// +// automationAccountName is the automation account name. +func (client KeysClient) ListByAutomationAccount(ctx context.Context, automationAccountName string) (result KeyListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.ResourceGroupName, + Constraints: []validation.Constraint{{Target: "client.ResourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.KeysClient", "ListByAutomationAccount", err.Error()) + } + + req, err := client.ListByAutomationAccountPreparer(ctx, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.KeysClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.KeysClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.KeysClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client KeysClient) ListByAutomationAccountPreparer(ctx context.Context, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/listKeys", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByAutomationAccountSender sends the ListByAutomationAccount request. The method will close the +// http.Response Body if it receives an error. +func (client KeysClient) ListByAutomationAccountSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByAutomationAccountResponder handles the response to the ListByAutomationAccount request. The method always +// closes the http.Response Body. +func (client KeysClient) ListByAutomationAccountResponder(resp *http.Response) (result KeyListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/automation/mgmt/2017-05-15-preview/automation/models.go b/services/automation/mgmt/2017-05-15-preview/automation/models.go index bc3ac79fcb1d..e47bac1a4a6c 100644 --- a/services/automation/mgmt/2017-05-15-preview/automation/models.go +++ b/services/automation/mgmt/2017-05-15-preview/automation/models.go @@ -290,6 +290,34 @@ func PossibleJobStreamTypeValues() []JobStreamType { return []JobStreamType{Any, Debug, Error, Output, Progress, Verbose, Warning} } +// KeyName enumerates the values for key name. +type KeyName string + +const ( + // KeyNamePrimary ... + KeyNamePrimary KeyName = "primary" + // KeyNameSecondary ... + KeyNameSecondary KeyName = "secondary" +) + +// PossibleKeyNameValues returns an array of possible values for the KeyName const type. +func PossibleKeyNameValues() []KeyName { + return []KeyName{KeyNamePrimary, KeyNameSecondary} +} + +// KeyPermissions enumerates the values for key permissions. +type KeyPermissions string + +const ( + // Full ... + Full KeyPermissions = "Full" +) + +// PossibleKeyPermissionsValues returns an array of possible values for the KeyPermissions const type. +func PossibleKeyPermissionsValues() []KeyPermissions { + return []KeyPermissions{Full} +} + // LinuxUpdateClasses enumerates the values for linux update classes. type LinuxUpdateClasses string @@ -4968,6 +4996,23 @@ func (jsp JobStreamProperties) MarshalJSON() ([]byte, error) { return json.Marshal(objectMap) } +// Key automation key which is used to register a DSC Node +type Key struct { + // KeyName - Automation key name. Possible values include: 'KeyNamePrimary', 'KeyNameSecondary' + KeyName KeyName `json:"keyName,omitempty"` + // Permissions - Automation key permissions. Possible values include: 'Full' + Permissions KeyPermissions `json:"permissions,omitempty"` + // Value - Value of the Automation Key used for registration. + Value *string `json:"value,omitempty"` +} + +// KeyListResult ... +type KeyListResult struct { + autorest.Response `json:"-"` + // Value - Lists the automation keys. + Value *[]Key `json:"value,omitempty"` +} + // LinkedWorkspace definition of the linked workspace. type LinkedWorkspace struct { autorest.Response `json:"-"`