diff --git a/profiles/preview/preview/automation/mgmt/automation/models.go b/profiles/preview/preview/automation/mgmt/automation/models.go index 30947c33ef66..50d42928e82e 100644 --- a/profiles/preview/preview/automation/mgmt/automation/models.go +++ b/profiles/preview/preview/automation/mgmt/automation/models.go @@ -19,7 +19,7 @@ package automation -import original "github.com/Azure/azure-sdk-for-go/services/preview/automation/mgmt/2017-05-15-preview/automation" +import original "github.com/Azure/azure-sdk-for-go/services/preview/automation/mgmt/2018-06-30-preview/automation" type AccountClient = original.AccountClient type ActivityClient = original.ActivityClient @@ -68,6 +68,13 @@ const ( URI ContentSourceType = original.URI ) +type CountType = original.CountType + +const ( + Nodeconfiguration CountType = original.Nodeconfiguration + Status CountType = original.Status +) + type DscConfigurationProvisioningState = original.DscConfigurationProvisioningState const ( @@ -315,6 +322,13 @@ const ( PartialSync SyncType = original.PartialSync ) +type TagOperators = original.TagOperators + +const ( + TagOperatorsAll TagOperators = original.TagOperatorsAll + TagOperatorsAny TagOperators = original.TagOperatorsAny +) + type TokenType = original.TokenType const ( @@ -359,6 +373,7 @@ type AdvancedScheduleMonthlyOccurrence = original.AdvancedScheduleMonthlyOccurre type AgentRegistration = original.AgentRegistration type AgentRegistrationKeys = original.AgentRegistrationKeys type AgentRegistrationRegenerateKeyParameter = original.AgentRegistrationRegenerateKeyParameter +type AzureQueryProperties = original.AzureQueryProperties type Certificate = original.Certificate type CertificateCreateOrUpdateParameters = original.CertificateCreateOrUpdateParameters type CertificateCreateOrUpdateProperties = original.CertificateCreateOrUpdateProperties @@ -399,6 +414,7 @@ type CredentialProperties = original.CredentialProperties type CredentialUpdateParameters = original.CredentialUpdateParameters type CredentialUpdateProperties = original.CredentialUpdateProperties type DscCompilationJob = original.DscCompilationJob +type DscCompilationJobCreateFuture = original.DscCompilationJobCreateFuture type DscCompilationJobCreateParameters = original.DscCompilationJobCreateParameters type DscCompilationJobCreateProperties = original.DscCompilationJobCreateProperties type DscCompilationJobListResult = original.DscCompilationJobListResult @@ -419,19 +435,24 @@ type DscMetaConfiguration = original.DscMetaConfiguration type DscNode = original.DscNode type DscNodeConfiguration = original.DscNodeConfiguration type DscNodeConfigurationAssociationProperty = original.DscNodeConfigurationAssociationProperty +type DscNodeConfigurationCreateOrUpdateFuture = original.DscNodeConfigurationCreateOrUpdateFuture type DscNodeConfigurationCreateOrUpdateParameters = original.DscNodeConfigurationCreateOrUpdateParameters +type DscNodeConfigurationCreateOrUpdateParametersProperties = original.DscNodeConfigurationCreateOrUpdateParametersProperties type DscNodeConfigurationListResult = original.DscNodeConfigurationListResult type DscNodeConfigurationListResultIterator = original.DscNodeConfigurationListResultIterator type DscNodeConfigurationListResultPage = original.DscNodeConfigurationListResultPage +type DscNodeConfigurationProperties = original.DscNodeConfigurationProperties type DscNodeExtensionHandlerAssociationProperty = original.DscNodeExtensionHandlerAssociationProperty type DscNodeListResult = original.DscNodeListResult type DscNodeListResultIterator = original.DscNodeListResultIterator type DscNodeListResultPage = original.DscNodeListResultPage +type DscNodeProperties = original.DscNodeProperties type DscNodeReport = original.DscNodeReport type DscNodeReportListResult = original.DscNodeReportListResult type DscNodeReportListResultIterator = original.DscNodeReportListResultIterator type DscNodeReportListResultPage = original.DscNodeReportListResultPage type DscNodeUpdateParameters = original.DscNodeUpdateParameters +type DscNodeUpdateParametersProperties = original.DscNodeUpdateParametersProperties type DscReportError = original.DscReportError type DscReportResource = original.DscReportResource type DscReportResourceNavigation = original.DscReportResourceNavigation @@ -479,10 +500,16 @@ type ModuleListResultPage = original.ModuleListResultPage type ModuleProperties = original.ModuleProperties type ModuleUpdateParameters = original.ModuleUpdateParameters type ModuleUpdateProperties = original.ModuleUpdateProperties +type NodeCount = original.NodeCount +type NodeCountProperties = original.NodeCountProperties +type NodeCounts = original.NodeCounts type Operation = original.Operation type OperationDisplay = original.OperationDisplay type OperationListResult = original.OperationListResult type ProxyResource = original.ProxyResource +type PythonPackageCreateParameters = original.PythonPackageCreateParameters +type PythonPackageCreateProperties = original.PythonPackageCreateProperties +type PythonPackageUpdateParameters = original.PythonPackageUpdateParameters type ReadCloser = original.ReadCloser type Resource = original.Resource type RunAsCredentialAssociationProperty = original.RunAsCredentialAssociationProperty @@ -493,7 +520,6 @@ type RunbookCreateOrUpdateDraftProperties = original.RunbookCreateOrUpdateDraftP type RunbookCreateOrUpdateParameters = original.RunbookCreateOrUpdateParameters type RunbookCreateOrUpdateProperties = original.RunbookCreateOrUpdateProperties type RunbookDraft = original.RunbookDraft -type RunbookDraftPublishFuture = original.RunbookDraftPublishFuture type RunbookDraftReplaceContentFuture = original.RunbookDraftReplaceContentFuture type RunbookDraftUndoEditResult = original.RunbookDraftUndoEditResult type RunbookListResult = original.RunbookListResult @@ -501,6 +527,7 @@ type RunbookListResultIterator = original.RunbookListResultIterator type RunbookListResultPage = original.RunbookListResultPage type RunbookParameter = original.RunbookParameter type RunbookProperties = original.RunbookProperties +type RunbookPublishFuture = original.RunbookPublishFuture type RunbookUpdateParameters = original.RunbookUpdateParameters type RunbookUpdateProperties = original.RunbookUpdateProperties type Schedule = original.Schedule @@ -554,6 +581,8 @@ type SourceControlUpdateProperties = original.SourceControlUpdateProperties type Statistics = original.Statistics type StatisticsListResult = original.StatisticsListResult type String = original.String +type TagSettingsProperties = original.TagSettingsProperties +type TargetProperties = original.TargetProperties type TestJob = original.TestJob type TestJobCreateParameters = original.TestJobCreateParameters type TrackedResource = original.TrackedResource @@ -574,6 +603,13 @@ type VariableListResultPage = original.VariableListResultPage type VariableProperties = original.VariableProperties type VariableUpdateParameters = original.VariableUpdateParameters type VariableUpdateProperties = original.VariableUpdateProperties +type Watcher = original.Watcher +type WatcherListResult = original.WatcherListResult +type WatcherListResultIterator = original.WatcherListResultIterator +type WatcherListResultPage = original.WatcherListResultPage +type WatcherProperties = original.WatcherProperties +type WatcherUpdateParameters = original.WatcherUpdateParameters +type WatcherUpdateProperties = original.WatcherUpdateProperties type Webhook = original.Webhook type WebhookCreateOrUpdateParameters = original.WebhookCreateOrUpdateParameters type WebhookCreateOrUpdateProperties = original.WebhookCreateOrUpdateProperties @@ -585,9 +621,11 @@ type WebhookUpdateParameters = original.WebhookUpdateParameters type WebhookUpdateProperties = original.WebhookUpdateProperties type WindowsProperties = original.WindowsProperties type ModuleClient = original.ModuleClient +type NodeCountInformationClient = original.NodeCountInformationClient type NodeReportsClient = original.NodeReportsClient type ObjectDataTypesClient = original.ObjectDataTypesClient type OperationsClient = original.OperationsClient +type Python2PackageClient = original.Python2PackageClient type RunbookClient = original.RunbookClient type RunbookDraftClient = original.RunbookDraftClient type ScheduleClient = original.ScheduleClient @@ -602,127 +640,128 @@ type TestJobClient = original.TestJobClient type TestJobStreamsClient = original.TestJobStreamsClient type UsagesClient = original.UsagesClient type VariableClient = original.VariableClient +type WatcherClient = original.WatcherClient type WebhookClient = original.WebhookClient -func NewAccountClient(subscriptionID string) AccountClient { - return original.NewAccountClient(subscriptionID) +func NewAccountClient(subscriptionID string, countType1 CountType) AccountClient { + return original.NewAccountClient(subscriptionID, countType1) } -func NewAccountClientWithBaseURI(baseURI string, subscriptionID string) AccountClient { - return original.NewAccountClientWithBaseURI(baseURI, subscriptionID) +func NewAccountClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) AccountClient { + return original.NewAccountClientWithBaseURI(baseURI, subscriptionID, countType1) } -func NewActivityClient(subscriptionID string) ActivityClient { - return original.NewActivityClient(subscriptionID) +func NewActivityClient(subscriptionID string, countType1 CountType) ActivityClient { + return original.NewActivityClient(subscriptionID, countType1) } -func NewActivityClientWithBaseURI(baseURI string, subscriptionID string) ActivityClient { - return original.NewActivityClientWithBaseURI(baseURI, subscriptionID) +func NewActivityClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) ActivityClient { + return original.NewActivityClientWithBaseURI(baseURI, subscriptionID, countType1) } -func NewAgentRegistrationInformationClient(subscriptionID string) AgentRegistrationInformationClient { - return original.NewAgentRegistrationInformationClient(subscriptionID) +func NewAgentRegistrationInformationClient(subscriptionID string, countType1 CountType) AgentRegistrationInformationClient { + return original.NewAgentRegistrationInformationClient(subscriptionID, countType1) } -func NewAgentRegistrationInformationClientWithBaseURI(baseURI string, subscriptionID string) AgentRegistrationInformationClient { - return original.NewAgentRegistrationInformationClientWithBaseURI(baseURI, subscriptionID) +func NewAgentRegistrationInformationClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) AgentRegistrationInformationClient { + return original.NewAgentRegistrationInformationClientWithBaseURI(baseURI, subscriptionID, countType1) } -func NewCertificateClient(subscriptionID string) CertificateClient { - return original.NewCertificateClient(subscriptionID) +func NewCertificateClient(subscriptionID string, countType1 CountType) CertificateClient { + return original.NewCertificateClient(subscriptionID, countType1) } -func NewCertificateClientWithBaseURI(baseURI string, subscriptionID string) CertificateClient { - return original.NewCertificateClientWithBaseURI(baseURI, subscriptionID) +func NewCertificateClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) CertificateClient { + return original.NewCertificateClientWithBaseURI(baseURI, subscriptionID, countType1) } -func New(subscriptionID string) BaseClient { - return original.New(subscriptionID) +func New(subscriptionID string, countType1 CountType) BaseClient { + return original.New(subscriptionID, countType1) } -func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { - return original.NewWithBaseURI(baseURI, subscriptionID) +func NewWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) BaseClient { + return original.NewWithBaseURI(baseURI, subscriptionID, countType1) } -func NewConnectionClient(subscriptionID string) ConnectionClient { - return original.NewConnectionClient(subscriptionID) +func NewConnectionClient(subscriptionID string, countType1 CountType) ConnectionClient { + return original.NewConnectionClient(subscriptionID, countType1) } -func NewConnectionClientWithBaseURI(baseURI string, subscriptionID string) ConnectionClient { - return original.NewConnectionClientWithBaseURI(baseURI, subscriptionID) +func NewConnectionClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) ConnectionClient { + return original.NewConnectionClientWithBaseURI(baseURI, subscriptionID, countType1) } -func NewConnectionTypeClient(subscriptionID string) ConnectionTypeClient { - return original.NewConnectionTypeClient(subscriptionID) +func NewConnectionTypeClient(subscriptionID string, countType1 CountType) ConnectionTypeClient { + return original.NewConnectionTypeClient(subscriptionID, countType1) } -func NewConnectionTypeClientWithBaseURI(baseURI string, subscriptionID string) ConnectionTypeClient { - return original.NewConnectionTypeClientWithBaseURI(baseURI, subscriptionID) +func NewConnectionTypeClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) ConnectionTypeClient { + return original.NewConnectionTypeClientWithBaseURI(baseURI, subscriptionID, countType1) } -func NewCredentialClient(subscriptionID string) CredentialClient { - return original.NewCredentialClient(subscriptionID) +func NewCredentialClient(subscriptionID string, countType1 CountType) CredentialClient { + return original.NewCredentialClient(subscriptionID, countType1) } -func NewCredentialClientWithBaseURI(baseURI string, subscriptionID string) CredentialClient { - return original.NewCredentialClientWithBaseURI(baseURI, subscriptionID) +func NewCredentialClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) CredentialClient { + return original.NewCredentialClientWithBaseURI(baseURI, subscriptionID, countType1) } -func NewDscCompilationJobClient(subscriptionID string) DscCompilationJobClient { - return original.NewDscCompilationJobClient(subscriptionID) +func NewDscCompilationJobClient(subscriptionID string, countType1 CountType) DscCompilationJobClient { + return original.NewDscCompilationJobClient(subscriptionID, countType1) } -func NewDscCompilationJobClientWithBaseURI(baseURI string, subscriptionID string) DscCompilationJobClient { - return original.NewDscCompilationJobClientWithBaseURI(baseURI, subscriptionID) +func NewDscCompilationJobClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) DscCompilationJobClient { + return original.NewDscCompilationJobClientWithBaseURI(baseURI, subscriptionID, countType1) } -func NewDscCompilationJobStreamClient(subscriptionID string) DscCompilationJobStreamClient { - return original.NewDscCompilationJobStreamClient(subscriptionID) +func NewDscCompilationJobStreamClient(subscriptionID string, countType1 CountType) DscCompilationJobStreamClient { + return original.NewDscCompilationJobStreamClient(subscriptionID, countType1) } -func NewDscCompilationJobStreamClientWithBaseURI(baseURI string, subscriptionID string) DscCompilationJobStreamClient { - return original.NewDscCompilationJobStreamClientWithBaseURI(baseURI, subscriptionID) +func NewDscCompilationJobStreamClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) DscCompilationJobStreamClient { + return original.NewDscCompilationJobStreamClientWithBaseURI(baseURI, subscriptionID, countType1) } -func NewDscConfigurationClient(subscriptionID string) DscConfigurationClient { - return original.NewDscConfigurationClient(subscriptionID) +func NewDscConfigurationClient(subscriptionID string, countType1 CountType) DscConfigurationClient { + return original.NewDscConfigurationClient(subscriptionID, countType1) } -func NewDscConfigurationClientWithBaseURI(baseURI string, subscriptionID string) DscConfigurationClient { - return original.NewDscConfigurationClientWithBaseURI(baseURI, subscriptionID) +func NewDscConfigurationClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) DscConfigurationClient { + return original.NewDscConfigurationClientWithBaseURI(baseURI, subscriptionID, countType1) } -func NewDscNodeClient(subscriptionID string) DscNodeClient { - return original.NewDscNodeClient(subscriptionID) +func NewDscNodeClient(subscriptionID string, countType1 CountType) DscNodeClient { + return original.NewDscNodeClient(subscriptionID, countType1) } -func NewDscNodeClientWithBaseURI(baseURI string, subscriptionID string) DscNodeClient { - return original.NewDscNodeClientWithBaseURI(baseURI, subscriptionID) +func NewDscNodeClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) DscNodeClient { + return original.NewDscNodeClientWithBaseURI(baseURI, subscriptionID, countType1) } -func NewDscNodeConfigurationClient(subscriptionID string) DscNodeConfigurationClient { - return original.NewDscNodeConfigurationClient(subscriptionID) +func NewDscNodeConfigurationClient(subscriptionID string, countType1 CountType) DscNodeConfigurationClient { + return original.NewDscNodeConfigurationClient(subscriptionID, countType1) } -func NewDscNodeConfigurationClientWithBaseURI(baseURI string, subscriptionID string) DscNodeConfigurationClient { - return original.NewDscNodeConfigurationClientWithBaseURI(baseURI, subscriptionID) +func NewDscNodeConfigurationClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) DscNodeConfigurationClient { + return original.NewDscNodeConfigurationClientWithBaseURI(baseURI, subscriptionID, countType1) } -func NewFieldsClient(subscriptionID string) FieldsClient { - return original.NewFieldsClient(subscriptionID) +func NewFieldsClient(subscriptionID string, countType1 CountType) FieldsClient { + return original.NewFieldsClient(subscriptionID, countType1) } -func NewFieldsClientWithBaseURI(baseURI string, subscriptionID string) FieldsClient { - return original.NewFieldsClientWithBaseURI(baseURI, subscriptionID) +func NewFieldsClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) FieldsClient { + return original.NewFieldsClientWithBaseURI(baseURI, subscriptionID, countType1) } -func NewHybridRunbookWorkerGroupClient(subscriptionID string) HybridRunbookWorkerGroupClient { - return original.NewHybridRunbookWorkerGroupClient(subscriptionID) +func NewHybridRunbookWorkerGroupClient(subscriptionID string, countType1 CountType) HybridRunbookWorkerGroupClient { + return original.NewHybridRunbookWorkerGroupClient(subscriptionID, countType1) } -func NewHybridRunbookWorkerGroupClientWithBaseURI(baseURI string, subscriptionID string) HybridRunbookWorkerGroupClient { - return original.NewHybridRunbookWorkerGroupClientWithBaseURI(baseURI, subscriptionID) +func NewHybridRunbookWorkerGroupClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) HybridRunbookWorkerGroupClient { + return original.NewHybridRunbookWorkerGroupClientWithBaseURI(baseURI, subscriptionID, countType1) } -func NewJobClient(subscriptionID string) JobClient { - return original.NewJobClient(subscriptionID) +func NewJobClient(subscriptionID string, countType1 CountType) JobClient { + return original.NewJobClient(subscriptionID, countType1) } -func NewJobClientWithBaseURI(baseURI string, subscriptionID string) JobClient { - return original.NewJobClientWithBaseURI(baseURI, subscriptionID) +func NewJobClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) JobClient { + return original.NewJobClientWithBaseURI(baseURI, subscriptionID, countType1) } -func NewJobScheduleClient(subscriptionID string) JobScheduleClient { - return original.NewJobScheduleClient(subscriptionID) +func NewJobScheduleClient(subscriptionID string, countType1 CountType) JobScheduleClient { + return original.NewJobScheduleClient(subscriptionID, countType1) } -func NewJobScheduleClientWithBaseURI(baseURI string, subscriptionID string) JobScheduleClient { - return original.NewJobScheduleClientWithBaseURI(baseURI, subscriptionID) +func NewJobScheduleClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) JobScheduleClient { + return original.NewJobScheduleClientWithBaseURI(baseURI, subscriptionID, countType1) } -func NewJobStreamClient(subscriptionID string) JobStreamClient { - return original.NewJobStreamClient(subscriptionID) +func NewJobStreamClient(subscriptionID string, countType1 CountType) JobStreamClient { + return original.NewJobStreamClient(subscriptionID, countType1) } -func NewJobStreamClientWithBaseURI(baseURI string, subscriptionID string) JobStreamClient { - return original.NewJobStreamClientWithBaseURI(baseURI, subscriptionID) +func NewJobStreamClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) JobStreamClient { + return original.NewJobStreamClientWithBaseURI(baseURI, subscriptionID, countType1) } -func NewKeysClient(subscriptionID string) KeysClient { - return original.NewKeysClient(subscriptionID) +func NewKeysClient(subscriptionID string, countType1 CountType) KeysClient { + return original.NewKeysClient(subscriptionID, countType1) } -func NewKeysClientWithBaseURI(baseURI string, subscriptionID string) KeysClient { - return original.NewKeysClientWithBaseURI(baseURI, subscriptionID) +func NewKeysClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) KeysClient { + return original.NewKeysClientWithBaseURI(baseURI, subscriptionID, countType1) } -func NewLinkedWorkspaceClient(subscriptionID string) LinkedWorkspaceClient { - return original.NewLinkedWorkspaceClient(subscriptionID) +func NewLinkedWorkspaceClient(subscriptionID string, countType1 CountType) LinkedWorkspaceClient { + return original.NewLinkedWorkspaceClient(subscriptionID, countType1) } -func NewLinkedWorkspaceClientWithBaseURI(baseURI string, subscriptionID string) LinkedWorkspaceClient { - return original.NewLinkedWorkspaceClientWithBaseURI(baseURI, subscriptionID) +func NewLinkedWorkspaceClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) LinkedWorkspaceClient { + return original.NewLinkedWorkspaceClientWithBaseURI(baseURI, subscriptionID, countType1) } func PossibleAccountStateValues() []AccountState { return original.PossibleAccountStateValues() @@ -733,6 +772,9 @@ func PossibleAgentRegistrationKeyNameValues() []AgentRegistrationKeyName { func PossibleContentSourceTypeValues() []ContentSourceType { return original.PossibleContentSourceTypeValues() } +func PossibleCountTypeValues() []CountType { + return original.PossibleCountTypeValues() +} func PossibleDscConfigurationProvisioningStateValues() []DscConfigurationProvisioningState { return original.PossibleDscConfigurationProvisioningStateValues() } @@ -799,119 +841,134 @@ func PossibleStreamTypeValues() []StreamType { func PossibleSyncTypeValues() []SyncType { return original.PossibleSyncTypeValues() } +func PossibleTagOperatorsValues() []TagOperators { + return original.PossibleTagOperatorsValues() +} func PossibleTokenTypeValues() []TokenType { return original.PossibleTokenTypeValues() } func PossibleWindowsUpdateClassesValues() []WindowsUpdateClasses { return original.PossibleWindowsUpdateClassesValues() } -func NewModuleClient(subscriptionID string) ModuleClient { - return original.NewModuleClient(subscriptionID) +func NewModuleClient(subscriptionID string, countType1 CountType) ModuleClient { + return original.NewModuleClient(subscriptionID, countType1) +} +func NewModuleClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) ModuleClient { + return original.NewModuleClientWithBaseURI(baseURI, subscriptionID, countType1) +} +func NewNodeCountInformationClient(subscriptionID string, countType1 CountType) NodeCountInformationClient { + return original.NewNodeCountInformationClient(subscriptionID, countType1) } -func NewModuleClientWithBaseURI(baseURI string, subscriptionID string) ModuleClient { - return original.NewModuleClientWithBaseURI(baseURI, subscriptionID) +func NewNodeCountInformationClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) NodeCountInformationClient { + return original.NewNodeCountInformationClientWithBaseURI(baseURI, subscriptionID, countType1) } -func NewNodeReportsClient(subscriptionID string) NodeReportsClient { - return original.NewNodeReportsClient(subscriptionID) +func NewNodeReportsClient(subscriptionID string, countType1 CountType) NodeReportsClient { + return original.NewNodeReportsClient(subscriptionID, countType1) } -func NewNodeReportsClientWithBaseURI(baseURI string, subscriptionID string) NodeReportsClient { - return original.NewNodeReportsClientWithBaseURI(baseURI, subscriptionID) +func NewNodeReportsClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) NodeReportsClient { + return original.NewNodeReportsClientWithBaseURI(baseURI, subscriptionID, countType1) } -func NewObjectDataTypesClient(subscriptionID string) ObjectDataTypesClient { - return original.NewObjectDataTypesClient(subscriptionID) +func NewObjectDataTypesClient(subscriptionID string, countType1 CountType) ObjectDataTypesClient { + return original.NewObjectDataTypesClient(subscriptionID, countType1) } -func NewObjectDataTypesClientWithBaseURI(baseURI string, subscriptionID string) ObjectDataTypesClient { - return original.NewObjectDataTypesClientWithBaseURI(baseURI, subscriptionID) +func NewObjectDataTypesClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) ObjectDataTypesClient { + return original.NewObjectDataTypesClientWithBaseURI(baseURI, subscriptionID, countType1) } -func NewOperationsClient(subscriptionID string) OperationsClient { - return original.NewOperationsClient(subscriptionID) +func NewOperationsClient(subscriptionID string, countType1 CountType) OperationsClient { + return original.NewOperationsClient(subscriptionID, countType1) } -func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { - return original.NewOperationsClientWithBaseURI(baseURI, subscriptionID) +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) OperationsClient { + return original.NewOperationsClientWithBaseURI(baseURI, subscriptionID, countType1) } -func NewRunbookClient(subscriptionID string) RunbookClient { - return original.NewRunbookClient(subscriptionID) +func NewPython2PackageClient(subscriptionID string, countType1 CountType) Python2PackageClient { + return original.NewPython2PackageClient(subscriptionID, countType1) } -func NewRunbookClientWithBaseURI(baseURI string, subscriptionID string) RunbookClient { - return original.NewRunbookClientWithBaseURI(baseURI, subscriptionID) +func NewPython2PackageClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) Python2PackageClient { + return original.NewPython2PackageClientWithBaseURI(baseURI, subscriptionID, countType1) } -func NewRunbookDraftClient(subscriptionID string) RunbookDraftClient { - return original.NewRunbookDraftClient(subscriptionID) +func NewRunbookClient(subscriptionID string, countType1 CountType) RunbookClient { + return original.NewRunbookClient(subscriptionID, countType1) } -func NewRunbookDraftClientWithBaseURI(baseURI string, subscriptionID string) RunbookDraftClient { - return original.NewRunbookDraftClientWithBaseURI(baseURI, subscriptionID) +func NewRunbookClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) RunbookClient { + return original.NewRunbookClientWithBaseURI(baseURI, subscriptionID, countType1) } -func NewScheduleClient(subscriptionID string) ScheduleClient { - return original.NewScheduleClient(subscriptionID) +func NewRunbookDraftClient(subscriptionID string, countType1 CountType) RunbookDraftClient { + return original.NewRunbookDraftClient(subscriptionID, countType1) } -func NewScheduleClientWithBaseURI(baseURI string, subscriptionID string) ScheduleClient { - return original.NewScheduleClientWithBaseURI(baseURI, subscriptionID) +func NewRunbookDraftClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) RunbookDraftClient { + return original.NewRunbookDraftClientWithBaseURI(baseURI, subscriptionID, countType1) } -func NewSoftwareUpdateConfigurationMachineRunsClient(subscriptionID string) SoftwareUpdateConfigurationMachineRunsClient { - return original.NewSoftwareUpdateConfigurationMachineRunsClient(subscriptionID) +func NewScheduleClient(subscriptionID string, countType1 CountType) ScheduleClient { + return original.NewScheduleClient(subscriptionID, countType1) } -func NewSoftwareUpdateConfigurationMachineRunsClientWithBaseURI(baseURI string, subscriptionID string) SoftwareUpdateConfigurationMachineRunsClient { - return original.NewSoftwareUpdateConfigurationMachineRunsClientWithBaseURI(baseURI, subscriptionID) +func NewScheduleClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) ScheduleClient { + return original.NewScheduleClientWithBaseURI(baseURI, subscriptionID, countType1) } -func NewSoftwareUpdateConfigurationRunsClient(subscriptionID string) SoftwareUpdateConfigurationRunsClient { - return original.NewSoftwareUpdateConfigurationRunsClient(subscriptionID) +func NewSoftwareUpdateConfigurationMachineRunsClient(subscriptionID string, countType1 CountType) SoftwareUpdateConfigurationMachineRunsClient { + return original.NewSoftwareUpdateConfigurationMachineRunsClient(subscriptionID, countType1) } -func NewSoftwareUpdateConfigurationRunsClientWithBaseURI(baseURI string, subscriptionID string) SoftwareUpdateConfigurationRunsClient { - return original.NewSoftwareUpdateConfigurationRunsClientWithBaseURI(baseURI, subscriptionID) +func NewSoftwareUpdateConfigurationMachineRunsClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) SoftwareUpdateConfigurationMachineRunsClient { + return original.NewSoftwareUpdateConfigurationMachineRunsClientWithBaseURI(baseURI, subscriptionID, countType1) } -func NewSoftwareUpdateConfigurationsClient(subscriptionID string) SoftwareUpdateConfigurationsClient { - return original.NewSoftwareUpdateConfigurationsClient(subscriptionID) +func NewSoftwareUpdateConfigurationRunsClient(subscriptionID string, countType1 CountType) SoftwareUpdateConfigurationRunsClient { + return original.NewSoftwareUpdateConfigurationRunsClient(subscriptionID, countType1) } -func NewSoftwareUpdateConfigurationsClientWithBaseURI(baseURI string, subscriptionID string) SoftwareUpdateConfigurationsClient { - return original.NewSoftwareUpdateConfigurationsClientWithBaseURI(baseURI, subscriptionID) +func NewSoftwareUpdateConfigurationRunsClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) SoftwareUpdateConfigurationRunsClient { + return original.NewSoftwareUpdateConfigurationRunsClientWithBaseURI(baseURI, subscriptionID, countType1) } -func NewSourceControlClient(subscriptionID string) SourceControlClient { - return original.NewSourceControlClient(subscriptionID) +func NewSoftwareUpdateConfigurationsClient(subscriptionID string, countType1 CountType) SoftwareUpdateConfigurationsClient { + return original.NewSoftwareUpdateConfigurationsClient(subscriptionID, countType1) } -func NewSourceControlClientWithBaseURI(baseURI string, subscriptionID string) SourceControlClient { - return original.NewSourceControlClientWithBaseURI(baseURI, subscriptionID) +func NewSoftwareUpdateConfigurationsClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) SoftwareUpdateConfigurationsClient { + return original.NewSoftwareUpdateConfigurationsClientWithBaseURI(baseURI, subscriptionID, countType1) } -func NewSourceControlSyncJobClient(subscriptionID string) SourceControlSyncJobClient { - return original.NewSourceControlSyncJobClient(subscriptionID) +func NewSourceControlClient(subscriptionID string, countType1 CountType) SourceControlClient { + return original.NewSourceControlClient(subscriptionID, countType1) } -func NewSourceControlSyncJobClientWithBaseURI(baseURI string, subscriptionID string) SourceControlSyncJobClient { - return original.NewSourceControlSyncJobClientWithBaseURI(baseURI, subscriptionID) +func NewSourceControlClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) SourceControlClient { + return original.NewSourceControlClientWithBaseURI(baseURI, subscriptionID, countType1) } -func NewSourceControlSyncJobStreamsClient(subscriptionID string) SourceControlSyncJobStreamsClient { - return original.NewSourceControlSyncJobStreamsClient(subscriptionID) +func NewSourceControlSyncJobClient(subscriptionID string, countType1 CountType) SourceControlSyncJobClient { + return original.NewSourceControlSyncJobClient(subscriptionID, countType1) } -func NewSourceControlSyncJobStreamsClientWithBaseURI(baseURI string, subscriptionID string) SourceControlSyncJobStreamsClient { - return original.NewSourceControlSyncJobStreamsClientWithBaseURI(baseURI, subscriptionID) +func NewSourceControlSyncJobClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) SourceControlSyncJobClient { + return original.NewSourceControlSyncJobClientWithBaseURI(baseURI, subscriptionID, countType1) } -func NewStatisticsClient(subscriptionID string) StatisticsClient { - return original.NewStatisticsClient(subscriptionID) +func NewSourceControlSyncJobStreamsClient(subscriptionID string, countType1 CountType) SourceControlSyncJobStreamsClient { + return original.NewSourceControlSyncJobStreamsClient(subscriptionID, countType1) } -func NewStatisticsClientWithBaseURI(baseURI string, subscriptionID string) StatisticsClient { - return original.NewStatisticsClientWithBaseURI(baseURI, subscriptionID) +func NewSourceControlSyncJobStreamsClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) SourceControlSyncJobStreamsClient { + return original.NewSourceControlSyncJobStreamsClientWithBaseURI(baseURI, subscriptionID, countType1) } -func NewTestJobClient(subscriptionID string) TestJobClient { - return original.NewTestJobClient(subscriptionID) +func NewStatisticsClient(subscriptionID string, countType1 CountType) StatisticsClient { + return original.NewStatisticsClient(subscriptionID, countType1) } -func NewTestJobClientWithBaseURI(baseURI string, subscriptionID string) TestJobClient { - return original.NewTestJobClientWithBaseURI(baseURI, subscriptionID) +func NewStatisticsClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) StatisticsClient { + return original.NewStatisticsClientWithBaseURI(baseURI, subscriptionID, countType1) } -func NewTestJobStreamsClient(subscriptionID string) TestJobStreamsClient { - return original.NewTestJobStreamsClient(subscriptionID) +func NewTestJobClient(subscriptionID string, countType1 CountType) TestJobClient { + return original.NewTestJobClient(subscriptionID, countType1) } -func NewTestJobStreamsClientWithBaseURI(baseURI string, subscriptionID string) TestJobStreamsClient { - return original.NewTestJobStreamsClientWithBaseURI(baseURI, subscriptionID) +func NewTestJobClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) TestJobClient { + return original.NewTestJobClientWithBaseURI(baseURI, subscriptionID, countType1) } -func NewUsagesClient(subscriptionID string) UsagesClient { - return original.NewUsagesClient(subscriptionID) +func NewTestJobStreamsClient(subscriptionID string, countType1 CountType) TestJobStreamsClient { + return original.NewTestJobStreamsClient(subscriptionID, countType1) } -func NewUsagesClientWithBaseURI(baseURI string, subscriptionID string) UsagesClient { - return original.NewUsagesClientWithBaseURI(baseURI, subscriptionID) +func NewTestJobStreamsClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) TestJobStreamsClient { + return original.NewTestJobStreamsClientWithBaseURI(baseURI, subscriptionID, countType1) } -func NewVariableClient(subscriptionID string) VariableClient { - return original.NewVariableClient(subscriptionID) +func NewUsagesClient(subscriptionID string, countType1 CountType) UsagesClient { + return original.NewUsagesClient(subscriptionID, countType1) } -func NewVariableClientWithBaseURI(baseURI string, subscriptionID string) VariableClient { - return original.NewVariableClientWithBaseURI(baseURI, subscriptionID) +func NewUsagesClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) UsagesClient { + return original.NewUsagesClientWithBaseURI(baseURI, subscriptionID, countType1) +} +func NewVariableClient(subscriptionID string, countType1 CountType) VariableClient { + return original.NewVariableClient(subscriptionID, countType1) +} +func NewVariableClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) VariableClient { + return original.NewVariableClientWithBaseURI(baseURI, subscriptionID, countType1) } func UserAgent() string { return original.UserAgent() + " profiles/preview" @@ -919,9 +976,15 @@ func UserAgent() string { func Version() string { return original.Version() } -func NewWebhookClient(subscriptionID string) WebhookClient { - return original.NewWebhookClient(subscriptionID) +func NewWatcherClient(subscriptionID string, countType1 CountType) WatcherClient { + return original.NewWatcherClient(subscriptionID, countType1) +} +func NewWatcherClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) WatcherClient { + return original.NewWatcherClientWithBaseURI(baseURI, subscriptionID, countType1) +} +func NewWebhookClient(subscriptionID string, countType1 CountType) WebhookClient { + return original.NewWebhookClient(subscriptionID, countType1) } -func NewWebhookClientWithBaseURI(baseURI string, subscriptionID string) WebhookClient { - return original.NewWebhookClientWithBaseURI(baseURI, subscriptionID) +func NewWebhookClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) WebhookClient { + return original.NewWebhookClientWithBaseURI(baseURI, subscriptionID, countType1) } diff --git a/services/preview/automation/mgmt/2017-05-15-preview/automation/models.go b/services/preview/automation/mgmt/2017-05-15-preview/automation/models.go index 4cc053dba85b..1fb788f57f3c 100644 --- a/services/preview/automation/mgmt/2017-05-15-preview/automation/models.go +++ b/services/preview/automation/mgmt/2017-05-15-preview/automation/models.go @@ -591,6 +591,21 @@ func PossibleSyncTypeValues() []SyncType { return []SyncType{FullSync, PartialSync} } +// TagOperators enumerates the values for tag operators. +type TagOperators string + +const ( + // TagOperatorsAll ... + TagOperatorsAll TagOperators = "All" + // TagOperatorsAny ... + TagOperatorsAny TagOperators = "Any" +) + +// PossibleTagOperatorsValues returns an array of possible values for the TagOperators const type. +func PossibleTagOperatorsValues() []TagOperators { + return []TagOperators{TagOperatorsAll, TagOperatorsAny} +} + // TokenType enumerates the values for token type. type TokenType string @@ -1352,6 +1367,16 @@ func (arrkp AgentRegistrationRegenerateKeyParameter) MarshalJSON() ([]byte, erro return json.Marshal(objectMap) } +// AzureQueryProperties azure query for the update configuration. +type AzureQueryProperties struct { + // Scope - List of Subscription or Resource Group ARM Ids. + Scope *[]string `json:"scope,omitempty"` + // Location - List of locations to scope the query to. + Location *[]string `json:"location,omitempty"` + // TagSettings - Tag settings for the VM. + TagSettings *TagSettingsProperties `json:"tagSettings,omitempty"` +} + // Certificate definition of the certificate. type Certificate struct { autorest.Response `json:"-"` @@ -7988,6 +8013,32 @@ type String struct { Value *string `json:"value,omitempty"` } +// TagSettingsProperties tag filter information for the VM. +type TagSettingsProperties struct { + // Tags - Dictionary of tags with its list of values. + Tags map[string][]string `json:"tags"` + // FilterOperator - Filter VMs by Any or All specified tags. Possible values include: 'TagOperatorsAll', 'TagOperatorsAny' + FilterOperator TagOperators `json:"filterOperator,omitempty"` +} + +// MarshalJSON is the custom marshaler for TagSettingsProperties. +func (tsp TagSettingsProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tsp.Tags != nil { + objectMap["tags"] = tsp.Tags + } + if tsp.FilterOperator != "" { + objectMap["filterOperator"] = tsp.FilterOperator + } + return json.Marshal(objectMap) +} + +// TargetProperties group specific to the update configuration. +type TargetProperties struct { + // AzureQueries - List of Azure queries in the software update configuration. + AzureQueries *[]AzureQueryProperties `json:"azureQueries,omitempty"` +} + // TestJob definition of the test job. type TestJob struct { autorest.Response `json:"-"` @@ -8138,6 +8189,8 @@ type UpdateConfiguration struct { AzureVirtualMachines *[]string `json:"azureVirtualMachines,omitempty"` // NonAzureComputerNames - List of names of non-azure machines targeted by the software update configuration. NonAzureComputerNames *[]string `json:"nonAzureComputerNames,omitempty"` + // Targets - Group targets for the software update configuration. + Targets *TargetProperties `json:"targets,omitempty"` } // UpdateConfigurationMachineRunProperties software update configuration machine run properties. diff --git a/services/preview/automation/mgmt/2018-01-15-preview/automation/account.go b/services/preview/automation/mgmt/2018-01-15-preview/automation/account.go new file mode 100644 index 000000000000..ca92a9118901 --- /dev/null +++ b/services/preview/automation/mgmt/2018-01-15-preview/automation/account.go @@ -0,0 +1,537 @@ +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" +) + +// AccountClient is the automation Client +type AccountClient struct { + BaseClient +} + +// NewAccountClient creates an instance of the AccountClient client. +func NewAccountClient(subscriptionID string, countType1 CountType) AccountClient { + return NewAccountClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewAccountClientWithBaseURI creates an instance of the AccountClient client. +func NewAccountClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) AccountClient { + return AccountClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// CreateOrUpdate create or update automation account. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// parameters - parameters supplied to the create or update automation account. +func (client AccountClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, automationAccountName string, parameters AccountCreateOrUpdateParameters) (result Account, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.AccountClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, automationAccountName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AccountClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.AccountClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AccountClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client AccountClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, parameters AccountCreateOrUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client AccountClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client AccountClient) CreateOrUpdateResponder(resp *http.Response) (result Account, 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 delete an automation account. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +func (client AccountClient) Delete(ctx context.Context, resourceGroupName string, automationAccountName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.AccountClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AccountClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.AccountClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AccountClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client AccountClient) DeletePreparer(ctx context.Context, resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client AccountClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client AccountClient) 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 get information about an Automation Account. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +func (client AccountClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string) (result Account, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.AccountClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AccountClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.AccountClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AccountClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client AccountClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client AccountClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client AccountClient) GetResponder(resp *http.Response) (result Account, 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 retrieve a list of accounts within a given subscription. +func (client AccountClient) List(ctx context.Context) (result AccountListResultPage, err error) { + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AccountClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.alr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.AccountClient", "List", resp, "Failure sending request") + return + } + + result.alr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AccountClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client AccountClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Automation/automationAccounts", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client AccountClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client AccountClient) ListResponder(resp *http.Response) (result AccountListResult, 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 AccountClient) listNextResults(lastResults AccountListResult) (result AccountListResult, err error) { + req, err := lastResults.accountListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.AccountClient", "listNextResults", 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, "automation.AccountClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AccountClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client AccountClient) ListComplete(ctx context.Context) (result AccountListResultIterator, err error) { + result.page, err = client.List(ctx) + return +} + +// ListByResourceGroup retrieve a list of accounts within a given resource group. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +func (client AccountClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result AccountListResultPage, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.AccountClient", "ListByResourceGroup", err.Error()) + } + + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AccountClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.alr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.AccountClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.alr, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AccountClient", "ListByResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client AccountClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client AccountClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client AccountClient) ListByResourceGroupResponder(resp *http.Response) (result AccountListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client AccountClient) listByResourceGroupNextResults(lastResults AccountListResult) (result AccountListResult, err error) { + req, err := lastResults.accountListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.AccountClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.AccountClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AccountClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client AccountClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result AccountListResultIterator, err error) { + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// Update update an automation account. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// parameters - parameters supplied to the update automation account. +func (client AccountClient) Update(ctx context.Context, resourceGroupName string, automationAccountName string, parameters AccountUpdateParameters) (result Account, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.AccountClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, automationAccountName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AccountClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.AccountClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AccountClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client AccountClient) UpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, parameters AccountUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client AccountClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client AccountClient) UpdateResponder(resp *http.Response) (result Account, 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/preview/automation/mgmt/2018-01-15-preview/automation/activity.go b/services/preview/automation/mgmt/2018-01-15-preview/automation/activity.go new file mode 100644 index 000000000000..e81a3d90118f --- /dev/null +++ b/services/preview/automation/mgmt/2018-01-15-preview/automation/activity.go @@ -0,0 +1,225 @@ +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" +) + +// ActivityClient is the automation Client +type ActivityClient struct { + BaseClient +} + +// NewActivityClient creates an instance of the ActivityClient client. +func NewActivityClient(subscriptionID string, countType1 CountType) ActivityClient { + return NewActivityClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewActivityClientWithBaseURI creates an instance of the ActivityClient client. +func NewActivityClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) ActivityClient { + return ActivityClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// Get retrieve the activity in the module identified by module name and activity name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// moduleName - the name of module. +// activityName - the name of activity. +func (client ActivityClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string, moduleName string, activityName string) (result Activity, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.ActivityClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName, moduleName, activityName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ActivityClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ActivityClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ActivityClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ActivityClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, moduleName string, activityName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "activityName": autorest.Encode("path", activityName), + "automationAccountName": autorest.Encode("path", automationAccountName), + "moduleName": autorest.Encode("path", moduleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/activities/{activityName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ActivityClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ActivityClient) GetResponder(resp *http.Response) (result Activity, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByModule retrieve a list of activities in the module identified by module name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// moduleName - the name of module. +func (client ActivityClient) ListByModule(ctx context.Context, resourceGroupName string, automationAccountName string, moduleName string) (result ActivityListResultPage, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.ActivityClient", "ListByModule", err.Error()) + } + + result.fn = client.listByModuleNextResults + req, err := client.ListByModulePreparer(ctx, resourceGroupName, automationAccountName, moduleName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ActivityClient", "ListByModule", nil, "Failure preparing request") + return + } + + resp, err := client.ListByModuleSender(req) + if err != nil { + result.alr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ActivityClient", "ListByModule", resp, "Failure sending request") + return + } + + result.alr, err = client.ListByModuleResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ActivityClient", "ListByModule", resp, "Failure responding to request") + } + + return +} + +// ListByModulePreparer prepares the ListByModule request. +func (client ActivityClient) ListByModulePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, moduleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "moduleName": autorest.Encode("path", moduleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/activities", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByModuleSender sends the ListByModule request. The method will close the +// http.Response Body if it receives an error. +func (client ActivityClient) ListByModuleSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByModuleResponder handles the response to the ListByModule request. The method always +// closes the http.Response Body. +func (client ActivityClient) ListByModuleResponder(resp *http.Response) (result ActivityListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByModuleNextResults retrieves the next set of results, if any. +func (client ActivityClient) listByModuleNextResults(lastResults ActivityListResult) (result ActivityListResult, err error) { + req, err := lastResults.activityListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.ActivityClient", "listByModuleNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByModuleSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.ActivityClient", "listByModuleNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByModuleResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ActivityClient", "listByModuleNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByModuleComplete enumerates all values, automatically crossing page boundaries as required. +func (client ActivityClient) ListByModuleComplete(ctx context.Context, resourceGroupName string, automationAccountName string, moduleName string) (result ActivityListResultIterator, err error) { + result.page, err = client.ListByModule(ctx, resourceGroupName, automationAccountName, moduleName) + return +} diff --git a/services/preview/automation/mgmt/2018-01-15-preview/automation/agentregistrationinformation.go b/services/preview/automation/mgmt/2018-01-15-preview/automation/agentregistrationinformation.go new file mode 100644 index 000000000000..02d73956c48d --- /dev/null +++ b/services/preview/automation/mgmt/2018-01-15-preview/automation/agentregistrationinformation.go @@ -0,0 +1,195 @@ +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" +) + +// AgentRegistrationInformationClient is the automation Client +type AgentRegistrationInformationClient struct { + BaseClient +} + +// NewAgentRegistrationInformationClient creates an instance of the AgentRegistrationInformationClient client. +func NewAgentRegistrationInformationClient(subscriptionID string, countType1 CountType) AgentRegistrationInformationClient { + return NewAgentRegistrationInformationClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewAgentRegistrationInformationClientWithBaseURI creates an instance of the AgentRegistrationInformationClient +// client. +func NewAgentRegistrationInformationClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) AgentRegistrationInformationClient { + return AgentRegistrationInformationClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// Get retrieve the automation agent registration information. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +func (client AgentRegistrationInformationClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string) (result AgentRegistration, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.AgentRegistrationInformationClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AgentRegistrationInformationClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.AgentRegistrationInformationClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AgentRegistrationInformationClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client AgentRegistrationInformationClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-01-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/agentRegistrationInformation", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client AgentRegistrationInformationClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client AgentRegistrationInformationClient) GetResponder(resp *http.Response) (result AgentRegistration, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// RegenerateKey regenerate a primary or secondary agent registration key +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// parameters - the name of the agent registration key to be regenerated +func (client AgentRegistrationInformationClient) RegenerateKey(ctx context.Context, resourceGroupName string, automationAccountName string, parameters AgentRegistrationRegenerateKeyParameter) (result AgentRegistration, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.AgentRegistrationInformationClient", "RegenerateKey", err.Error()) + } + + req, err := client.RegenerateKeyPreparer(ctx, resourceGroupName, automationAccountName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AgentRegistrationInformationClient", "RegenerateKey", nil, "Failure preparing request") + return + } + + resp, err := client.RegenerateKeySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.AgentRegistrationInformationClient", "RegenerateKey", resp, "Failure sending request") + return + } + + result, err = client.RegenerateKeyResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AgentRegistrationInformationClient", "RegenerateKey", resp, "Failure responding to request") + } + + return +} + +// RegenerateKeyPreparer prepares the RegenerateKey request. +func (client AgentRegistrationInformationClient) RegenerateKeyPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, parameters AgentRegistrationRegenerateKeyParameter) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-01-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/agentRegistrationInformation/regenerateKey", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// RegenerateKeySender sends the RegenerateKey request. The method will close the +// http.Response Body if it receives an error. +func (client AgentRegistrationInformationClient) RegenerateKeySender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// RegenerateKeyResponder handles the response to the RegenerateKey request. The method always +// closes the http.Response Body. +func (client AgentRegistrationInformationClient) RegenerateKeyResponder(resp *http.Response) (result AgentRegistration, 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/preview/automation/mgmt/2018-01-15-preview/automation/certificate.go b/services/preview/automation/mgmt/2018-01-15-preview/automation/certificate.go new file mode 100644 index 000000000000..d0124ad01d04 --- /dev/null +++ b/services/preview/automation/mgmt/2018-01-15-preview/automation/certificate.go @@ -0,0 +1,461 @@ +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" +) + +// CertificateClient is the automation Client +type CertificateClient struct { + BaseClient +} + +// NewCertificateClient creates an instance of the CertificateClient client. +func NewCertificateClient(subscriptionID string, countType1 CountType) CertificateClient { + return NewCertificateClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewCertificateClientWithBaseURI creates an instance of the CertificateClient client. +func NewCertificateClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) CertificateClient { + return CertificateClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// CreateOrUpdate create a certificate. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// certificateName - the parameters supplied to the create or update certificate operation. +// parameters - the parameters supplied to the create or update certificate operation. +func (client CertificateClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, automationAccountName string, certificateName string, parameters CertificateCreateOrUpdateParameters) (result Certificate, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.CertificateCreateOrUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.CertificateCreateOrUpdateProperties.Base64Value", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("automation.CertificateClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, automationAccountName, certificateName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client CertificateClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, certificateName string, parameters CertificateCreateOrUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "certificateName": autorest.Encode("path", certificateName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client CertificateClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client CertificateClient) CreateOrUpdateResponder(resp *http.Response) (result Certificate, 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 delete the certificate. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// certificateName - the name of certificate. +func (client CertificateClient) Delete(ctx context.Context, resourceGroupName string, automationAccountName string, certificateName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.CertificateClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, automationAccountName, certificateName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client CertificateClient) DeletePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, certificateName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "certificateName": autorest.Encode("path", certificateName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client CertificateClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client CertificateClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get retrieve the certificate identified by certificate name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// certificateName - the name of certificate. +func (client CertificateClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string, certificateName string) (result Certificate, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.CertificateClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName, certificateName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client CertificateClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, certificateName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "certificateName": autorest.Encode("path", certificateName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client CertificateClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client CertificateClient) GetResponder(resp *http.Response) (result Certificate, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of certificates. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +func (client CertificateClient) ListByAutomationAccount(ctx context.Context, resourceGroupName string, automationAccountName string) (result CertificateListResultPage, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.CertificateClient", "ListByAutomationAccount", err.Error()) + } + + result.fn = client.listByAutomationAccountNextResults + req, err := client.ListByAutomationAccountPreparer(ctx, resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.clr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result.clr, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client CertificateClient) ListByAutomationAccountPreparer(ctx context.Context, resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates", 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 CertificateClient) 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 CertificateClient) ListByAutomationAccountResponder(resp *http.Response) (result CertificateListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByAutomationAccountNextResults retrieves the next set of results, if any. +func (client CertificateClient) listByAutomationAccountNextResults(lastResults CertificateListResult) (result CertificateListResult, err error) { + req, err := lastResults.certificateListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.CertificateClient", "listByAutomationAccountNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.CertificateClient", "listByAutomationAccountNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "listByAutomationAccountNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByAutomationAccountComplete enumerates all values, automatically crossing page boundaries as required. +func (client CertificateClient) ListByAutomationAccountComplete(ctx context.Context, resourceGroupName string, automationAccountName string) (result CertificateListResultIterator, err error) { + result.page, err = client.ListByAutomationAccount(ctx, resourceGroupName, automationAccountName) + return +} + +// Update update a certificate. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// certificateName - the parameters supplied to the update certificate operation. +// parameters - the parameters supplied to the update certificate operation. +func (client CertificateClient) Update(ctx context.Context, resourceGroupName string, automationAccountName string, certificateName string, parameters CertificateUpdateParameters) (result Certificate, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.CertificateClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, automationAccountName, certificateName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client CertificateClient) UpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, certificateName string, parameters CertificateUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "certificateName": autorest.Encode("path", certificateName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client CertificateClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client CertificateClient) UpdateResponder(resp *http.Response) (result Certificate, 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/preview/automation/mgmt/2018-01-15-preview/automation/client.go b/services/preview/automation/mgmt/2018-01-15-preview/automation/client.go new file mode 100644 index 000000000000..35ec8db368d7 --- /dev/null +++ b/services/preview/automation/mgmt/2018-01-15-preview/automation/client.go @@ -0,0 +1,53 @@ +// Package automation implements the Azure ARM Automation service API version . +// +// Automation Client +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 ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Automation + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Automation. +type BaseClient struct { + autorest.Client + BaseURI string + SubscriptionID string + CountType1 CountType +} + +// New creates an instance of the BaseClient client. +func New(subscriptionID string, countType1 CountType) BaseClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewWithBaseURI creates an instance of the BaseClient client. +func NewWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + CountType1: countType1, + } +} diff --git a/services/preview/automation/mgmt/2018-01-15-preview/automation/connection.go b/services/preview/automation/mgmt/2018-01-15-preview/automation/connection.go new file mode 100644 index 000000000000..34ebae556858 --- /dev/null +++ b/services/preview/automation/mgmt/2018-01-15-preview/automation/connection.go @@ -0,0 +1,462 @@ +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" +) + +// ConnectionClient is the automation Client +type ConnectionClient struct { + BaseClient +} + +// NewConnectionClient creates an instance of the ConnectionClient client. +func NewConnectionClient(subscriptionID string, countType1 CountType) ConnectionClient { + return NewConnectionClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewConnectionClientWithBaseURI creates an instance of the ConnectionClient client. +func NewConnectionClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) ConnectionClient { + return ConnectionClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// CreateOrUpdate create or update a connection. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// connectionName - the parameters supplied to the create or update connection operation. +// parameters - the parameters supplied to the create or update connection operation. +func (client ConnectionClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, automationAccountName string, connectionName string, parameters ConnectionCreateOrUpdateParameters) (result Connection, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ConnectionCreateOrUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ConnectionCreateOrUpdateProperties.ConnectionType", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("automation.ConnectionClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, automationAccountName, connectionName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ConnectionClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, connectionName string, parameters ConnectionCreateOrUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "connectionName": autorest.Encode("path", connectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ConnectionClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ConnectionClient) CreateOrUpdateResponder(resp *http.Response) (result Connection, 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 delete the connection. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// connectionName - the name of connection. +func (client ConnectionClient) Delete(ctx context.Context, resourceGroupName string, automationAccountName string, connectionName string) (result Connection, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.ConnectionClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, automationAccountName, connectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ConnectionClient) DeletePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, connectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "connectionName": autorest.Encode("path", connectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ConnectionClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ConnectionClient) DeleteResponder(resp *http.Response) (result Connection, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get retrieve the connection identified by connection name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// connectionName - the name of connection. +func (client ConnectionClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string, connectionName string) (result Connection, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.ConnectionClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName, connectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ConnectionClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, connectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "connectionName": autorest.Encode("path", connectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ConnectionClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ConnectionClient) GetResponder(resp *http.Response) (result Connection, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of connections. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +func (client ConnectionClient) ListByAutomationAccount(ctx context.Context, resourceGroupName string, automationAccountName string) (result ConnectionListResultPage, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.ConnectionClient", "ListByAutomationAccount", err.Error()) + } + + result.fn = client.listByAutomationAccountNextResults + req, err := client.ListByAutomationAccountPreparer(ctx, resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.clr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result.clr, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client ConnectionClient) ListByAutomationAccountPreparer(ctx context.Context, resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections", 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 ConnectionClient) 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 ConnectionClient) ListByAutomationAccountResponder(resp *http.Response) (result ConnectionListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByAutomationAccountNextResults retrieves the next set of results, if any. +func (client ConnectionClient) listByAutomationAccountNextResults(lastResults ConnectionListResult) (result ConnectionListResult, err error) { + req, err := lastResults.connectionListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.ConnectionClient", "listByAutomationAccountNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.ConnectionClient", "listByAutomationAccountNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "listByAutomationAccountNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByAutomationAccountComplete enumerates all values, automatically crossing page boundaries as required. +func (client ConnectionClient) ListByAutomationAccountComplete(ctx context.Context, resourceGroupName string, automationAccountName string) (result ConnectionListResultIterator, err error) { + result.page, err = client.ListByAutomationAccount(ctx, resourceGroupName, automationAccountName) + return +} + +// Update update a connection. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// connectionName - the parameters supplied to the update a connection operation. +// parameters - the parameters supplied to the update a connection operation. +func (client ConnectionClient) Update(ctx context.Context, resourceGroupName string, automationAccountName string, connectionName string, parameters ConnectionUpdateParameters) (result Connection, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.ConnectionClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, automationAccountName, connectionName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ConnectionClient) UpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, connectionName string, parameters ConnectionUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "connectionName": autorest.Encode("path", connectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client ConnectionClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ConnectionClient) UpdateResponder(resp *http.Response) (result Connection, 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/preview/automation/mgmt/2018-01-15-preview/automation/connectiontype.go b/services/preview/automation/mgmt/2018-01-15-preview/automation/connectiontype.go new file mode 100644 index 000000000000..d4277e164145 --- /dev/null +++ b/services/preview/automation/mgmt/2018-01-15-preview/automation/connectiontype.go @@ -0,0 +1,381 @@ +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" +) + +// ConnectionTypeClient is the automation Client +type ConnectionTypeClient struct { + BaseClient +} + +// NewConnectionTypeClient creates an instance of the ConnectionTypeClient client. +func NewConnectionTypeClient(subscriptionID string, countType1 CountType) ConnectionTypeClient { + return NewConnectionTypeClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewConnectionTypeClientWithBaseURI creates an instance of the ConnectionTypeClient client. +func NewConnectionTypeClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) ConnectionTypeClient { + return ConnectionTypeClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// CreateOrUpdate create a connectiontype. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// connectionTypeName - the parameters supplied to the create or update connectiontype operation. +// parameters - the parameters supplied to the create or update connectiontype operation. +func (client ConnectionTypeClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, automationAccountName string, connectionTypeName string, parameters ConnectionTypeCreateOrUpdateParameters) (result ConnectionType, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ConnectionTypeCreateOrUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ConnectionTypeCreateOrUpdateProperties.FieldDefinitions", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("automation.ConnectionTypeClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, automationAccountName, connectionTypeName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ConnectionTypeClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, connectionTypeName string, parameters ConnectionTypeCreateOrUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "connectionTypeName": autorest.Encode("path", connectionTypeName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes/{connectionTypeName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ConnectionTypeClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ConnectionTypeClient) CreateOrUpdateResponder(resp *http.Response) (result ConnectionType, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusConflict), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete the connectiontype. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// connectionTypeName - the name of connectiontype. +func (client ConnectionTypeClient) Delete(ctx context.Context, resourceGroupName string, automationAccountName string, connectionTypeName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.ConnectionTypeClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, automationAccountName, connectionTypeName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ConnectionTypeClient) DeletePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, connectionTypeName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "connectionTypeName": autorest.Encode("path", connectionTypeName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes/{connectionTypeName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ConnectionTypeClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ConnectionTypeClient) 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 retrieve the connectiontype identified by connectiontype name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// connectionTypeName - the name of connectiontype. +func (client ConnectionTypeClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string, connectionTypeName string) (result ConnectionType, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.ConnectionTypeClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName, connectionTypeName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ConnectionTypeClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, connectionTypeName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "connectionTypeName": autorest.Encode("path", connectionTypeName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes/{connectionTypeName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ConnectionTypeClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ConnectionTypeClient) GetResponder(resp *http.Response) (result ConnectionType, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of connectiontypes. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +func (client ConnectionTypeClient) ListByAutomationAccount(ctx context.Context, resourceGroupName string, automationAccountName string) (result ConnectionTypeListResultPage, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.ConnectionTypeClient", "ListByAutomationAccount", err.Error()) + } + + result.fn = client.listByAutomationAccountNextResults + req, err := client.ListByAutomationAccountPreparer(ctx, resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.ctlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result.ctlr, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client ConnectionTypeClient) ListByAutomationAccountPreparer(ctx context.Context, resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes", 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 ConnectionTypeClient) 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 ConnectionTypeClient) ListByAutomationAccountResponder(resp *http.Response) (result ConnectionTypeListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByAutomationAccountNextResults retrieves the next set of results, if any. +func (client ConnectionTypeClient) listByAutomationAccountNextResults(lastResults ConnectionTypeListResult) (result ConnectionTypeListResult, err error) { + req, err := lastResults.connectionTypeListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "listByAutomationAccountNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "listByAutomationAccountNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "listByAutomationAccountNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByAutomationAccountComplete enumerates all values, automatically crossing page boundaries as required. +func (client ConnectionTypeClient) ListByAutomationAccountComplete(ctx context.Context, resourceGroupName string, automationAccountName string) (result ConnectionTypeListResultIterator, err error) { + result.page, err = client.ListByAutomationAccount(ctx, resourceGroupName, automationAccountName) + return +} diff --git a/services/preview/automation/mgmt/2018-01-15-preview/automation/credential.go b/services/preview/automation/mgmt/2018-01-15-preview/automation/credential.go new file mode 100644 index 000000000000..ae5410ab911e --- /dev/null +++ b/services/preview/automation/mgmt/2018-01-15-preview/automation/credential.go @@ -0,0 +1,463 @@ +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" +) + +// CredentialClient is the automation Client +type CredentialClient struct { + BaseClient +} + +// NewCredentialClient creates an instance of the CredentialClient client. +func NewCredentialClient(subscriptionID string, countType1 CountType) CredentialClient { + return NewCredentialClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewCredentialClientWithBaseURI creates an instance of the CredentialClient client. +func NewCredentialClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) CredentialClient { + return CredentialClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// CreateOrUpdate create a credential. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// credentialName - the parameters supplied to the create or update credential operation. +// parameters - the parameters supplied to the create or update credential operation. +func (client CredentialClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, automationAccountName string, credentialName string, parameters CredentialCreateOrUpdateParameters) (result Credential, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.CredentialCreateOrUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.CredentialCreateOrUpdateProperties.UserName", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.CredentialCreateOrUpdateProperties.Password", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("automation.CredentialClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, automationAccountName, credentialName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client CredentialClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, credentialName string, parameters CredentialCreateOrUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "credentialName": autorest.Encode("path", credentialName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client CredentialClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client CredentialClient) CreateOrUpdateResponder(resp *http.Response) (result Credential, 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 delete the credential. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// credentialName - the name of credential. +func (client CredentialClient) Delete(ctx context.Context, resourceGroupName string, automationAccountName string, credentialName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.CredentialClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, automationAccountName, credentialName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client CredentialClient) DeletePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, credentialName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "credentialName": autorest.Encode("path", credentialName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client CredentialClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client CredentialClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get retrieve the credential identified by credential name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// credentialName - the name of credential. +func (client CredentialClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string, credentialName string) (result Credential, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.CredentialClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName, credentialName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client CredentialClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, credentialName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "credentialName": autorest.Encode("path", credentialName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client CredentialClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client CredentialClient) GetResponder(resp *http.Response) (result Credential, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of credentials. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +func (client CredentialClient) ListByAutomationAccount(ctx context.Context, resourceGroupName string, automationAccountName string) (result CredentialListResultPage, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.CredentialClient", "ListByAutomationAccount", err.Error()) + } + + result.fn = client.listByAutomationAccountNextResults + req, err := client.ListByAutomationAccountPreparer(ctx, resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.clr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result.clr, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client CredentialClient) ListByAutomationAccountPreparer(ctx context.Context, resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials", 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 CredentialClient) 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 CredentialClient) ListByAutomationAccountResponder(resp *http.Response) (result CredentialListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByAutomationAccountNextResults retrieves the next set of results, if any. +func (client CredentialClient) listByAutomationAccountNextResults(lastResults CredentialListResult) (result CredentialListResult, err error) { + req, err := lastResults.credentialListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.CredentialClient", "listByAutomationAccountNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.CredentialClient", "listByAutomationAccountNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "listByAutomationAccountNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByAutomationAccountComplete enumerates all values, automatically crossing page boundaries as required. +func (client CredentialClient) ListByAutomationAccountComplete(ctx context.Context, resourceGroupName string, automationAccountName string) (result CredentialListResultIterator, err error) { + result.page, err = client.ListByAutomationAccount(ctx, resourceGroupName, automationAccountName) + return +} + +// Update update a credential. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// credentialName - the parameters supplied to the Update credential operation. +// parameters - the parameters supplied to the Update credential operation. +func (client CredentialClient) Update(ctx context.Context, resourceGroupName string, automationAccountName string, credentialName string, parameters CredentialUpdateParameters) (result Credential, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.CredentialClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, automationAccountName, credentialName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client CredentialClient) UpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, credentialName string, parameters CredentialUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "credentialName": autorest.Encode("path", credentialName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client CredentialClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client CredentialClient) UpdateResponder(resp *http.Response) (result Credential, 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/preview/automation/mgmt/2018-01-15-preview/automation/dsccompilationjob.go b/services/preview/automation/mgmt/2018-01-15-preview/automation/dsccompilationjob.go new file mode 100644 index 000000000000..673577eaafd8 --- /dev/null +++ b/services/preview/automation/mgmt/2018-01-15-preview/automation/dsccompilationjob.go @@ -0,0 +1,392 @@ +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" + "github.com/satori/go.uuid" + "net/http" +) + +// DscCompilationJobClient is the automation Client +type DscCompilationJobClient struct { + BaseClient +} + +// NewDscCompilationJobClient creates an instance of the DscCompilationJobClient client. +func NewDscCompilationJobClient(subscriptionID string, countType1 CountType) DscCompilationJobClient { + return NewDscCompilationJobClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewDscCompilationJobClientWithBaseURI creates an instance of the DscCompilationJobClient client. +func NewDscCompilationJobClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) DscCompilationJobClient { + return DscCompilationJobClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// Create creates the Dsc compilation job of the configuration. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// compilationJobName - the the DSC configuration Id. +// parameters - the parameters supplied to the create compilation job operation. +func (client DscCompilationJobClient) Create(ctx context.Context, resourceGroupName string, automationAccountName string, compilationJobName string, parameters DscCompilationJobCreateParameters) (result DscCompilationJobCreateFuture, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.DscCompilationJobCreateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.DscCompilationJobCreateProperties.Configuration", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("automation.DscCompilationJobClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, automationAccountName, compilationJobName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobClient", "Create", nil, "Failure preparing request") + return + } + + result, err = client.CreateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobClient", "Create", result.Response(), "Failure sending request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client DscCompilationJobClient) CreatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, compilationJobName string, parameters DscCompilationJobCreateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "compilationJobName": autorest.Encode("path", compilationJobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-01-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{compilationJobName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client DscCompilationJobClient) CreateSender(req *http.Request) (future DscCompilationJobCreateFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client DscCompilationJobClient) CreateResponder(resp *http.Response) (result DscCompilationJob, 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 +} + +// Get retrieve the Dsc configuration compilation job identified by job id. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// compilationJobName - the the DSC configuration Id. +func (client DscCompilationJobClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string, compilationJobName string) (result DscCompilationJob, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.DscCompilationJobClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName, compilationJobName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client DscCompilationJobClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, compilationJobName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "compilationJobName": autorest.Encode("path", compilationJobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-01-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{compilationJobName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client DscCompilationJobClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DscCompilationJobClient) GetResponder(resp *http.Response) (result DscCompilationJob, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetStream retrieve the job stream identified by job stream id. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// jobID - the job id. +// jobStreamID - the job stream id. +func (client DscCompilationJobClient) GetStream(ctx context.Context, resourceGroupName string, automationAccountName string, jobID uuid.UUID, jobStreamID string) (result JobStream, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.DscCompilationJobClient", "GetStream", err.Error()) + } + + req, err := client.GetStreamPreparer(ctx, resourceGroupName, automationAccountName, jobID, jobStreamID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobClient", "GetStream", nil, "Failure preparing request") + return + } + + resp, err := client.GetStreamSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobClient", "GetStream", resp, "Failure sending request") + return + } + + result, err = client.GetStreamResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobClient", "GetStream", resp, "Failure responding to request") + } + + return +} + +// GetStreamPreparer prepares the GetStream request. +func (client DscCompilationJobClient) GetStreamPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, jobID uuid.UUID, jobStreamID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "jobId": autorest.Encode("path", jobID), + "jobStreamId": autorest.Encode("path", jobStreamID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-01-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{jobId}/streams/{jobStreamId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetStreamSender sends the GetStream request. The method will close the +// http.Response Body if it receives an error. +func (client DscCompilationJobClient) GetStreamSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetStreamResponder handles the response to the GetStream request. The method always +// closes the http.Response Body. +func (client DscCompilationJobClient) GetStreamResponder(resp *http.Response) (result JobStream, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of dsc compilation jobs. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// filter - the filter to apply on the operation. +func (client DscCompilationJobClient) ListByAutomationAccount(ctx context.Context, resourceGroupName string, automationAccountName string, filter string) (result DscCompilationJobListResultPage, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.DscCompilationJobClient", "ListByAutomationAccount", err.Error()) + } + + result.fn = client.listByAutomationAccountNextResults + req, err := client.ListByAutomationAccountPreparer(ctx, resourceGroupName, automationAccountName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.dcjlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result.dcjlr, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client DscCompilationJobClient) ListByAutomationAccountPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-01-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs", 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 DscCompilationJobClient) 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 DscCompilationJobClient) ListByAutomationAccountResponder(resp *http.Response) (result DscCompilationJobListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByAutomationAccountNextResults retrieves the next set of results, if any. +func (client DscCompilationJobClient) listByAutomationAccountNextResults(lastResults DscCompilationJobListResult) (result DscCompilationJobListResult, err error) { + req, err := lastResults.dscCompilationJobListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.DscCompilationJobClient", "listByAutomationAccountNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.DscCompilationJobClient", "listByAutomationAccountNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobClient", "listByAutomationAccountNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByAutomationAccountComplete enumerates all values, automatically crossing page boundaries as required. +func (client DscCompilationJobClient) ListByAutomationAccountComplete(ctx context.Context, resourceGroupName string, automationAccountName string, filter string) (result DscCompilationJobListResultIterator, err error) { + result.page, err = client.ListByAutomationAccount(ctx, resourceGroupName, automationAccountName, filter) + return +} diff --git a/services/preview/automation/mgmt/2018-01-15-preview/automation/dsccompilationjobstream.go b/services/preview/automation/mgmt/2018-01-15-preview/automation/dsccompilationjobstream.go new file mode 100644 index 000000000000..19ecbc9d0fab --- /dev/null +++ b/services/preview/automation/mgmt/2018-01-15-preview/automation/dsccompilationjobstream.go @@ -0,0 +1,119 @@ +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" + "github.com/satori/go.uuid" + "net/http" +) + +// DscCompilationJobStreamClient is the automation Client +type DscCompilationJobStreamClient struct { + BaseClient +} + +// NewDscCompilationJobStreamClient creates an instance of the DscCompilationJobStreamClient client. +func NewDscCompilationJobStreamClient(subscriptionID string, countType1 CountType) DscCompilationJobStreamClient { + return NewDscCompilationJobStreamClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewDscCompilationJobStreamClientWithBaseURI creates an instance of the DscCompilationJobStreamClient client. +func NewDscCompilationJobStreamClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) DscCompilationJobStreamClient { + return DscCompilationJobStreamClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// ListByJob retrieve all the job streams for the compilation Job. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// jobID - the job id. +func (client DscCompilationJobStreamClient) ListByJob(ctx context.Context, resourceGroupName string, automationAccountName string, jobID uuid.UUID) (result JobStreamListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.DscCompilationJobStreamClient", "ListByJob", err.Error()) + } + + req, err := client.ListByJobPreparer(ctx, resourceGroupName, automationAccountName, jobID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobStreamClient", "ListByJob", nil, "Failure preparing request") + return + } + + resp, err := client.ListByJobSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobStreamClient", "ListByJob", resp, "Failure sending request") + return + } + + result, err = client.ListByJobResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobStreamClient", "ListByJob", resp, "Failure responding to request") + } + + return +} + +// ListByJobPreparer prepares the ListByJob request. +func (client DscCompilationJobStreamClient) ListByJobPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, jobID uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "jobId": autorest.Encode("path", jobID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-01-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{jobId}/streams", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByJobSender sends the ListByJob request. The method will close the +// http.Response Body if it receives an error. +func (client DscCompilationJobStreamClient) ListByJobSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByJobResponder handles the response to the ListByJob request. The method always +// closes the http.Response Body. +func (client DscCompilationJobStreamClient) ListByJobResponder(resp *http.Response) (result JobStreamListResult, 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/preview/automation/mgmt/2018-01-15-preview/automation/dscconfiguration.go b/services/preview/automation/mgmt/2018-01-15-preview/automation/dscconfiguration.go new file mode 100644 index 000000000000..bf7c044b9ad5 --- /dev/null +++ b/services/preview/automation/mgmt/2018-01-15-preview/automation/dscconfiguration.go @@ -0,0 +1,561 @@ +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" +) + +// DscConfigurationClient is the automation Client +type DscConfigurationClient struct { + BaseClient +} + +// NewDscConfigurationClient creates an instance of the DscConfigurationClient client. +func NewDscConfigurationClient(subscriptionID string, countType1 CountType) DscConfigurationClient { + return NewDscConfigurationClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewDscConfigurationClientWithBaseURI creates an instance of the DscConfigurationClient client. +func NewDscConfigurationClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) DscConfigurationClient { + return DscConfigurationClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// CreateOrUpdate create the configuration identified by configuration name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// configurationName - the create or update parameters for configuration. +// parameters - the create or update parameters for configuration. +func (client DscConfigurationClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, automationAccountName string, configurationName string, parameters DscConfigurationCreateOrUpdateParameters) (result DscConfiguration, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.DscConfigurationCreateOrUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.DscConfigurationCreateOrUpdateProperties.Source", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.DscConfigurationCreateOrUpdateProperties.Source.Hash", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.DscConfigurationCreateOrUpdateProperties.Source.Hash.Algorithm", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.DscConfigurationCreateOrUpdateProperties.Source.Hash.Value", Name: validation.Null, Rule: true, Chain: nil}, + }}, + }}, + }}}}}); err != nil { + return result, validation.NewError("automation.DscConfigurationClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, automationAccountName, configurationName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client DscConfigurationClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, configurationName string, parameters DscConfigurationCreateOrUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "configurationName": autorest.Encode("path", configurationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client DscConfigurationClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client DscConfigurationClient) CreateOrUpdateResponder(resp *http.Response) (result DscConfiguration, 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 delete the dsc configuration identified by configuration name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// configurationName - the configuration name. +func (client DscConfigurationClient) Delete(ctx context.Context, resourceGroupName string, automationAccountName string, configurationName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.DscConfigurationClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, automationAccountName, configurationName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client DscConfigurationClient) DeletePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, configurationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "configurationName": autorest.Encode("path", configurationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client DscConfigurationClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client DscConfigurationClient) 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 retrieve the configuration identified by configuration name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// configurationName - the configuration name. +func (client DscConfigurationClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string, configurationName string) (result DscConfiguration, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.DscConfigurationClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName, configurationName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client DscConfigurationClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, configurationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "configurationName": autorest.Encode("path", configurationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client DscConfigurationClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DscConfigurationClient) GetResponder(resp *http.Response) (result DscConfiguration, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetContent retrieve the configuration script identified by configuration name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// configurationName - the configuration name. +func (client DscConfigurationClient) GetContent(ctx context.Context, resourceGroupName string, automationAccountName string, configurationName string) (result ReadCloser, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.DscConfigurationClient", "GetContent", err.Error()) + } + + req, err := client.GetContentPreparer(ctx, resourceGroupName, automationAccountName, configurationName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "GetContent", nil, "Failure preparing request") + return + } + + resp, err := client.GetContentSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "GetContent", resp, "Failure sending request") + return + } + + result, err = client.GetContentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "GetContent", resp, "Failure responding to request") + } + + return +} + +// GetContentPreparer prepares the GetContent request. +func (client DscConfigurationClient) GetContentPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, configurationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "configurationName": autorest.Encode("path", configurationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}/content", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetContentSender sends the GetContent request. The method will close the +// http.Response Body if it receives an error. +func (client DscConfigurationClient) GetContentSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetContentResponder handles the response to the GetContent request. The method always +// closes the http.Response Body. +func (client DscConfigurationClient) GetContentResponder(resp *http.Response) (result ReadCloser, err error) { + result.Value = &resp.Body + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK)) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of configurations. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// filter - the filter to apply on the operation. +// skip - the number of rows to skip. +// top - the the number of rows to take. +// inlinecount - return total rows. +func (client DscConfigurationClient) ListByAutomationAccount(ctx context.Context, resourceGroupName string, automationAccountName string, filter string, skip *int32, top *int32, inlinecount string) (result DscConfigurationListResultPage, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.DscConfigurationClient", "ListByAutomationAccount", err.Error()) + } + + result.fn = client.listByAutomationAccountNextResults + req, err := client.ListByAutomationAccountPreparer(ctx, resourceGroupName, automationAccountName, filter, skip, top, inlinecount) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.dclr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result.dclr, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client DscConfigurationClient) ListByAutomationAccountPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, filter string, skip *int32, top *int32, inlinecount string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if len(inlinecount) > 0 { + queryParameters["$inlinecount"] = autorest.Encode("query", inlinecount) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations", 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 DscConfigurationClient) 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 DscConfigurationClient) ListByAutomationAccountResponder(resp *http.Response) (result DscConfigurationListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByAutomationAccountNextResults retrieves the next set of results, if any. +func (client DscConfigurationClient) listByAutomationAccountNextResults(lastResults DscConfigurationListResult) (result DscConfigurationListResult, err error) { + req, err := lastResults.dscConfigurationListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "listByAutomationAccountNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "listByAutomationAccountNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "listByAutomationAccountNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByAutomationAccountComplete enumerates all values, automatically crossing page boundaries as required. +func (client DscConfigurationClient) ListByAutomationAccountComplete(ctx context.Context, resourceGroupName string, automationAccountName string, filter string, skip *int32, top *int32, inlinecount string) (result DscConfigurationListResultIterator, err error) { + result.page, err = client.ListByAutomationAccount(ctx, resourceGroupName, automationAccountName, filter, skip, top, inlinecount) + return +} + +// Update create the configuration identified by configuration name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// configurationName - the create or update parameters for configuration. +// parameters - the create or update parameters for configuration. +func (client DscConfigurationClient) Update(ctx context.Context, resourceGroupName string, automationAccountName string, configurationName string, parameters *DscConfigurationUpdateParameters) (result DscConfiguration, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.DscConfigurationClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, automationAccountName, configurationName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client DscConfigurationClient) UpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, configurationName string, parameters *DscConfigurationUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "configurationName": autorest.Encode("path", configurationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if parameters != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(parameters)) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client DscConfigurationClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client DscConfigurationClient) UpdateResponder(resp *http.Response) (result DscConfiguration, 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/preview/automation/mgmt/2018-01-15-preview/automation/dscnode.go b/services/preview/automation/mgmt/2018-01-15-preview/automation/dscnode.go new file mode 100644 index 000000000000..c850d333e6d1 --- /dev/null +++ b/services/preview/automation/mgmt/2018-01-15-preview/automation/dscnode.go @@ -0,0 +1,394 @@ +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" +) + +// DscNodeClient is the automation Client +type DscNodeClient struct { + BaseClient +} + +// NewDscNodeClient creates an instance of the DscNodeClient client. +func NewDscNodeClient(subscriptionID string, countType1 CountType) DscNodeClient { + return NewDscNodeClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewDscNodeClientWithBaseURI creates an instance of the DscNodeClient client. +func NewDscNodeClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) DscNodeClient { + return DscNodeClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// Delete delete the dsc node identified by node id. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// nodeID - the node id. +func (client DscNodeClient) Delete(ctx context.Context, resourceGroupName string, automationAccountName string, nodeID string) (result DscNode, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.DscNodeClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, automationAccountName, nodeID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscNodeClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client DscNodeClient) DeletePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, nodeID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "nodeId": autorest.Encode("path", nodeID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-01-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client DscNodeClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client DscNodeClient) DeleteResponder(resp *http.Response) (result DscNode, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get retrieve the dsc node identified by node id. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// nodeID - the node id. +func (client DscNodeClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string, nodeID string) (result DscNode, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.DscNodeClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName, nodeID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscNodeClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client DscNodeClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, nodeID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "nodeId": autorest.Encode("path", nodeID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-01-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client DscNodeClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DscNodeClient) GetResponder(resp *http.Response) (result DscNode, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of dsc nodes. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// filter - the filter to apply on the operation. +// skip - the number of rows to skip. +// top - the the number of rows to take. +// inlinecount - return total rows. +func (client DscNodeClient) ListByAutomationAccount(ctx context.Context, resourceGroupName string, automationAccountName string, filter string, skip *int32, top *int32, inlinecount string) (result DscNodeListResultPage, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.DscNodeClient", "ListByAutomationAccount", err.Error()) + } + + result.fn = client.listByAutomationAccountNextResults + req, err := client.ListByAutomationAccountPreparer(ctx, resourceGroupName, automationAccountName, filter, skip, top, inlinecount) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.dnlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscNodeClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result.dnlr, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client DscNodeClient) ListByAutomationAccountPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, filter string, skip *int32, top *int32, inlinecount string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-01-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if len(inlinecount) > 0 { + queryParameters["$inlinecount"] = autorest.Encode("query", inlinecount) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes", 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 DscNodeClient) 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 DscNodeClient) ListByAutomationAccountResponder(resp *http.Response) (result DscNodeListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByAutomationAccountNextResults retrieves the next set of results, if any. +func (client DscNodeClient) listByAutomationAccountNextResults(lastResults DscNodeListResult) (result DscNodeListResult, err error) { + req, err := lastResults.dscNodeListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.DscNodeClient", "listByAutomationAccountNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.DscNodeClient", "listByAutomationAccountNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeClient", "listByAutomationAccountNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByAutomationAccountComplete enumerates all values, automatically crossing page boundaries as required. +func (client DscNodeClient) ListByAutomationAccountComplete(ctx context.Context, resourceGroupName string, automationAccountName string, filter string, skip *int32, top *int32, inlinecount string) (result DscNodeListResultIterator, err error) { + result.page, err = client.ListByAutomationAccount(ctx, resourceGroupName, automationAccountName, filter, skip, top, inlinecount) + return +} + +// Update update the dsc node. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// nodeID - parameters supplied to the update dsc node. +// dscNodeUpdateParameters - parameters supplied to the update dsc node. +func (client DscNodeClient) Update(ctx context.Context, resourceGroupName string, automationAccountName string, nodeID string, dscNodeUpdateParameters DscNodeUpdateParameters) (result DscNode, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.DscNodeClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, automationAccountName, nodeID, dscNodeUpdateParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscNodeClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client DscNodeClient) UpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, nodeID string, dscNodeUpdateParameters DscNodeUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "nodeId": autorest.Encode("path", nodeID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-01-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}", pathParameters), + autorest.WithJSON(dscNodeUpdateParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client DscNodeClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client DscNodeClient) UpdateResponder(resp *http.Response) (result DscNode, 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/preview/automation/mgmt/2018-01-15-preview/automation/dscnodeconfiguration.go b/services/preview/automation/mgmt/2018-01-15-preview/automation/dscnodeconfiguration.go new file mode 100644 index 000000000000..673ece89dfda --- /dev/null +++ b/services/preview/automation/mgmt/2018-01-15-preview/automation/dscnodeconfiguration.go @@ -0,0 +1,407 @@ +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" +) + +// DscNodeConfigurationClient is the automation Client +type DscNodeConfigurationClient struct { + BaseClient +} + +// NewDscNodeConfigurationClient creates an instance of the DscNodeConfigurationClient client. +func NewDscNodeConfigurationClient(subscriptionID string, countType1 CountType) DscNodeConfigurationClient { + return NewDscNodeConfigurationClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewDscNodeConfigurationClientWithBaseURI creates an instance of the DscNodeConfigurationClient client. +func NewDscNodeConfigurationClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) DscNodeConfigurationClient { + return DscNodeConfigurationClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// CreateOrUpdate create the node configuration identified by node configuration name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// nodeConfigurationName - the Dsc node configuration name. +// parameters - the create or update parameters for configuration. +func (client DscNodeConfigurationClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, automationAccountName string, nodeConfigurationName string, parameters DscNodeConfigurationCreateOrUpdateParameters) (result DscNodeConfigurationCreateOrUpdateFuture, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.DscNodeConfigurationCreateOrUpdateParametersProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.DscNodeConfigurationCreateOrUpdateParametersProperties.Source", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.DscNodeConfigurationCreateOrUpdateParametersProperties.Source.Hash", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.DscNodeConfigurationCreateOrUpdateParametersProperties.Source.Hash.Algorithm", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.DscNodeConfigurationCreateOrUpdateParametersProperties.Source.Hash.Value", Name: validation.Null, Rule: true, Chain: nil}, + }}, + }}, + {Target: "parameters.DscNodeConfigurationCreateOrUpdateParametersProperties.Configuration", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("automation.DscNodeConfigurationClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, automationAccountName, nodeConfigurationName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeConfigurationClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeConfigurationClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client DscNodeConfigurationClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, nodeConfigurationName string, parameters DscNodeConfigurationCreateOrUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "nodeConfigurationName": autorest.Encode("path", nodeConfigurationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-01-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations/{nodeConfigurationName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client DscNodeConfigurationClient) CreateOrUpdateSender(req *http.Request) (future DscNodeConfigurationCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client DscNodeConfigurationClient) CreateOrUpdateResponder(resp *http.Response) (result DscNodeConfiguration, 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 delete the Dsc node configurations by node configuration. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// nodeConfigurationName - the Dsc node configuration name. +func (client DscNodeConfigurationClient) Delete(ctx context.Context, resourceGroupName string, automationAccountName string, nodeConfigurationName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.DscNodeConfigurationClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, automationAccountName, nodeConfigurationName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeConfigurationClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.DscNodeConfigurationClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeConfigurationClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client DscNodeConfigurationClient) DeletePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, nodeConfigurationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "nodeConfigurationName": autorest.Encode("path", nodeConfigurationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-01-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations/{nodeConfigurationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client DscNodeConfigurationClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client DscNodeConfigurationClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get retrieve the Dsc node configurations by node configuration. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// nodeConfigurationName - the Dsc node configuration name. +func (client DscNodeConfigurationClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string, nodeConfigurationName string) (result DscNodeConfiguration, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.DscNodeConfigurationClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName, nodeConfigurationName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeConfigurationClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscNodeConfigurationClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeConfigurationClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client DscNodeConfigurationClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, nodeConfigurationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "nodeConfigurationName": autorest.Encode("path", nodeConfigurationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-01-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations/{nodeConfigurationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client DscNodeConfigurationClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DscNodeConfigurationClient) GetResponder(resp *http.Response) (result DscNodeConfiguration, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of dsc node configurations. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// filter - the filter to apply on the operation. +// skip - the number of rows to skip. +// top - the the number of rows to take. +// inlinecount - return total rows. +func (client DscNodeConfigurationClient) ListByAutomationAccount(ctx context.Context, resourceGroupName string, automationAccountName string, filter string, skip *int32, top *int32, inlinecount string) (result DscNodeConfigurationListResultPage, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.DscNodeConfigurationClient", "ListByAutomationAccount", err.Error()) + } + + result.fn = client.listByAutomationAccountNextResults + req, err := client.ListByAutomationAccountPreparer(ctx, resourceGroupName, automationAccountName, filter, skip, top, inlinecount) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeConfigurationClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.dnclr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscNodeConfigurationClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result.dnclr, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeConfigurationClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client DscNodeConfigurationClient) ListByAutomationAccountPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, filter string, skip *int32, top *int32, inlinecount string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-01-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if len(inlinecount) > 0 { + queryParameters["$inlinecount"] = autorest.Encode("query", inlinecount) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations", 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 DscNodeConfigurationClient) 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 DscNodeConfigurationClient) ListByAutomationAccountResponder(resp *http.Response) (result DscNodeConfigurationListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByAutomationAccountNextResults retrieves the next set of results, if any. +func (client DscNodeConfigurationClient) listByAutomationAccountNextResults(lastResults DscNodeConfigurationListResult) (result DscNodeConfigurationListResult, err error) { + req, err := lastResults.dscNodeConfigurationListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.DscNodeConfigurationClient", "listByAutomationAccountNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.DscNodeConfigurationClient", "listByAutomationAccountNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeConfigurationClient", "listByAutomationAccountNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByAutomationAccountComplete enumerates all values, automatically crossing page boundaries as required. +func (client DscNodeConfigurationClient) ListByAutomationAccountComplete(ctx context.Context, resourceGroupName string, automationAccountName string, filter string, skip *int32, top *int32, inlinecount string) (result DscNodeConfigurationListResultIterator, err error) { + result.page, err = client.ListByAutomationAccount(ctx, resourceGroupName, automationAccountName, filter, skip, top, inlinecount) + return +} diff --git a/services/preview/automation/mgmt/2018-01-15-preview/automation/fields.go b/services/preview/automation/mgmt/2018-01-15-preview/automation/fields.go new file mode 100644 index 000000000000..60ec0e5e6daf --- /dev/null +++ b/services/preview/automation/mgmt/2018-01-15-preview/automation/fields.go @@ -0,0 +1,120 @@ +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" +) + +// FieldsClient is the automation Client +type FieldsClient struct { + BaseClient +} + +// NewFieldsClient creates an instance of the FieldsClient client. +func NewFieldsClient(subscriptionID string, countType1 CountType) FieldsClient { + return NewFieldsClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewFieldsClientWithBaseURI creates an instance of the FieldsClient client. +func NewFieldsClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) FieldsClient { + return FieldsClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// ListByType retrieve a list of fields of a given type identified by module name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// moduleName - the name of module. +// typeName - the name of type. +func (client FieldsClient) ListByType(ctx context.Context, resourceGroupName string, automationAccountName string, moduleName string, typeName string) (result TypeFieldListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.FieldsClient", "ListByType", err.Error()) + } + + req, err := client.ListByTypePreparer(ctx, resourceGroupName, automationAccountName, moduleName, typeName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.FieldsClient", "ListByType", nil, "Failure preparing request") + return + } + + resp, err := client.ListByTypeSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.FieldsClient", "ListByType", resp, "Failure sending request") + return + } + + result, err = client.ListByTypeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.FieldsClient", "ListByType", resp, "Failure responding to request") + } + + return +} + +// ListByTypePreparer prepares the ListByType request. +func (client FieldsClient) ListByTypePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, moduleName string, typeName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "moduleName": autorest.Encode("path", moduleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "typeName": autorest.Encode("path", typeName), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/types/{typeName}/fields", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByTypeSender sends the ListByType request. The method will close the +// http.Response Body if it receives an error. +func (client FieldsClient) ListByTypeSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByTypeResponder handles the response to the ListByType request. The method always +// closes the http.Response Body. +func (client FieldsClient) ListByTypeResponder(resp *http.Response) (result TypeFieldListResult, 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/preview/automation/mgmt/2018-01-15-preview/automation/hybridrunbookworkergroup.go b/services/preview/automation/mgmt/2018-01-15-preview/automation/hybridrunbookworkergroup.go new file mode 100644 index 000000000000..35b70b811b0b --- /dev/null +++ b/services/preview/automation/mgmt/2018-01-15-preview/automation/hybridrunbookworkergroup.go @@ -0,0 +1,381 @@ +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" +) + +// HybridRunbookWorkerGroupClient is the automation Client +type HybridRunbookWorkerGroupClient struct { + BaseClient +} + +// NewHybridRunbookWorkerGroupClient creates an instance of the HybridRunbookWorkerGroupClient client. +func NewHybridRunbookWorkerGroupClient(subscriptionID string, countType1 CountType) HybridRunbookWorkerGroupClient { + return NewHybridRunbookWorkerGroupClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewHybridRunbookWorkerGroupClientWithBaseURI creates an instance of the HybridRunbookWorkerGroupClient client. +func NewHybridRunbookWorkerGroupClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) HybridRunbookWorkerGroupClient { + return HybridRunbookWorkerGroupClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// Delete delete a hybrid runbook worker group. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// hybridRunbookWorkerGroupName - the hybrid runbook worker group name +func (client HybridRunbookWorkerGroupClient) Delete(ctx context.Context, resourceGroupName string, automationAccountName string, hybridRunbookWorkerGroupName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.HybridRunbookWorkerGroupClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, automationAccountName, hybridRunbookWorkerGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client HybridRunbookWorkerGroupClient) DeletePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, hybridRunbookWorkerGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "hybridRunbookWorkerGroupName": autorest.Encode("path", hybridRunbookWorkerGroupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client HybridRunbookWorkerGroupClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client HybridRunbookWorkerGroupClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get retrieve a hybrid runbook worker group. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// hybridRunbookWorkerGroupName - the hybrid runbook worker group name +func (client HybridRunbookWorkerGroupClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string, hybridRunbookWorkerGroupName string) (result HybridRunbookWorkerGroup, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.HybridRunbookWorkerGroupClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName, hybridRunbookWorkerGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client HybridRunbookWorkerGroupClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, hybridRunbookWorkerGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "hybridRunbookWorkerGroupName": autorest.Encode("path", hybridRunbookWorkerGroupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client HybridRunbookWorkerGroupClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client HybridRunbookWorkerGroupClient) GetResponder(resp *http.Response) (result HybridRunbookWorkerGroup, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of hybrid runbook worker groups. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// filter - the filter to apply on the operation. +func (client HybridRunbookWorkerGroupClient) ListByAutomationAccount(ctx context.Context, resourceGroupName string, automationAccountName string, filter string) (result HybridRunbookWorkerGroupsListResultPage, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.HybridRunbookWorkerGroupClient", "ListByAutomationAccount", err.Error()) + } + + result.fn = client.listByAutomationAccountNextResults + req, err := client.ListByAutomationAccountPreparer(ctx, resourceGroupName, automationAccountName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.hrwglr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result.hrwglr, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client HybridRunbookWorkerGroupClient) ListByAutomationAccountPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups", 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 HybridRunbookWorkerGroupClient) 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 HybridRunbookWorkerGroupClient) ListByAutomationAccountResponder(resp *http.Response) (result HybridRunbookWorkerGroupsListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByAutomationAccountNextResults retrieves the next set of results, if any. +func (client HybridRunbookWorkerGroupClient) listByAutomationAccountNextResults(lastResults HybridRunbookWorkerGroupsListResult) (result HybridRunbookWorkerGroupsListResult, err error) { + req, err := lastResults.hybridRunbookWorkerGroupsListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "listByAutomationAccountNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "listByAutomationAccountNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "listByAutomationAccountNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByAutomationAccountComplete enumerates all values, automatically crossing page boundaries as required. +func (client HybridRunbookWorkerGroupClient) ListByAutomationAccountComplete(ctx context.Context, resourceGroupName string, automationAccountName string, filter string) (result HybridRunbookWorkerGroupsListResultIterator, err error) { + result.page, err = client.ListByAutomationAccount(ctx, resourceGroupName, automationAccountName, filter) + return +} + +// Update update a hybrid runbook worker group. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// hybridRunbookWorkerGroupName - the hybrid runbook worker group name +// parameters - the hybrid runbook worker group +func (client HybridRunbookWorkerGroupClient) Update(ctx context.Context, resourceGroupName string, automationAccountName string, hybridRunbookWorkerGroupName string, parameters HybridRunbookWorkerGroupUpdateParameters) (result HybridRunbookWorkerGroup, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.HybridRunbookWorkerGroupClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, automationAccountName, hybridRunbookWorkerGroupName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client HybridRunbookWorkerGroupClient) UpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, hybridRunbookWorkerGroupName string, parameters HybridRunbookWorkerGroupUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "hybridRunbookWorkerGroupName": autorest.Encode("path", hybridRunbookWorkerGroupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client HybridRunbookWorkerGroupClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client HybridRunbookWorkerGroupClient) UpdateResponder(resp *http.Response) (result HybridRunbookWorkerGroup, 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/preview/automation/mgmt/2018-01-15-preview/automation/job.go b/services/preview/automation/mgmt/2018-01-15-preview/automation/job.go new file mode 100644 index 000000000000..bf97a45f3be4 --- /dev/null +++ b/services/preview/automation/mgmt/2018-01-15-preview/automation/job.go @@ -0,0 +1,727 @@ +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" +) + +// JobClient is the automation Client +type JobClient struct { + BaseClient +} + +// NewJobClient creates an instance of the JobClient client. +func NewJobClient(subscriptionID string, countType1 CountType) JobClient { + return NewJobClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewJobClientWithBaseURI creates an instance of the JobClient client. +func NewJobClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) JobClient { + return JobClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// Create create a job of the runbook. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// jobName - the job name. +// parameters - the parameters supplied to the create job operation. +// clientRequestID - identifies this specific client request. +func (client JobClient) Create(ctx context.Context, resourceGroupName string, automationAccountName string, jobName string, parameters JobCreateParameters, clientRequestID string) (result Job, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.JobCreateProperties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.JobClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, automationAccountName, jobName, parameters, clientRequestID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.JobClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "Create", resp, "Failure responding to request") + } + + return +} + +// CreatePreparer prepares the Create request. +func (client JobClient) CreatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, jobName string, parameters JobCreateParameters, clientRequestID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-05-15-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + if len(clientRequestID) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("clientRequestId", autorest.String(clientRequestID))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client JobClient) CreateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client JobClient) CreateResponder(resp *http.Response) (result Job, 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 +} + +// Get retrieve the job identified by job name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// jobName - the job name. +// clientRequestID - identifies this specific client request. +func (client JobClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string, jobName string, clientRequestID string) (result Job, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.JobClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName, jobName, clientRequestID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.JobClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client JobClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, jobName string, clientRequestID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-05-15-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.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if len(clientRequestID) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("clientRequestId", autorest.String(clientRequestID))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client JobClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client JobClient) GetResponder(resp *http.Response) (result Job, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetOutput retrieve the job output identified by job name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// jobName - the name of the job to be created. +// clientRequestID - identifies this specific client request. +func (client JobClient) GetOutput(ctx context.Context, resourceGroupName string, automationAccountName string, jobName string, clientRequestID string) (result ReadCloser, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.JobClient", "GetOutput", err.Error()) + } + + req, err := client.GetOutputPreparer(ctx, resourceGroupName, automationAccountName, jobName, clientRequestID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "GetOutput", nil, "Failure preparing request") + return + } + + resp, err := client.GetOutputSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.JobClient", "GetOutput", resp, "Failure sending request") + return + } + + result, err = client.GetOutputResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "GetOutput", resp, "Failure responding to request") + } + + return +} + +// GetOutputPreparer prepares the GetOutput request. +func (client JobClient) GetOutputPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, jobName string, clientRequestID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-05-15-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.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/output", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if len(clientRequestID) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("clientRequestId", autorest.String(clientRequestID))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetOutputSender sends the GetOutput request. The method will close the +// http.Response Body if it receives an error. +func (client JobClient) GetOutputSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetOutputResponder handles the response to the GetOutput request. The method always +// closes the http.Response Body. +func (client JobClient) GetOutputResponder(resp *http.Response) (result ReadCloser, err error) { + result.Value = &resp.Body + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK)) + result.Response = autorest.Response{Response: resp} + return +} + +// GetRunbookContent retrieve the runbook content of the job identified by job name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// jobName - the job name. +// clientRequestID - identifies this specific client request. +func (client JobClient) GetRunbookContent(ctx context.Context, resourceGroupName string, automationAccountName string, jobName string, clientRequestID string) (result ReadCloser, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.JobClient", "GetRunbookContent", err.Error()) + } + + req, err := client.GetRunbookContentPreparer(ctx, resourceGroupName, automationAccountName, jobName, clientRequestID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "GetRunbookContent", nil, "Failure preparing request") + return + } + + resp, err := client.GetRunbookContentSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.JobClient", "GetRunbookContent", resp, "Failure sending request") + return + } + + result, err = client.GetRunbookContentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "GetRunbookContent", resp, "Failure responding to request") + } + + return +} + +// GetRunbookContentPreparer prepares the GetRunbookContent request. +func (client JobClient) GetRunbookContentPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, jobName string, clientRequestID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-05-15-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.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/runbookContent", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if len(clientRequestID) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("clientRequestId", autorest.String(clientRequestID))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetRunbookContentSender sends the GetRunbookContent request. The method will close the +// http.Response Body if it receives an error. +func (client JobClient) GetRunbookContentSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetRunbookContentResponder handles the response to the GetRunbookContent request. The method always +// closes the http.Response Body. +func (client JobClient) GetRunbookContentResponder(resp *http.Response) (result ReadCloser, err error) { + result.Value = &resp.Body + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK)) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of jobs. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// filter - the filter to apply on the operation. +// clientRequestID - identifies this specific client request. +func (client JobClient) ListByAutomationAccount(ctx context.Context, resourceGroupName string, automationAccountName string, filter string, clientRequestID string) (result JobListResultV2Page, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.JobClient", "ListByAutomationAccount", err.Error()) + } + + result.fn = client.listByAutomationAccountNextResults + req, err := client.ListByAutomationAccountPreparer(ctx, resourceGroupName, automationAccountName, filter, clientRequestID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.jlrv.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.JobClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result.jlrv, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client JobClient) ListByAutomationAccountPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, filter string, clientRequestID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-05-15-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if len(clientRequestID) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("clientRequestId", autorest.String(clientRequestID))) + } + 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 JobClient) 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 JobClient) ListByAutomationAccountResponder(resp *http.Response) (result JobListResultV2, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByAutomationAccountNextResults retrieves the next set of results, if any. +func (client JobClient) listByAutomationAccountNextResults(lastResults JobListResultV2) (result JobListResultV2, err error) { + req, err := lastResults.jobListResultV2Preparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.JobClient", "listByAutomationAccountNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.JobClient", "listByAutomationAccountNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "listByAutomationAccountNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByAutomationAccountComplete enumerates all values, automatically crossing page boundaries as required. +func (client JobClient) ListByAutomationAccountComplete(ctx context.Context, resourceGroupName string, automationAccountName string, filter string, clientRequestID string) (result JobListResultV2Iterator, err error) { + result.page, err = client.ListByAutomationAccount(ctx, resourceGroupName, automationAccountName, filter, clientRequestID) + return +} + +// Resume resume the job identified by jobName. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// jobName - the job name. +// clientRequestID - identifies this specific client request. +func (client JobClient) Resume(ctx context.Context, resourceGroupName string, automationAccountName string, jobName string, clientRequestID string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.JobClient", "Resume", err.Error()) + } + + req, err := client.ResumePreparer(ctx, resourceGroupName, automationAccountName, jobName, clientRequestID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "Resume", nil, "Failure preparing request") + return + } + + resp, err := client.ResumeSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.JobClient", "Resume", resp, "Failure sending request") + return + } + + result, err = client.ResumeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "Resume", resp, "Failure responding to request") + } + + return +} + +// ResumePreparer prepares the Resume request. +func (client JobClient) ResumePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, jobName string, clientRequestID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-05-15-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.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/resume", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if len(clientRequestID) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("clientRequestId", autorest.String(clientRequestID))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ResumeSender sends the Resume request. The method will close the +// http.Response Body if it receives an error. +func (client JobClient) ResumeSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ResumeResponder handles the response to the Resume request. The method always +// closes the http.Response Body. +func (client JobClient) ResumeResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Stop stop the job identified by jobName. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// jobName - the job name. +// clientRequestID - identifies this specific client request. +func (client JobClient) Stop(ctx context.Context, resourceGroupName string, automationAccountName string, jobName string, clientRequestID string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.JobClient", "Stop", err.Error()) + } + + req, err := client.StopPreparer(ctx, resourceGroupName, automationAccountName, jobName, clientRequestID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "Stop", nil, "Failure preparing request") + return + } + + resp, err := client.StopSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.JobClient", "Stop", resp, "Failure sending request") + return + } + + result, err = client.StopResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "Stop", resp, "Failure responding to request") + } + + return +} + +// StopPreparer prepares the Stop request. +func (client JobClient) StopPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, jobName string, clientRequestID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-05-15-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.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/stop", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if len(clientRequestID) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("clientRequestId", autorest.String(clientRequestID))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// StopSender sends the Stop request. The method will close the +// http.Response Body if it receives an error. +func (client JobClient) StopSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// StopResponder handles the response to the Stop request. The method always +// closes the http.Response Body. +func (client JobClient) StopResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Suspend suspend the job identified by job name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// jobName - the job name. +// clientRequestID - identifies this specific client request. +func (client JobClient) Suspend(ctx context.Context, resourceGroupName string, automationAccountName string, jobName string, clientRequestID string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.JobClient", "Suspend", err.Error()) + } + + req, err := client.SuspendPreparer(ctx, resourceGroupName, automationAccountName, jobName, clientRequestID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "Suspend", nil, "Failure preparing request") + return + } + + resp, err := client.SuspendSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.JobClient", "Suspend", resp, "Failure sending request") + return + } + + result, err = client.SuspendResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "Suspend", resp, "Failure responding to request") + } + + return +} + +// SuspendPreparer prepares the Suspend request. +func (client JobClient) SuspendPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, jobName string, clientRequestID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-05-15-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.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/suspend", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if len(clientRequestID) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("clientRequestId", autorest.String(clientRequestID))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// SuspendSender sends the Suspend request. The method will close the +// http.Response Body if it receives an error. +func (client JobClient) SuspendSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// SuspendResponder handles the response to the Suspend request. The method always +// closes the http.Response Body. +func (client JobClient) SuspendResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/services/preview/automation/mgmt/2018-01-15-preview/automation/jobschedule.go b/services/preview/automation/mgmt/2018-01-15-preview/automation/jobschedule.go new file mode 100644 index 000000000000..2d9c35c03ddf --- /dev/null +++ b/services/preview/automation/mgmt/2018-01-15-preview/automation/jobschedule.go @@ -0,0 +1,387 @@ +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" + "github.com/satori/go.uuid" + "net/http" +) + +// JobScheduleClient is the automation Client +type JobScheduleClient struct { + BaseClient +} + +// NewJobScheduleClient creates an instance of the JobScheduleClient client. +func NewJobScheduleClient(subscriptionID string, countType1 CountType) JobScheduleClient { + return NewJobScheduleClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewJobScheduleClientWithBaseURI creates an instance of the JobScheduleClient client. +func NewJobScheduleClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) JobScheduleClient { + return JobScheduleClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// Create create a job schedule. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// jobScheduleID - the job schedule name. +// parameters - the parameters supplied to the create job schedule operation. +func (client JobScheduleClient) Create(ctx context.Context, resourceGroupName string, automationAccountName string, jobScheduleID uuid.UUID, parameters JobScheduleCreateParameters) (result JobSchedule, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.JobScheduleCreateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.JobScheduleCreateProperties.Schedule", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.JobScheduleCreateProperties.Runbook", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("automation.JobScheduleClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, automationAccountName, jobScheduleID, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobScheduleClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.JobScheduleClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobScheduleClient", "Create", resp, "Failure responding to request") + } + + return +} + +// CreatePreparer prepares the Create request. +func (client JobScheduleClient) CreatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, jobScheduleID uuid.UUID, parameters JobScheduleCreateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "jobScheduleId": autorest.Encode("path", jobScheduleID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules/{jobScheduleId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client JobScheduleClient) CreateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client JobScheduleClient) CreateResponder(resp *http.Response) (result JobSchedule, 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 delete the job schedule identified by job schedule name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// jobScheduleID - the job schedule name. +func (client JobScheduleClient) Delete(ctx context.Context, resourceGroupName string, automationAccountName string, jobScheduleID uuid.UUID) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.JobScheduleClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, automationAccountName, jobScheduleID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobScheduleClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.JobScheduleClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobScheduleClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client JobScheduleClient) DeletePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, jobScheduleID uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "jobScheduleId": autorest.Encode("path", jobScheduleID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules/{jobScheduleId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client JobScheduleClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client JobScheduleClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get retrieve the job schedule identified by job schedule name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// jobScheduleID - the job schedule name. +func (client JobScheduleClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string, jobScheduleID uuid.UUID) (result JobSchedule, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.JobScheduleClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName, jobScheduleID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobScheduleClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.JobScheduleClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobScheduleClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client JobScheduleClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, jobScheduleID uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "jobScheduleId": autorest.Encode("path", jobScheduleID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules/{jobScheduleId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client JobScheduleClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client JobScheduleClient) GetResponder(resp *http.Response) (result JobSchedule, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of job schedules. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// filter - the filter to apply on the operation. +func (client JobScheduleClient) ListByAutomationAccount(ctx context.Context, resourceGroupName string, automationAccountName string, filter string) (result JobScheduleListResultPage, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.JobScheduleClient", "ListByAutomationAccount", err.Error()) + } + + result.fn = client.listByAutomationAccountNextResults + req, err := client.ListByAutomationAccountPreparer(ctx, resourceGroupName, automationAccountName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobScheduleClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.jslr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.JobScheduleClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result.jslr, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobScheduleClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client JobScheduleClient) ListByAutomationAccountPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules", 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 JobScheduleClient) 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 JobScheduleClient) ListByAutomationAccountResponder(resp *http.Response) (result JobScheduleListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByAutomationAccountNextResults retrieves the next set of results, if any. +func (client JobScheduleClient) listByAutomationAccountNextResults(lastResults JobScheduleListResult) (result JobScheduleListResult, err error) { + req, err := lastResults.jobScheduleListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.JobScheduleClient", "listByAutomationAccountNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.JobScheduleClient", "listByAutomationAccountNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobScheduleClient", "listByAutomationAccountNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByAutomationAccountComplete enumerates all values, automatically crossing page boundaries as required. +func (client JobScheduleClient) ListByAutomationAccountComplete(ctx context.Context, resourceGroupName string, automationAccountName string, filter string) (result JobScheduleListResultIterator, err error) { + result.page, err = client.ListByAutomationAccount(ctx, resourceGroupName, automationAccountName, filter) + return +} diff --git a/services/preview/automation/mgmt/2018-01-15-preview/automation/jobstream.go b/services/preview/automation/mgmt/2018-01-15-preview/automation/jobstream.go new file mode 100644 index 000000000000..441700fcafe1 --- /dev/null +++ b/services/preview/automation/mgmt/2018-01-15-preview/automation/jobstream.go @@ -0,0 +1,239 @@ +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" +) + +// JobStreamClient is the automation Client +type JobStreamClient struct { + BaseClient +} + +// NewJobStreamClient creates an instance of the JobStreamClient client. +func NewJobStreamClient(subscriptionID string, countType1 CountType) JobStreamClient { + return NewJobStreamClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewJobStreamClientWithBaseURI creates an instance of the JobStreamClient client. +func NewJobStreamClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) JobStreamClient { + return JobStreamClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// Get retrieve the job stream identified by job stream id. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// jobName - the job name. +// jobStreamID - the job stream id. +// clientRequestID - identifies this specific client request. +func (client JobStreamClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string, jobName string, jobStreamID string, clientRequestID string) (result JobStream, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.JobStreamClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName, jobName, jobStreamID, clientRequestID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobStreamClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.JobStreamClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobStreamClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client JobStreamClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, jobName string, jobStreamID string, clientRequestID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "jobName": autorest.Encode("path", jobName), + "jobStreamId": autorest.Encode("path", jobStreamID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-05-15-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.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/streams/{jobStreamId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if len(clientRequestID) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("clientRequestId", autorest.String(clientRequestID))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client JobStreamClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client JobStreamClient) GetResponder(resp *http.Response) (result JobStream, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByJob retrieve a list of jobs streams identified by job name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// jobName - the job name. +// filter - the filter to apply on the operation. +// clientRequestID - identifies this specific client request. +func (client JobStreamClient) ListByJob(ctx context.Context, resourceGroupName string, automationAccountName string, jobName string, filter string, clientRequestID string) (result JobStreamListResultPage, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.JobStreamClient", "ListByJob", err.Error()) + } + + result.fn = client.listByJobNextResults + req, err := client.ListByJobPreparer(ctx, resourceGroupName, automationAccountName, jobName, filter, clientRequestID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobStreamClient", "ListByJob", nil, "Failure preparing request") + return + } + + resp, err := client.ListByJobSender(req) + if err != nil { + result.jslr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.JobStreamClient", "ListByJob", resp, "Failure sending request") + return + } + + result.jslr, err = client.ListByJobResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobStreamClient", "ListByJob", resp, "Failure responding to request") + } + + return +} + +// ListByJobPreparer prepares the ListByJob request. +func (client JobStreamClient) ListByJobPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, jobName string, filter string, clientRequestID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-05-15-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/streams", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if len(clientRequestID) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("clientRequestId", autorest.String(clientRequestID))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByJobSender sends the ListByJob request. The method will close the +// http.Response Body if it receives an error. +func (client JobStreamClient) ListByJobSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByJobResponder handles the response to the ListByJob request. The method always +// closes the http.Response Body. +func (client JobStreamClient) ListByJobResponder(resp *http.Response) (result JobStreamListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByJobNextResults retrieves the next set of results, if any. +func (client JobStreamClient) listByJobNextResults(lastResults JobStreamListResult) (result JobStreamListResult, err error) { + req, err := lastResults.jobStreamListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.JobStreamClient", "listByJobNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByJobSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.JobStreamClient", "listByJobNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByJobResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobStreamClient", "listByJobNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByJobComplete enumerates all values, automatically crossing page boundaries as required. +func (client JobStreamClient) ListByJobComplete(ctx context.Context, resourceGroupName string, automationAccountName string, jobName string, filter string, clientRequestID string) (result JobStreamListResultIterator, err error) { + result.page, err = client.ListByJob(ctx, resourceGroupName, automationAccountName, jobName, filter, clientRequestID) + return +} diff --git a/services/preview/automation/mgmt/2018-01-15-preview/automation/keys.go b/services/preview/automation/mgmt/2018-01-15-preview/automation/keys.go new file mode 100644 index 000000000000..8d53d162cabc --- /dev/null +++ b/services/preview/automation/mgmt/2018-01-15-preview/automation/keys.go @@ -0,0 +1,116 @@ +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, countType1 CountType) KeysClient { + return NewKeysClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewKeysClientWithBaseURI creates an instance of the KeysClient client. +func NewKeysClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) KeysClient { + return KeysClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// ListByAutomationAccount retrieve the automation keys for an account. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +func (client KeysClient) ListByAutomationAccount(ctx context.Context, resourceGroupName string, automationAccountName string) (result KeyListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.KeysClient", "ListByAutomationAccount", err.Error()) + } + + req, err := client.ListByAutomationAccountPreparer(ctx, resourceGroupName, 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, resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", 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/preview/automation/mgmt/2018-01-15-preview/automation/linkedworkspace.go b/services/preview/automation/mgmt/2018-01-15-preview/automation/linkedworkspace.go new file mode 100644 index 000000000000..5385fb666937 --- /dev/null +++ b/services/preview/automation/mgmt/2018-01-15-preview/automation/linkedworkspace.go @@ -0,0 +1,116 @@ +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" +) + +// LinkedWorkspaceClient is the automation Client +type LinkedWorkspaceClient struct { + BaseClient +} + +// NewLinkedWorkspaceClient creates an instance of the LinkedWorkspaceClient client. +func NewLinkedWorkspaceClient(subscriptionID string, countType1 CountType) LinkedWorkspaceClient { + return NewLinkedWorkspaceClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewLinkedWorkspaceClientWithBaseURI creates an instance of the LinkedWorkspaceClient client. +func NewLinkedWorkspaceClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) LinkedWorkspaceClient { + return LinkedWorkspaceClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// Get retrieve the linked workspace for the account id. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +func (client LinkedWorkspaceClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string) (result LinkedWorkspace, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.LinkedWorkspaceClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.LinkedWorkspaceClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.LinkedWorkspaceClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.LinkedWorkspaceClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client LinkedWorkspaceClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/linkedWorkspace", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client LinkedWorkspaceClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client LinkedWorkspaceClient) GetResponder(resp *http.Response) (result LinkedWorkspace, 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/preview/automation/mgmt/2018-01-15-preview/automation/models.go b/services/preview/automation/mgmt/2018-01-15-preview/automation/models.go new file mode 100644 index 000000000000..b8f74a884091 --- /dev/null +++ b/services/preview/automation/mgmt/2018-01-15-preview/automation/models.go @@ -0,0 +1,9842 @@ +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 ( + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "github.com/satori/go.uuid" + "io" + "net/http" +) + +// AccountState enumerates the values for account state. +type AccountState string + +const ( + // Ok ... + Ok AccountState = "Ok" + // Suspended ... + Suspended AccountState = "Suspended" + // Unavailable ... + Unavailable AccountState = "Unavailable" +) + +// PossibleAccountStateValues returns an array of possible values for the AccountState const type. +func PossibleAccountStateValues() []AccountState { + return []AccountState{Ok, Suspended, Unavailable} +} + +// AgentRegistrationKeyName enumerates the values for agent registration key name. +type AgentRegistrationKeyName string + +const ( + // Primary ... + Primary AgentRegistrationKeyName = "primary" + // Secondary ... + Secondary AgentRegistrationKeyName = "secondary" +) + +// PossibleAgentRegistrationKeyNameValues returns an array of possible values for the AgentRegistrationKeyName const type. +func PossibleAgentRegistrationKeyNameValues() []AgentRegistrationKeyName { + return []AgentRegistrationKeyName{Primary, Secondary} +} + +// ContentSourceType enumerates the values for content source type. +type ContentSourceType string + +const ( + // EmbeddedContent ... + EmbeddedContent ContentSourceType = "embeddedContent" + // URI ... + URI ContentSourceType = "uri" +) + +// PossibleContentSourceTypeValues returns an array of possible values for the ContentSourceType const type. +func PossibleContentSourceTypeValues() []ContentSourceType { + return []ContentSourceType{EmbeddedContent, URI} +} + +// CountType enumerates the values for count type. +type CountType string + +const ( + // Nodeconfiguration ... + Nodeconfiguration CountType = "nodeconfiguration" + // Status ... + Status CountType = "status" +) + +// PossibleCountTypeValues returns an array of possible values for the CountType const type. +func PossibleCountTypeValues() []CountType { + return []CountType{Nodeconfiguration, Status} +} + +// DscConfigurationProvisioningState enumerates the values for dsc configuration provisioning state. +type DscConfigurationProvisioningState string + +const ( + // Succeeded ... + Succeeded DscConfigurationProvisioningState = "Succeeded" +) + +// PossibleDscConfigurationProvisioningStateValues returns an array of possible values for the DscConfigurationProvisioningState const type. +func PossibleDscConfigurationProvisioningStateValues() []DscConfigurationProvisioningState { + return []DscConfigurationProvisioningState{Succeeded} +} + +// DscConfigurationState enumerates the values for dsc configuration state. +type DscConfigurationState string + +const ( + // DscConfigurationStateEdit ... + DscConfigurationStateEdit DscConfigurationState = "Edit" + // DscConfigurationStateNew ... + DscConfigurationStateNew DscConfigurationState = "New" + // DscConfigurationStatePublished ... + DscConfigurationStatePublished DscConfigurationState = "Published" +) + +// PossibleDscConfigurationStateValues returns an array of possible values for the DscConfigurationState const type. +func PossibleDscConfigurationStateValues() []DscConfigurationState { + return []DscConfigurationState{DscConfigurationStateEdit, DscConfigurationStateNew, DscConfigurationStatePublished} +} + +// GroupTypeEnum enumerates the values for group type enum. +type GroupTypeEnum string + +const ( + // System ... + System GroupTypeEnum = "System" + // User ... + User GroupTypeEnum = "User" +) + +// PossibleGroupTypeEnumValues returns an array of possible values for the GroupTypeEnum const type. +func PossibleGroupTypeEnumValues() []GroupTypeEnum { + return []GroupTypeEnum{System, User} +} + +// HTTPStatusCode enumerates the values for http status code. +type HTTPStatusCode string + +const ( + // Accepted ... + Accepted HTTPStatusCode = "Accepted" + // Ambiguous ... + Ambiguous HTTPStatusCode = "Ambiguous" + // BadGateway ... + BadGateway HTTPStatusCode = "BadGateway" + // BadRequest ... + BadRequest HTTPStatusCode = "BadRequest" + // Conflict ... + Conflict HTTPStatusCode = "Conflict" + // Continue ... + Continue HTTPStatusCode = "Continue" + // Created ... + Created HTTPStatusCode = "Created" + // ExpectationFailed ... + ExpectationFailed HTTPStatusCode = "ExpectationFailed" + // Forbidden ... + Forbidden HTTPStatusCode = "Forbidden" + // Found ... + Found HTTPStatusCode = "Found" + // GatewayTimeout ... + GatewayTimeout HTTPStatusCode = "GatewayTimeout" + // Gone ... + Gone HTTPStatusCode = "Gone" + // HTTPVersionNotSupported ... + HTTPVersionNotSupported HTTPStatusCode = "HttpVersionNotSupported" + // InternalServerError ... + InternalServerError HTTPStatusCode = "InternalServerError" + // LengthRequired ... + LengthRequired HTTPStatusCode = "LengthRequired" + // MethodNotAllowed ... + MethodNotAllowed HTTPStatusCode = "MethodNotAllowed" + // Moved ... + Moved HTTPStatusCode = "Moved" + // MovedPermanently ... + MovedPermanently HTTPStatusCode = "MovedPermanently" + // MultipleChoices ... + MultipleChoices HTTPStatusCode = "MultipleChoices" + // NoContent ... + NoContent HTTPStatusCode = "NoContent" + // NonAuthoritativeInformation ... + NonAuthoritativeInformation HTTPStatusCode = "NonAuthoritativeInformation" + // NotAcceptable ... + NotAcceptable HTTPStatusCode = "NotAcceptable" + // NotFound ... + NotFound HTTPStatusCode = "NotFound" + // NotImplemented ... + NotImplemented HTTPStatusCode = "NotImplemented" + // NotModified ... + NotModified HTTPStatusCode = "NotModified" + // OK ... + OK HTTPStatusCode = "OK" + // PartialContent ... + PartialContent HTTPStatusCode = "PartialContent" + // PaymentRequired ... + PaymentRequired HTTPStatusCode = "PaymentRequired" + // PreconditionFailed ... + PreconditionFailed HTTPStatusCode = "PreconditionFailed" + // ProxyAuthenticationRequired ... + ProxyAuthenticationRequired HTTPStatusCode = "ProxyAuthenticationRequired" + // Redirect ... + Redirect HTTPStatusCode = "Redirect" + // RedirectKeepVerb ... + RedirectKeepVerb HTTPStatusCode = "RedirectKeepVerb" + // RedirectMethod ... + RedirectMethod HTTPStatusCode = "RedirectMethod" + // RequestedRangeNotSatisfiable ... + RequestedRangeNotSatisfiable HTTPStatusCode = "RequestedRangeNotSatisfiable" + // RequestEntityTooLarge ... + RequestEntityTooLarge HTTPStatusCode = "RequestEntityTooLarge" + // RequestTimeout ... + RequestTimeout HTTPStatusCode = "RequestTimeout" + // RequestURITooLong ... + RequestURITooLong HTTPStatusCode = "RequestUriTooLong" + // ResetContent ... + ResetContent HTTPStatusCode = "ResetContent" + // SeeOther ... + SeeOther HTTPStatusCode = "SeeOther" + // ServiceUnavailable ... + ServiceUnavailable HTTPStatusCode = "ServiceUnavailable" + // SwitchingProtocols ... + SwitchingProtocols HTTPStatusCode = "SwitchingProtocols" + // TemporaryRedirect ... + TemporaryRedirect HTTPStatusCode = "TemporaryRedirect" + // Unauthorized ... + Unauthorized HTTPStatusCode = "Unauthorized" + // UnsupportedMediaType ... + UnsupportedMediaType HTTPStatusCode = "UnsupportedMediaType" + // Unused ... + Unused HTTPStatusCode = "Unused" + // UpgradeRequired ... + UpgradeRequired HTTPStatusCode = "UpgradeRequired" + // UseProxy ... + UseProxy HTTPStatusCode = "UseProxy" +) + +// PossibleHTTPStatusCodeValues returns an array of possible values for the HTTPStatusCode const type. +func PossibleHTTPStatusCodeValues() []HTTPStatusCode { + return []HTTPStatusCode{Accepted, Ambiguous, BadGateway, BadRequest, Conflict, Continue, Created, ExpectationFailed, Forbidden, Found, GatewayTimeout, Gone, HTTPVersionNotSupported, InternalServerError, LengthRequired, MethodNotAllowed, Moved, MovedPermanently, MultipleChoices, NoContent, NonAuthoritativeInformation, NotAcceptable, NotFound, NotImplemented, NotModified, OK, PartialContent, PaymentRequired, PreconditionFailed, ProxyAuthenticationRequired, Redirect, RedirectKeepVerb, RedirectMethod, RequestedRangeNotSatisfiable, RequestEntityTooLarge, RequestTimeout, RequestURITooLong, ResetContent, SeeOther, ServiceUnavailable, SwitchingProtocols, TemporaryRedirect, Unauthorized, UnsupportedMediaType, Unused, UpgradeRequired, UseProxy} +} + +// JobProvisioningState enumerates the values for job provisioning state. +type JobProvisioningState string + +const ( + // JobProvisioningStateFailed ... + JobProvisioningStateFailed JobProvisioningState = "Failed" + // JobProvisioningStateProcessing ... + JobProvisioningStateProcessing JobProvisioningState = "Processing" + // JobProvisioningStateSucceeded ... + JobProvisioningStateSucceeded JobProvisioningState = "Succeeded" + // JobProvisioningStateSuspended ... + JobProvisioningStateSuspended JobProvisioningState = "Suspended" +) + +// PossibleJobProvisioningStateValues returns an array of possible values for the JobProvisioningState const type. +func PossibleJobProvisioningStateValues() []JobProvisioningState { + return []JobProvisioningState{JobProvisioningStateFailed, JobProvisioningStateProcessing, JobProvisioningStateSucceeded, JobProvisioningStateSuspended} +} + +// JobStatus enumerates the values for job status. +type JobStatus string + +const ( + // JobStatusActivating ... + JobStatusActivating JobStatus = "Activating" + // JobStatusBlocked ... + JobStatusBlocked JobStatus = "Blocked" + // JobStatusCompleted ... + JobStatusCompleted JobStatus = "Completed" + // JobStatusDisconnected ... + JobStatusDisconnected JobStatus = "Disconnected" + // JobStatusFailed ... + JobStatusFailed JobStatus = "Failed" + // JobStatusNew ... + JobStatusNew JobStatus = "New" + // JobStatusRemoving ... + JobStatusRemoving JobStatus = "Removing" + // JobStatusResuming ... + JobStatusResuming JobStatus = "Resuming" + // JobStatusRunning ... + JobStatusRunning JobStatus = "Running" + // JobStatusStopped ... + JobStatusStopped JobStatus = "Stopped" + // JobStatusStopping ... + JobStatusStopping JobStatus = "Stopping" + // JobStatusSuspended ... + JobStatusSuspended JobStatus = "Suspended" + // JobStatusSuspending ... + JobStatusSuspending JobStatus = "Suspending" +) + +// PossibleJobStatusValues returns an array of possible values for the JobStatus const type. +func PossibleJobStatusValues() []JobStatus { + return []JobStatus{JobStatusActivating, JobStatusBlocked, JobStatusCompleted, JobStatusDisconnected, JobStatusFailed, JobStatusNew, JobStatusRemoving, JobStatusResuming, JobStatusRunning, JobStatusStopped, JobStatusStopping, JobStatusSuspended, JobStatusSuspending} +} + +// JobStreamType enumerates the values for job stream type. +type JobStreamType string + +const ( + // Any ... + Any JobStreamType = "Any" + // Debug ... + Debug JobStreamType = "Debug" + // Error ... + Error JobStreamType = "Error" + // Output ... + Output JobStreamType = "Output" + // Progress ... + Progress JobStreamType = "Progress" + // Verbose ... + Verbose JobStreamType = "Verbose" + // Warning ... + Warning JobStreamType = "Warning" +) + +// PossibleJobStreamTypeValues returns an array of possible values for the JobStreamType const type. +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" + // Read ... + Read KeyPermissions = "Read" +) + +// PossibleKeyPermissionsValues returns an array of possible values for the KeyPermissions const type. +func PossibleKeyPermissionsValues() []KeyPermissions { + return []KeyPermissions{Full, Read} +} + +// LinuxUpdateClasses enumerates the values for linux update classes. +type LinuxUpdateClasses string + +const ( + // Critical ... + Critical LinuxUpdateClasses = "Critical" + // Other ... + Other LinuxUpdateClasses = "Other" + // Security ... + Security LinuxUpdateClasses = "Security" + // Unclassified ... + Unclassified LinuxUpdateClasses = "Unclassified" +) + +// PossibleLinuxUpdateClassesValues returns an array of possible values for the LinuxUpdateClasses const type. +func PossibleLinuxUpdateClassesValues() []LinuxUpdateClasses { + return []LinuxUpdateClasses{Critical, Other, Security, Unclassified} +} + +// ModuleProvisioningState enumerates the values for module provisioning state. +type ModuleProvisioningState string + +const ( + // ModuleProvisioningStateActivitiesStored ... + ModuleProvisioningStateActivitiesStored ModuleProvisioningState = "ActivitiesStored" + // ModuleProvisioningStateCancelled ... + ModuleProvisioningStateCancelled ModuleProvisioningState = "Cancelled" + // ModuleProvisioningStateConnectionTypeImported ... + ModuleProvisioningStateConnectionTypeImported ModuleProvisioningState = "ConnectionTypeImported" + // ModuleProvisioningStateContentDownloaded ... + ModuleProvisioningStateContentDownloaded ModuleProvisioningState = "ContentDownloaded" + // ModuleProvisioningStateContentRetrieved ... + ModuleProvisioningStateContentRetrieved ModuleProvisioningState = "ContentRetrieved" + // ModuleProvisioningStateContentStored ... + ModuleProvisioningStateContentStored ModuleProvisioningState = "ContentStored" + // ModuleProvisioningStateContentValidated ... + ModuleProvisioningStateContentValidated ModuleProvisioningState = "ContentValidated" + // ModuleProvisioningStateCreated ... + ModuleProvisioningStateCreated ModuleProvisioningState = "Created" + // ModuleProvisioningStateCreating ... + ModuleProvisioningStateCreating ModuleProvisioningState = "Creating" + // ModuleProvisioningStateFailed ... + ModuleProvisioningStateFailed ModuleProvisioningState = "Failed" + // ModuleProvisioningStateModuleDataStored ... + ModuleProvisioningStateModuleDataStored ModuleProvisioningState = "ModuleDataStored" + // ModuleProvisioningStateModuleImportRunbookComplete ... + ModuleProvisioningStateModuleImportRunbookComplete ModuleProvisioningState = "ModuleImportRunbookComplete" + // ModuleProvisioningStateRunningImportModuleRunbook ... + ModuleProvisioningStateRunningImportModuleRunbook ModuleProvisioningState = "RunningImportModuleRunbook" + // ModuleProvisioningStateStartingImportModuleRunbook ... + ModuleProvisioningStateStartingImportModuleRunbook ModuleProvisioningState = "StartingImportModuleRunbook" + // ModuleProvisioningStateSucceeded ... + ModuleProvisioningStateSucceeded ModuleProvisioningState = "Succeeded" + // ModuleProvisioningStateUpdating ... + ModuleProvisioningStateUpdating ModuleProvisioningState = "Updating" +) + +// PossibleModuleProvisioningStateValues returns an array of possible values for the ModuleProvisioningState const type. +func PossibleModuleProvisioningStateValues() []ModuleProvisioningState { + return []ModuleProvisioningState{ModuleProvisioningStateActivitiesStored, ModuleProvisioningStateCancelled, ModuleProvisioningStateConnectionTypeImported, ModuleProvisioningStateContentDownloaded, ModuleProvisioningStateContentRetrieved, ModuleProvisioningStateContentStored, ModuleProvisioningStateContentValidated, ModuleProvisioningStateCreated, ModuleProvisioningStateCreating, ModuleProvisioningStateFailed, ModuleProvisioningStateModuleDataStored, ModuleProvisioningStateModuleImportRunbookComplete, ModuleProvisioningStateRunningImportModuleRunbook, ModuleProvisioningStateStartingImportModuleRunbook, ModuleProvisioningStateSucceeded, ModuleProvisioningStateUpdating} +} + +// OperatingSystemType enumerates the values for operating system type. +type OperatingSystemType string + +const ( + // Linux ... + Linux OperatingSystemType = "Linux" + // Windows ... + Windows OperatingSystemType = "Windows" +) + +// PossibleOperatingSystemTypeValues returns an array of possible values for the OperatingSystemType const type. +func PossibleOperatingSystemTypeValues() []OperatingSystemType { + return []OperatingSystemType{Linux, Windows} +} + +// ProvisioningState enumerates the values for provisioning state. +type ProvisioningState string + +const ( + // Completed ... + Completed ProvisioningState = "Completed" + // Failed ... + Failed ProvisioningState = "Failed" + // Running ... + Running ProvisioningState = "Running" +) + +// PossibleProvisioningStateValues returns an array of possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{Completed, Failed, Running} +} + +// RunbookProvisioningState enumerates the values for runbook provisioning state. +type RunbookProvisioningState string + +const ( + // RunbookProvisioningStateSucceeded ... + RunbookProvisioningStateSucceeded RunbookProvisioningState = "Succeeded" +) + +// PossibleRunbookProvisioningStateValues returns an array of possible values for the RunbookProvisioningState const type. +func PossibleRunbookProvisioningStateValues() []RunbookProvisioningState { + return []RunbookProvisioningState{RunbookProvisioningStateSucceeded} +} + +// RunbookState enumerates the values for runbook state. +type RunbookState string + +const ( + // RunbookStateEdit ... + RunbookStateEdit RunbookState = "Edit" + // RunbookStateNew ... + RunbookStateNew RunbookState = "New" + // RunbookStatePublished ... + RunbookStatePublished RunbookState = "Published" +) + +// PossibleRunbookStateValues returns an array of possible values for the RunbookState const type. +func PossibleRunbookStateValues() []RunbookState { + return []RunbookState{RunbookStateEdit, RunbookStateNew, RunbookStatePublished} +} + +// RunbookTypeEnum enumerates the values for runbook type enum. +type RunbookTypeEnum string + +const ( + // Graph ... + Graph RunbookTypeEnum = "Graph" + // GraphPowerShell ... + GraphPowerShell RunbookTypeEnum = "GraphPowerShell" + // GraphPowerShellWorkflow ... + GraphPowerShellWorkflow RunbookTypeEnum = "GraphPowerShellWorkflow" + // PowerShell ... + PowerShell RunbookTypeEnum = "PowerShell" + // PowerShellWorkflow ... + PowerShellWorkflow RunbookTypeEnum = "PowerShellWorkflow" + // Script ... + Script RunbookTypeEnum = "Script" +) + +// PossibleRunbookTypeEnumValues returns an array of possible values for the RunbookTypeEnum const type. +func PossibleRunbookTypeEnumValues() []RunbookTypeEnum { + return []RunbookTypeEnum{Graph, GraphPowerShell, GraphPowerShellWorkflow, PowerShell, PowerShellWorkflow, Script} +} + +// ScheduleDay enumerates the values for schedule day. +type ScheduleDay string + +const ( + // Friday ... + Friday ScheduleDay = "Friday" + // Monday ... + Monday ScheduleDay = "Monday" + // Saturday ... + Saturday ScheduleDay = "Saturday" + // Sunday ... + Sunday ScheduleDay = "Sunday" + // Thursday ... + Thursday ScheduleDay = "Thursday" + // Tuesday ... + Tuesday ScheduleDay = "Tuesday" + // Wednesday ... + Wednesday ScheduleDay = "Wednesday" +) + +// PossibleScheduleDayValues returns an array of possible values for the ScheduleDay const type. +func PossibleScheduleDayValues() []ScheduleDay { + return []ScheduleDay{Friday, Monday, Saturday, Sunday, Thursday, Tuesday, Wednesday} +} + +// ScheduleFrequency enumerates the values for schedule frequency. +type ScheduleFrequency string + +const ( + // Day ... + Day ScheduleFrequency = "Day" + // Hour ... + Hour ScheduleFrequency = "Hour" + // Month ... + Month ScheduleFrequency = "Month" + // OneTime ... + OneTime ScheduleFrequency = "OneTime" + // Week ... + Week ScheduleFrequency = "Week" +) + +// PossibleScheduleFrequencyValues returns an array of possible values for the ScheduleFrequency const type. +func PossibleScheduleFrequencyValues() []ScheduleFrequency { + return []ScheduleFrequency{Day, Hour, Month, OneTime, Week} +} + +// SkuNameEnum enumerates the values for sku name enum. +type SkuNameEnum string + +const ( + // Basic ... + Basic SkuNameEnum = "Basic" + // Free ... + Free SkuNameEnum = "Free" +) + +// PossibleSkuNameEnumValues returns an array of possible values for the SkuNameEnum const type. +func PossibleSkuNameEnumValues() []SkuNameEnum { + return []SkuNameEnum{Basic, Free} +} + +// SourceType enumerates the values for source type. +type SourceType string + +const ( + // GitHub ... + GitHub SourceType = "GitHub" + // VsoGit ... + VsoGit SourceType = "VsoGit" + // VsoTfvc ... + VsoTfvc SourceType = "VsoTfvc" +) + +// PossibleSourceTypeValues returns an array of possible values for the SourceType const type. +func PossibleSourceTypeValues() []SourceType { + return []SourceType{GitHub, VsoGit, VsoTfvc} +} + +// StreamType enumerates the values for stream type. +type StreamType string + +const ( + // StreamTypeError ... + StreamTypeError StreamType = "Error" + // StreamTypeOutput ... + StreamTypeOutput StreamType = "Output" +) + +// PossibleStreamTypeValues returns an array of possible values for the StreamType const type. +func PossibleStreamTypeValues() []StreamType { + return []StreamType{StreamTypeError, StreamTypeOutput} +} + +// SyncType enumerates the values for sync type. +type SyncType string + +const ( + // FullSync ... + FullSync SyncType = "FullSync" + // PartialSync ... + PartialSync SyncType = "PartialSync" +) + +// PossibleSyncTypeValues returns an array of possible values for the SyncType const type. +func PossibleSyncTypeValues() []SyncType { + return []SyncType{FullSync, PartialSync} +} + +// TagOperators enumerates the values for tag operators. +type TagOperators string + +const ( + // TagOperatorsAll ... + TagOperatorsAll TagOperators = "All" + // TagOperatorsAny ... + TagOperatorsAny TagOperators = "Any" +) + +// PossibleTagOperatorsValues returns an array of possible values for the TagOperators const type. +func PossibleTagOperatorsValues() []TagOperators { + return []TagOperators{TagOperatorsAll, TagOperatorsAny} +} + +// TokenType enumerates the values for token type. +type TokenType string + +const ( + // Oauth ... + Oauth TokenType = "Oauth" + // PersonalAccessToken ... + PersonalAccessToken TokenType = "PersonalAccessToken" +) + +// PossibleTokenTypeValues returns an array of possible values for the TokenType const type. +func PossibleTokenTypeValues() []TokenType { + return []TokenType{Oauth, PersonalAccessToken} +} + +// WindowsUpdateClasses enumerates the values for windows update classes. +type WindowsUpdateClasses string + +const ( + // WindowsUpdateClassesCritical ... + WindowsUpdateClassesCritical WindowsUpdateClasses = "Critical" + // WindowsUpdateClassesDefinition ... + WindowsUpdateClassesDefinition WindowsUpdateClasses = "Definition" + // WindowsUpdateClassesFeaturePack ... + WindowsUpdateClassesFeaturePack WindowsUpdateClasses = "FeaturePack" + // WindowsUpdateClassesSecurity ... + WindowsUpdateClassesSecurity WindowsUpdateClasses = "Security" + // WindowsUpdateClassesServicePack ... + WindowsUpdateClassesServicePack WindowsUpdateClasses = "ServicePack" + // WindowsUpdateClassesTools ... + WindowsUpdateClassesTools WindowsUpdateClasses = "Tools" + // WindowsUpdateClassesUnclassified ... + WindowsUpdateClassesUnclassified WindowsUpdateClasses = "Unclassified" + // WindowsUpdateClassesUpdateRollup ... + WindowsUpdateClassesUpdateRollup WindowsUpdateClasses = "UpdateRollup" + // WindowsUpdateClassesUpdates ... + WindowsUpdateClassesUpdates WindowsUpdateClasses = "Updates" +) + +// PossibleWindowsUpdateClassesValues returns an array of possible values for the WindowsUpdateClasses const type. +func PossibleWindowsUpdateClassesValues() []WindowsUpdateClasses { + return []WindowsUpdateClasses{WindowsUpdateClassesCritical, WindowsUpdateClassesDefinition, WindowsUpdateClassesFeaturePack, WindowsUpdateClassesSecurity, WindowsUpdateClassesServicePack, WindowsUpdateClassesTools, WindowsUpdateClassesUnclassified, WindowsUpdateClassesUpdateRollup, WindowsUpdateClassesUpdates} +} + +// Account definition of the automation account type. +type Account struct { + autorest.Response `json:"-"` + // AccountProperties - Gets or sets the automation account properties. + *AccountProperties `json:"properties,omitempty"` + // Etag - Gets or sets the etag of the resource. + Etag *string `json:"etag,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The Azure Region where the resource lives + Location *string `json:"location,omitempty"` + // ID - Fully qualified resource Id for the resource + ID *string `json:"id,omitempty"` + // Name - The name of the resource + Name *string `json:"name,omitempty"` + // Type - The type of the resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Account. +func (a Account) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if a.AccountProperties != nil { + objectMap["properties"] = a.AccountProperties + } + if a.Etag != nil { + objectMap["etag"] = a.Etag + } + if a.Tags != nil { + objectMap["tags"] = a.Tags + } + if a.Location != nil { + objectMap["location"] = a.Location + } + if a.ID != nil { + objectMap["id"] = a.ID + } + if a.Name != nil { + objectMap["name"] = a.Name + } + if a.Type != nil { + objectMap["type"] = a.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Account struct. +func (a *Account) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var accountProperties AccountProperties + err = json.Unmarshal(*v, &accountProperties) + if err != nil { + return err + } + a.AccountProperties = &accountProperties + } + case "etag": + if v != nil { + var etag string + err = json.Unmarshal(*v, &etag) + if err != nil { + return err + } + a.Etag = &etag + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + a.Tags = tags + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + a.Location = &location + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + a.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + a.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + a.Type = &typeVar + } + } + } + + return nil +} + +// AccountCreateOrUpdateParameters the parameters supplied to the create or update automation account operation. +type AccountCreateOrUpdateParameters struct { + // AccountCreateOrUpdateProperties - Gets or sets account create or update properties. + *AccountCreateOrUpdateProperties `json:"properties,omitempty"` + // Name - Gets or sets name of the resource. + Name *string `json:"name,omitempty"` + // Location - Gets or sets the location of the resource. + Location *string `json:"location,omitempty"` + // Tags - Gets or sets the tags attached to the resource. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for AccountCreateOrUpdateParameters. +func (acoup AccountCreateOrUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if acoup.AccountCreateOrUpdateProperties != nil { + objectMap["properties"] = acoup.AccountCreateOrUpdateProperties + } + if acoup.Name != nil { + objectMap["name"] = acoup.Name + } + if acoup.Location != nil { + objectMap["location"] = acoup.Location + } + if acoup.Tags != nil { + objectMap["tags"] = acoup.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for AccountCreateOrUpdateParameters struct. +func (acoup *AccountCreateOrUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var accountCreateOrUpdateProperties AccountCreateOrUpdateProperties + err = json.Unmarshal(*v, &accountCreateOrUpdateProperties) + if err != nil { + return err + } + acoup.AccountCreateOrUpdateProperties = &accountCreateOrUpdateProperties + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + acoup.Name = &name + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + acoup.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + acoup.Tags = tags + } + } + } + + return nil +} + +// AccountCreateOrUpdateProperties the parameters supplied to the create or update account properties. +type AccountCreateOrUpdateProperties struct { + // Sku - Gets or sets account SKU. + Sku *Sku `json:"sku,omitempty"` +} + +// AccountListResult the response model for the list account operation. +type AccountListResult struct { + autorest.Response `json:"-"` + // Value - Gets or sets list of accounts. + Value *[]Account `json:"value,omitempty"` + // NextLink - Gets or sets the next link. + NextLink *string `json:"nextLink,omitempty"` +} + +// AccountListResultIterator provides access to a complete listing of Account values. +type AccountListResultIterator struct { + i int + page AccountListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *AccountListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter AccountListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter AccountListResultIterator) Response() AccountListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter AccountListResultIterator) Value() Account { + if !iter.page.NotDone() { + return Account{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (alr AccountListResult) IsEmpty() bool { + return alr.Value == nil || len(*alr.Value) == 0 +} + +// accountListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (alr AccountListResult) accountListResultPreparer() (*http.Request, error) { + if alr.NextLink == nil || len(to.String(alr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(alr.NextLink))) +} + +// AccountListResultPage contains a page of Account values. +type AccountListResultPage struct { + fn func(AccountListResult) (AccountListResult, error) + alr AccountListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *AccountListResultPage) Next() error { + next, err := page.fn(page.alr) + if err != nil { + return err + } + page.alr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page AccountListResultPage) NotDone() bool { + return !page.alr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page AccountListResultPage) Response() AccountListResult { + return page.alr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page AccountListResultPage) Values() []Account { + if page.alr.IsEmpty() { + return nil + } + return *page.alr.Value +} + +// AccountProperties definition of the account property. +type AccountProperties struct { + // Sku - Gets or sets the SKU of account. + Sku *Sku `json:"sku,omitempty"` + // LastModifiedBy - Gets or sets the last modified by. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + // State - Gets status of account. Possible values include: 'Ok', 'Unavailable', 'Suspended' + State AccountState `json:"state,omitempty"` + // CreationTime - Gets the creation time. + CreationTime *date.Time `json:"creationTime,omitempty"` + // LastModifiedTime - Gets the last modified time. + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + // Description - Gets or sets the description. + Description *string `json:"description,omitempty"` +} + +// AccountUpdateParameters the parameters supplied to the update automation account operation. +type AccountUpdateParameters struct { + // AccountUpdateProperties - Gets or sets account update properties. + *AccountUpdateProperties `json:"properties,omitempty"` + // Name - Gets or sets the name of the resource. + Name *string `json:"name,omitempty"` + // Location - Gets or sets the location of the resource. + Location *string `json:"location,omitempty"` + // Tags - Gets or sets the tags attached to the resource. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for AccountUpdateParameters. +func (aup AccountUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if aup.AccountUpdateProperties != nil { + objectMap["properties"] = aup.AccountUpdateProperties + } + if aup.Name != nil { + objectMap["name"] = aup.Name + } + if aup.Location != nil { + objectMap["location"] = aup.Location + } + if aup.Tags != nil { + objectMap["tags"] = aup.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for AccountUpdateParameters struct. +func (aup *AccountUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var accountUpdateProperties AccountUpdateProperties + err = json.Unmarshal(*v, &accountUpdateProperties) + if err != nil { + return err + } + aup.AccountUpdateProperties = &accountUpdateProperties + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + aup.Name = &name + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + aup.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + aup.Tags = tags + } + } + } + + return nil +} + +// AccountUpdateProperties the parameters supplied to the update account properties. +type AccountUpdateProperties struct { + // Sku - Gets or sets account SKU. + Sku *Sku `json:"sku,omitempty"` +} + +// Activity definition of the activity. +type Activity struct { + autorest.Response `json:"-"` + // ID - Gets or sets the id of the resource. + ID *string `json:"id,omitempty"` + // Name - Gets the name of the activity. + Name *string `json:"name,omitempty"` + // ActivityProperties - Gets or sets the properties of the activity. + *ActivityProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for Activity. +func (a Activity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if a.ID != nil { + objectMap["id"] = a.ID + } + if a.Name != nil { + objectMap["name"] = a.Name + } + if a.ActivityProperties != nil { + objectMap["properties"] = a.ActivityProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Activity struct. +func (a *Activity) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + a.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + a.Name = &name + } + case "properties": + if v != nil { + var activityProperties ActivityProperties + err = json.Unmarshal(*v, &activityProperties) + if err != nil { + return err + } + a.ActivityProperties = &activityProperties + } + } + } + + return nil +} + +// ActivityListResult the response model for the list activity operation. +type ActivityListResult struct { + autorest.Response `json:"-"` + // Value - Gets or sets a list of activities. + Value *[]Activity `json:"value,omitempty"` + // NextLink - Gets or sets the next link. + NextLink *string `json:"nextLink,omitempty"` +} + +// ActivityListResultIterator provides access to a complete listing of Activity values. +type ActivityListResultIterator struct { + i int + page ActivityListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ActivityListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ActivityListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ActivityListResultIterator) Response() ActivityListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ActivityListResultIterator) Value() Activity { + if !iter.page.NotDone() { + return Activity{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (alr ActivityListResult) IsEmpty() bool { + return alr.Value == nil || len(*alr.Value) == 0 +} + +// activityListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (alr ActivityListResult) activityListResultPreparer() (*http.Request, error) { + if alr.NextLink == nil || len(to.String(alr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(alr.NextLink))) +} + +// ActivityListResultPage contains a page of Activity values. +type ActivityListResultPage struct { + fn func(ActivityListResult) (ActivityListResult, error) + alr ActivityListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ActivityListResultPage) Next() error { + next, err := page.fn(page.alr) + if err != nil { + return err + } + page.alr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ActivityListResultPage) NotDone() bool { + return !page.alr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ActivityListResultPage) Response() ActivityListResult { + return page.alr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ActivityListResultPage) Values() []Activity { + if page.alr.IsEmpty() { + return nil + } + return *page.alr.Value +} + +// ActivityOutputType definition of the activity output type. +type ActivityOutputType struct { + // Name - Gets or sets the name of the activity output type. + Name *string `json:"name,omitempty"` + // Type - Gets or sets the type of the activity output type. + Type *string `json:"type,omitempty"` +} + +// ActivityParameter definition of the activity parameter. +type ActivityParameter struct { + // Name - Gets or sets the name of the activity parameter. + Name *string `json:"name,omitempty"` + // Type - Gets or sets the type of the activity parameter. + Type *string `json:"type,omitempty"` + // IsMandatory - Gets or sets a Boolean value that indicates true if the parameter is required. If the value is false, the parameter is optional. + IsMandatory *bool `json:"isMandatory,omitempty"` + // IsDynamic - Gets or sets a Boolean value that indicates true if the parameter is dynamic. + IsDynamic *bool `json:"isDynamic,omitempty"` + // Position - Gets or sets the position of the activity parameter. + Position *int64 `json:"position,omitempty"` + // ValueFromPipeline - Gets or sets a Boolean value that indicates true if the parameter can take values from the incoming pipeline objects. This setting is used if the cmdlet must access the complete input object. false indicates that the parameter cannot take values from the complete input object. + ValueFromPipeline *bool `json:"valueFromPipeline,omitempty"` + // ValueFromPipelineByPropertyName - Gets or sets a Boolean value that indicates true if the parameter can be filled from a property of the incoming pipeline object that has the same name as this parameter. false indicates that the parameter cannot be filled from the incoming pipeline object property with the same name. + ValueFromPipelineByPropertyName *bool `json:"valueFromPipelineByPropertyName,omitempty"` + // ValueFromRemainingArguments - Gets or sets a Boolean value that indicates true if the cmdlet parameter accepts all the remaining command-line arguments that are associated with this parameter in the form of an array. false if the cmdlet parameter does not accept all the remaining argument values. + ValueFromRemainingArguments *bool `json:"valueFromRemainingArguments,omitempty"` + // Description - Gets or sets the description of the activity parameter. + Description *string `json:"description,omitempty"` + // ValidationSet - Gets or sets the validation set of activity parameter. + ValidationSet *[]ActivityParameterValidationSet `json:"validationSet,omitempty"` +} + +// ActivityParameterSet definition of the activity parameter set. +type ActivityParameterSet struct { + // Name - Gets or sets the name of the activity parameter set. + Name *string `json:"name,omitempty"` + // Parameters - Gets or sets the parameters of the activity parameter set. + Parameters *[]ActivityParameter `json:"parameters,omitempty"` +} + +// ActivityParameterValidationSet definition of the activity parameter validation set. +type ActivityParameterValidationSet struct { + // MemberValue - Gets or sets the name of the activity parameter validation set member. + MemberValue *string `json:"memberValue,omitempty"` +} + +// ActivityProperties properties of the activity. +type ActivityProperties struct { + // Definition - Gets or sets the user name of the activity. + Definition *string `json:"definition,omitempty"` + // ParameterSets - Gets or sets the parameter sets of the activity. + ParameterSets *[]ActivityParameterSet `json:"parameterSets,omitempty"` + // OutputTypes - Gets or sets the output types of the activity. + OutputTypes *[]ActivityOutputType `json:"outputTypes,omitempty"` + // CreationTime - Gets or sets the creation time. + CreationTime *date.Time `json:"creationTime,omitempty"` + // LastModifiedTime - Gets or sets the last modified time. + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + // Description - Gets or sets the description. + Description *string `json:"description,omitempty"` +} + +// AdvancedSchedule the properties of the create Advanced Schedule. +type AdvancedSchedule struct { + // WeekDays - Days of the week that the job should execute on. + WeekDays *[]string `json:"weekDays,omitempty"` + // MonthDays - Days of the month that the job should execute on. Must be between 1 and 31. + MonthDays *[]int32 `json:"monthDays,omitempty"` + // MonthlyOccurrences - Occurrences of days within a month. + MonthlyOccurrences *[]AdvancedScheduleMonthlyOccurrence `json:"monthlyOccurrences,omitempty"` +} + +// AdvancedScheduleMonthlyOccurrence the properties of the create advanced schedule monthly occurrence. +type AdvancedScheduleMonthlyOccurrence struct { + // Occurrence - Occurrence of the week within the month. Must be between 1 and 5 + Occurrence *int32 `json:"occurrence,omitempty"` + // Day - Day of the occurrence. Must be one of monday, tuesday, wednesday, thursday, friday, saturday, sunday. Possible values include: 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday' + Day ScheduleDay `json:"day,omitempty"` +} + +// AgentRegistration definition of the agent registration infomration type. +type AgentRegistration struct { + autorest.Response `json:"-"` + // DscMetaConfiguration - Gets or sets the dsc meta configuration. + DscMetaConfiguration *string `json:"dscMetaConfiguration,omitempty"` + // Endpoint - Gets or sets the dsc server endpoint. + Endpoint *string `json:"endpoint,omitempty"` + // Keys - Gets or sets the agent registration keys. + Keys *AgentRegistrationKeys `json:"keys,omitempty"` + // ID - Gets or sets the id. + ID *string `json:"id,omitempty"` +} + +// AgentRegistrationKeys definition of the agent registration keys. +type AgentRegistrationKeys struct { + // Primary - Gets or sets the primary key. + Primary *string `json:"primary,omitempty"` + // Secondary - Gets or sets the secondary key. + Secondary *string `json:"secondary,omitempty"` +} + +// AgentRegistrationRegenerateKeyParameter the parameters supplied to the regenerate keys operation. +type AgentRegistrationRegenerateKeyParameter struct { + // KeyName - Gets or sets the agent registration key name - primary or secondary. Possible values include: 'Primary', 'Secondary' + KeyName AgentRegistrationKeyName `json:"keyName,omitempty"` +} + +// AzureQueryProperties azure query for the update configuration. +type AzureQueryProperties struct { + // Scope - List of Subscription or Resource Group ARM Ids. + Scope *[]string `json:"scope,omitempty"` + // Location - List of locations to scope the query to. + Location *[]string `json:"location,omitempty"` + // TagSettings - Tag settings for the VM. + TagSettings *TagSettingsProperties `json:"tagSettings,omitempty"` +} + +// Certificate definition of the certificate. +type Certificate struct { + autorest.Response `json:"-"` + // CertificateProperties - Gets or sets the properties of the certificate. + *CertificateProperties `json:"properties,omitempty"` + // ID - Fully qualified resource Id for the resource + ID *string `json:"id,omitempty"` + // Name - The name of the resource + Name *string `json:"name,omitempty"` + // Type - The type of the resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Certificate. +func (c Certificate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if c.CertificateProperties != nil { + objectMap["properties"] = c.CertificateProperties + } + if c.ID != nil { + objectMap["id"] = c.ID + } + if c.Name != nil { + objectMap["name"] = c.Name + } + if c.Type != nil { + objectMap["type"] = c.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Certificate struct. +func (c *Certificate) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var certificateProperties CertificateProperties + err = json.Unmarshal(*v, &certificateProperties) + if err != nil { + return err + } + c.CertificateProperties = &certificateProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + c.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + c.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + c.Type = &typeVar + } + } + } + + return nil +} + +// CertificateCreateOrUpdateParameters the parameters supplied to the create or update or replace certificate +// operation. +type CertificateCreateOrUpdateParameters struct { + // Name - Gets or sets the name of the certificate. + Name *string `json:"name,omitempty"` + // CertificateCreateOrUpdateProperties - Gets or sets the properties of the certificate. + *CertificateCreateOrUpdateProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for CertificateCreateOrUpdateParameters. +func (ccoup CertificateCreateOrUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ccoup.Name != nil { + objectMap["name"] = ccoup.Name + } + if ccoup.CertificateCreateOrUpdateProperties != nil { + objectMap["properties"] = ccoup.CertificateCreateOrUpdateProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for CertificateCreateOrUpdateParameters struct. +func (ccoup *CertificateCreateOrUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ccoup.Name = &name + } + case "properties": + if v != nil { + var certificateCreateOrUpdateProperties CertificateCreateOrUpdateProperties + err = json.Unmarshal(*v, &certificateCreateOrUpdateProperties) + if err != nil { + return err + } + ccoup.CertificateCreateOrUpdateProperties = &certificateCreateOrUpdateProperties + } + } + } + + return nil +} + +// CertificateCreateOrUpdateProperties the properties of the create certificate operation. +type CertificateCreateOrUpdateProperties struct { + // Base64Value - Gets or sets the base64 encoded value of the certificate. + Base64Value *string `json:"base64Value,omitempty"` + // Description - Gets or sets the description of the certificate. + Description *string `json:"description,omitempty"` + // Thumbprint - Gets or sets the thumbprint of the certificate. + Thumbprint *string `json:"thumbprint,omitempty"` + // IsExportable - Gets or sets the is exportable flag of the certificate. + IsExportable *bool `json:"isExportable,omitempty"` +} + +// CertificateListResult the response model for the list certificate operation. +type CertificateListResult struct { + autorest.Response `json:"-"` + // Value - Gets or sets a list of certificates. + Value *[]Certificate `json:"value,omitempty"` + // NextLink - Gets or sets the next link. + NextLink *string `json:"nextLink,omitempty"` +} + +// CertificateListResultIterator provides access to a complete listing of Certificate values. +type CertificateListResultIterator struct { + i int + page CertificateListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *CertificateListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter CertificateListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter CertificateListResultIterator) Response() CertificateListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter CertificateListResultIterator) Value() Certificate { + if !iter.page.NotDone() { + return Certificate{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (clr CertificateListResult) IsEmpty() bool { + return clr.Value == nil || len(*clr.Value) == 0 +} + +// certificateListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (clr CertificateListResult) certificateListResultPreparer() (*http.Request, error) { + if clr.NextLink == nil || len(to.String(clr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(clr.NextLink))) +} + +// CertificateListResultPage contains a page of Certificate values. +type CertificateListResultPage struct { + fn func(CertificateListResult) (CertificateListResult, error) + clr CertificateListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *CertificateListResultPage) Next() error { + next, err := page.fn(page.clr) + if err != nil { + return err + } + page.clr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page CertificateListResultPage) NotDone() bool { + return !page.clr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page CertificateListResultPage) Response() CertificateListResult { + return page.clr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page CertificateListResultPage) Values() []Certificate { + if page.clr.IsEmpty() { + return nil + } + return *page.clr.Value +} + +// CertificateProperties properties of the certificate. +type CertificateProperties struct { + // Thumbprint - Gets the thumbprint of the certificate. + Thumbprint *string `json:"thumbprint,omitempty"` + // ExpiryTime - Gets the expiry time of the certificate. + ExpiryTime *date.Time `json:"expiryTime,omitempty"` + // IsExportable - Gets the is exportable flag of the certificate. + IsExportable *bool `json:"isExportable,omitempty"` + // CreationTime - Gets the creation time. + CreationTime *date.Time `json:"creationTime,omitempty"` + // LastModifiedTime - Gets the last modified time. + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + // Description - Gets or sets the description. + Description *string `json:"description,omitempty"` +} + +// CertificateUpdateParameters the parameters supplied to the update certificate operation. +type CertificateUpdateParameters struct { + // Name - Gets or sets the name of the certificate. + Name *string `json:"name,omitempty"` + // CertificateUpdateProperties - Gets or sets the properties of the certificate. + *CertificateUpdateProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for CertificateUpdateParameters. +func (cup CertificateUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cup.Name != nil { + objectMap["name"] = cup.Name + } + if cup.CertificateUpdateProperties != nil { + objectMap["properties"] = cup.CertificateUpdateProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for CertificateUpdateParameters struct. +func (cup *CertificateUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + cup.Name = &name + } + case "properties": + if v != nil { + var certificateUpdateProperties CertificateUpdateProperties + err = json.Unmarshal(*v, &certificateUpdateProperties) + if err != nil { + return err + } + cup.CertificateUpdateProperties = &certificateUpdateProperties + } + } + } + + return nil +} + +// CertificateUpdateProperties the properties of the update certificate operation +type CertificateUpdateProperties struct { + // Description - Gets or sets the description of the certificate. + Description *string `json:"description,omitempty"` +} + +// CollectionItemUpdateConfiguration object returned when requesting a collection of software update configuration +type CollectionItemUpdateConfiguration struct { + // AzureVirtualMachines - List of azure resource Ids for azure virtual machines targeted by the software update configuration. + AzureVirtualMachines *[]string `json:"azureVirtualMachines,omitempty"` + // Duration - Maximum time allowed for the software update configuration run. Duration needs to be specified using the format PT[n]H[n]M[n]S as per ISO8601 + Duration *string `json:"duration,omitempty"` +} + +// Connection definition of the connection. +type Connection struct { + autorest.Response `json:"-"` + // ConnectionProperties - Gets or sets the properties of the connection. + *ConnectionProperties `json:"properties,omitempty"` + // ID - Fully qualified resource Id for the resource + ID *string `json:"id,omitempty"` + // Name - The name of the resource + Name *string `json:"name,omitempty"` + // Type - The type of the resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Connection. +func (c Connection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if c.ConnectionProperties != nil { + objectMap["properties"] = c.ConnectionProperties + } + if c.ID != nil { + objectMap["id"] = c.ID + } + if c.Name != nil { + objectMap["name"] = c.Name + } + if c.Type != nil { + objectMap["type"] = c.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Connection struct. +func (c *Connection) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var connectionProperties ConnectionProperties + err = json.Unmarshal(*v, &connectionProperties) + if err != nil { + return err + } + c.ConnectionProperties = &connectionProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + c.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + c.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + c.Type = &typeVar + } + } + } + + return nil +} + +// ConnectionCreateOrUpdateParameters the parameters supplied to the create or update connection operation. +type ConnectionCreateOrUpdateParameters struct { + // Name - Gets or sets the name of the connection. + Name *string `json:"name,omitempty"` + // ConnectionCreateOrUpdateProperties - Gets or sets the properties of the connection. + *ConnectionCreateOrUpdateProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for ConnectionCreateOrUpdateParameters. +func (ccoup ConnectionCreateOrUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ccoup.Name != nil { + objectMap["name"] = ccoup.Name + } + if ccoup.ConnectionCreateOrUpdateProperties != nil { + objectMap["properties"] = ccoup.ConnectionCreateOrUpdateProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ConnectionCreateOrUpdateParameters struct. +func (ccoup *ConnectionCreateOrUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ccoup.Name = &name + } + case "properties": + if v != nil { + var connectionCreateOrUpdateProperties ConnectionCreateOrUpdateProperties + err = json.Unmarshal(*v, &connectionCreateOrUpdateProperties) + if err != nil { + return err + } + ccoup.ConnectionCreateOrUpdateProperties = &connectionCreateOrUpdateProperties + } + } + } + + return nil +} + +// ConnectionCreateOrUpdateProperties the properties of the create connection properties +type ConnectionCreateOrUpdateProperties struct { + // Description - Gets or sets the description of the connection. + Description *string `json:"description,omitempty"` + // ConnectionType - Gets or sets the connectionType of the connection. + ConnectionType *ConnectionTypeAssociationProperty `json:"connectionType,omitempty"` + // FieldDefinitionValues - Gets or sets the field definition properties of the connection. + FieldDefinitionValues map[string]*string `json:"fieldDefinitionValues"` +} + +// MarshalJSON is the custom marshaler for ConnectionCreateOrUpdateProperties. +func (ccoup ConnectionCreateOrUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ccoup.Description != nil { + objectMap["description"] = ccoup.Description + } + if ccoup.ConnectionType != nil { + objectMap["connectionType"] = ccoup.ConnectionType + } + if ccoup.FieldDefinitionValues != nil { + objectMap["fieldDefinitionValues"] = ccoup.FieldDefinitionValues + } + return json.Marshal(objectMap) +} + +// ConnectionListResult the response model for the list connection operation. +type ConnectionListResult struct { + autorest.Response `json:"-"` + // Value - Gets or sets a list of connection. + Value *[]Connection `json:"value,omitempty"` + // NextLink - Gets or sets the next link. + NextLink *string `json:"nextLink,omitempty"` +} + +// ConnectionListResultIterator provides access to a complete listing of Connection values. +type ConnectionListResultIterator struct { + i int + page ConnectionListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ConnectionListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ConnectionListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ConnectionListResultIterator) Response() ConnectionListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ConnectionListResultIterator) Value() Connection { + if !iter.page.NotDone() { + return Connection{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (clr ConnectionListResult) IsEmpty() bool { + return clr.Value == nil || len(*clr.Value) == 0 +} + +// connectionListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (clr ConnectionListResult) connectionListResultPreparer() (*http.Request, error) { + if clr.NextLink == nil || len(to.String(clr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(clr.NextLink))) +} + +// ConnectionListResultPage contains a page of Connection values. +type ConnectionListResultPage struct { + fn func(ConnectionListResult) (ConnectionListResult, error) + clr ConnectionListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ConnectionListResultPage) Next() error { + next, err := page.fn(page.clr) + if err != nil { + return err + } + page.clr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ConnectionListResultPage) NotDone() bool { + return !page.clr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ConnectionListResultPage) Response() ConnectionListResult { + return page.clr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ConnectionListResultPage) Values() []Connection { + if page.clr.IsEmpty() { + return nil + } + return *page.clr.Value +} + +// ConnectionProperties definition of the connection properties. +type ConnectionProperties struct { + // ConnectionType - Gets or sets the connectionType of the connection. + ConnectionType *ConnectionTypeAssociationProperty `json:"connectionType,omitempty"` + // FieldDefinitionValues - Gets the field definition values of the connection. + FieldDefinitionValues map[string]*string `json:"fieldDefinitionValues"` + // CreationTime - Gets the creation time. + CreationTime *date.Time `json:"creationTime,omitempty"` + // LastModifiedTime - Gets the last modified time. + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + // Description - Gets or sets the description. + Description *string `json:"description,omitempty"` +} + +// MarshalJSON is the custom marshaler for ConnectionProperties. +func (cp ConnectionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cp.ConnectionType != nil { + objectMap["connectionType"] = cp.ConnectionType + } + if cp.FieldDefinitionValues != nil { + objectMap["fieldDefinitionValues"] = cp.FieldDefinitionValues + } + if cp.CreationTime != nil { + objectMap["creationTime"] = cp.CreationTime + } + if cp.LastModifiedTime != nil { + objectMap["lastModifiedTime"] = cp.LastModifiedTime + } + if cp.Description != nil { + objectMap["description"] = cp.Description + } + return json.Marshal(objectMap) +} + +// ConnectionType definition of the connection type. +type ConnectionType struct { + autorest.Response `json:"-"` + // ID - Gets the id of the resource. + ID *string `json:"id,omitempty"` + // Name - Gets the name of the connection type. + Name *string `json:"name,omitempty"` + // Type - Resource type + Type *string `json:"type,omitempty"` + // ConnectionTypeProperties - Gets or sets the properties of the connection type. + *ConnectionTypeProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for ConnectionType. +func (ct ConnectionType) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ct.ID != nil { + objectMap["id"] = ct.ID + } + if ct.Name != nil { + objectMap["name"] = ct.Name + } + if ct.Type != nil { + objectMap["type"] = ct.Type + } + if ct.ConnectionTypeProperties != nil { + objectMap["properties"] = ct.ConnectionTypeProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ConnectionType struct. +func (ct *ConnectionType) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ct.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ct.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ct.Type = &typeVar + } + case "properties": + if v != nil { + var connectionTypeProperties ConnectionTypeProperties + err = json.Unmarshal(*v, &connectionTypeProperties) + if err != nil { + return err + } + ct.ConnectionTypeProperties = &connectionTypeProperties + } + } + } + + return nil +} + +// ConnectionTypeAssociationProperty the connection type property associated with the entity. +type ConnectionTypeAssociationProperty struct { + // Name - Gets or sets the name of the connection type. + Name *string `json:"name,omitempty"` +} + +// ConnectionTypeCreateOrUpdateParameters the parameters supplied to the create or update connection type +// operation. +type ConnectionTypeCreateOrUpdateParameters struct { + // Name - Gets or sets the name of the connection type. + Name *string `json:"name,omitempty"` + // ConnectionTypeCreateOrUpdateProperties - Gets or sets the value of the connection type. + *ConnectionTypeCreateOrUpdateProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for ConnectionTypeCreateOrUpdateParameters. +func (ctcoup ConnectionTypeCreateOrUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ctcoup.Name != nil { + objectMap["name"] = ctcoup.Name + } + if ctcoup.ConnectionTypeCreateOrUpdateProperties != nil { + objectMap["properties"] = ctcoup.ConnectionTypeCreateOrUpdateProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ConnectionTypeCreateOrUpdateParameters struct. +func (ctcoup *ConnectionTypeCreateOrUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ctcoup.Name = &name + } + case "properties": + if v != nil { + var connectionTypeCreateOrUpdateProperties ConnectionTypeCreateOrUpdateProperties + err = json.Unmarshal(*v, &connectionTypeCreateOrUpdateProperties) + if err != nil { + return err + } + ctcoup.ConnectionTypeCreateOrUpdateProperties = &connectionTypeCreateOrUpdateProperties + } + } + } + + return nil +} + +// ConnectionTypeCreateOrUpdateProperties the properties of the create connection type. +type ConnectionTypeCreateOrUpdateProperties struct { + // IsGlobal - Gets or sets a Boolean value to indicate if the connection type is global. + IsGlobal *bool `json:"isGlobal,omitempty"` + // FieldDefinitions - Gets or sets the field definitions of the connection type. + FieldDefinitions map[string]*FieldDefinition `json:"fieldDefinitions"` +} + +// MarshalJSON is the custom marshaler for ConnectionTypeCreateOrUpdateProperties. +func (ctcoup ConnectionTypeCreateOrUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ctcoup.IsGlobal != nil { + objectMap["isGlobal"] = ctcoup.IsGlobal + } + if ctcoup.FieldDefinitions != nil { + objectMap["fieldDefinitions"] = ctcoup.FieldDefinitions + } + return json.Marshal(objectMap) +} + +// ConnectionTypeListResult the response model for the list connection type operation. +type ConnectionTypeListResult struct { + autorest.Response `json:"-"` + // Value - Gets or sets a list of connection types. + Value *[]ConnectionType `json:"value,omitempty"` + // NextLink - Gets or sets the next link. + NextLink *string `json:"nextLink,omitempty"` +} + +// ConnectionTypeListResultIterator provides access to a complete listing of ConnectionType values. +type ConnectionTypeListResultIterator struct { + i int + page ConnectionTypeListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ConnectionTypeListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ConnectionTypeListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ConnectionTypeListResultIterator) Response() ConnectionTypeListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ConnectionTypeListResultIterator) Value() ConnectionType { + if !iter.page.NotDone() { + return ConnectionType{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (ctlr ConnectionTypeListResult) IsEmpty() bool { + return ctlr.Value == nil || len(*ctlr.Value) == 0 +} + +// connectionTypeListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ctlr ConnectionTypeListResult) connectionTypeListResultPreparer() (*http.Request, error) { + if ctlr.NextLink == nil || len(to.String(ctlr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ctlr.NextLink))) +} + +// ConnectionTypeListResultPage contains a page of ConnectionType values. +type ConnectionTypeListResultPage struct { + fn func(ConnectionTypeListResult) (ConnectionTypeListResult, error) + ctlr ConnectionTypeListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ConnectionTypeListResultPage) Next() error { + next, err := page.fn(page.ctlr) + if err != nil { + return err + } + page.ctlr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ConnectionTypeListResultPage) NotDone() bool { + return !page.ctlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ConnectionTypeListResultPage) Response() ConnectionTypeListResult { + return page.ctlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ConnectionTypeListResultPage) Values() []ConnectionType { + if page.ctlr.IsEmpty() { + return nil + } + return *page.ctlr.Value +} + +// ConnectionTypeProperties properties of the connection type. +type ConnectionTypeProperties struct { + // IsGlobal - Gets or sets a Boolean value to indicate if the connection type is global. + IsGlobal *bool `json:"isGlobal,omitempty"` + // FieldDefinitions - Gets the field definitions of the connection type. + FieldDefinitions map[string]*FieldDefinition `json:"fieldDefinitions"` + // CreationTime - Gets the creation time. + CreationTime *date.Time `json:"creationTime,omitempty"` + // LastModifiedTime - Gets or sets the last modified time. + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + // Description - Gets or sets the description. + Description *string `json:"description,omitempty"` +} + +// MarshalJSON is the custom marshaler for ConnectionTypeProperties. +func (ctp ConnectionTypeProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ctp.IsGlobal != nil { + objectMap["isGlobal"] = ctp.IsGlobal + } + if ctp.FieldDefinitions != nil { + objectMap["fieldDefinitions"] = ctp.FieldDefinitions + } + if ctp.CreationTime != nil { + objectMap["creationTime"] = ctp.CreationTime + } + if ctp.LastModifiedTime != nil { + objectMap["lastModifiedTime"] = ctp.LastModifiedTime + } + if ctp.Description != nil { + objectMap["description"] = ctp.Description + } + return json.Marshal(objectMap) +} + +// ConnectionUpdateParameters the parameters supplied to the update connection operation. +type ConnectionUpdateParameters struct { + // Name - Gets or sets the name of the connection. + Name *string `json:"name,omitempty"` + // ConnectionUpdateProperties - Gets or sets the properties of the connection. + *ConnectionUpdateProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for ConnectionUpdateParameters. +func (cup ConnectionUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cup.Name != nil { + objectMap["name"] = cup.Name + } + if cup.ConnectionUpdateProperties != nil { + objectMap["properties"] = cup.ConnectionUpdateProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ConnectionUpdateParameters struct. +func (cup *ConnectionUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + cup.Name = &name + } + case "properties": + if v != nil { + var connectionUpdateProperties ConnectionUpdateProperties + err = json.Unmarshal(*v, &connectionUpdateProperties) + if err != nil { + return err + } + cup.ConnectionUpdateProperties = &connectionUpdateProperties + } + } + } + + return nil +} + +// ConnectionUpdateProperties the properties of the update connection operation. +type ConnectionUpdateProperties struct { + // Description - Gets or sets the description of the connection. + Description *string `json:"description,omitempty"` + // FieldDefinitionValues - Gets or sets the field definition values of the connection. + FieldDefinitionValues map[string]*string `json:"fieldDefinitionValues"` +} + +// MarshalJSON is the custom marshaler for ConnectionUpdateProperties. +func (cup ConnectionUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cup.Description != nil { + objectMap["description"] = cup.Description + } + if cup.FieldDefinitionValues != nil { + objectMap["fieldDefinitionValues"] = cup.FieldDefinitionValues + } + return json.Marshal(objectMap) +} + +// ContentHash definition of the runbook property type. +type ContentHash struct { + // Algorithm - Gets or sets the content hash algorithm used to hash the content. + Algorithm *string `json:"algorithm,omitempty"` + // Value - Gets or sets expected hash value of the content. + Value *string `json:"value,omitempty"` +} + +// ContentLink definition of the content link. +type ContentLink struct { + // URI - Gets or sets the uri of the runbook content. + URI *string `json:"uri,omitempty"` + // ContentHash - Gets or sets the hash. + ContentHash *ContentHash `json:"contentHash,omitempty"` + // Version - Gets or sets the version of the content. + Version *string `json:"version,omitempty"` +} + +// ContentSource definition of the content source. +type ContentSource struct { + // Hash - Gets or sets the hash. + Hash *ContentHash `json:"hash,omitempty"` + // Type - Gets or sets the content source type. Possible values include: 'EmbeddedContent', 'URI' + Type ContentSourceType `json:"type,omitempty"` + // Value - Gets or sets the value of the content. This is based on the content source type. + Value *string `json:"value,omitempty"` + // Version - Gets or sets the version of the content. + Version *string `json:"version,omitempty"` +} + +// Credential definition of the credential. +type Credential struct { + autorest.Response `json:"-"` + // CredentialProperties - Gets or sets the properties of the credential. + *CredentialProperties `json:"properties,omitempty"` + // ID - Fully qualified resource Id for the resource + ID *string `json:"id,omitempty"` + // Name - The name of the resource + Name *string `json:"name,omitempty"` + // Type - The type of the resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Credential. +func (c Credential) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if c.CredentialProperties != nil { + objectMap["properties"] = c.CredentialProperties + } + if c.ID != nil { + objectMap["id"] = c.ID + } + if c.Name != nil { + objectMap["name"] = c.Name + } + if c.Type != nil { + objectMap["type"] = c.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Credential struct. +func (c *Credential) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var credentialProperties CredentialProperties + err = json.Unmarshal(*v, &credentialProperties) + if err != nil { + return err + } + c.CredentialProperties = &credentialProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + c.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + c.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + c.Type = &typeVar + } + } + } + + return nil +} + +// CredentialCreateOrUpdateParameters the parameters supplied to the create or update credential operation. +type CredentialCreateOrUpdateParameters struct { + // Name - Gets or sets the name of the credential. + Name *string `json:"name,omitempty"` + // CredentialCreateOrUpdateProperties - Gets or sets the properties of the credential. + *CredentialCreateOrUpdateProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for CredentialCreateOrUpdateParameters. +func (ccoup CredentialCreateOrUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ccoup.Name != nil { + objectMap["name"] = ccoup.Name + } + if ccoup.CredentialCreateOrUpdateProperties != nil { + objectMap["properties"] = ccoup.CredentialCreateOrUpdateProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for CredentialCreateOrUpdateParameters struct. +func (ccoup *CredentialCreateOrUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ccoup.Name = &name + } + case "properties": + if v != nil { + var credentialCreateOrUpdateProperties CredentialCreateOrUpdateProperties + err = json.Unmarshal(*v, &credentialCreateOrUpdateProperties) + if err != nil { + return err + } + ccoup.CredentialCreateOrUpdateProperties = &credentialCreateOrUpdateProperties + } + } + } + + return nil +} + +// CredentialCreateOrUpdateProperties the properties of the create cerdential operation. +type CredentialCreateOrUpdateProperties struct { + // UserName - Gets or sets the user name of the credential. + UserName *string `json:"userName,omitempty"` + // Password - Gets or sets the password of the credential. + Password *string `json:"password,omitempty"` + // Description - Gets or sets the description of the credential. + Description *string `json:"description,omitempty"` +} + +// CredentialListResult the response model for the list credential operation. +type CredentialListResult struct { + autorest.Response `json:"-"` + // Value - Gets or sets a list of credentials. + Value *[]Credential `json:"value,omitempty"` + // NextLink - Gets or sets the next link. + NextLink *string `json:"nextLink,omitempty"` +} + +// CredentialListResultIterator provides access to a complete listing of Credential values. +type CredentialListResultIterator struct { + i int + page CredentialListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *CredentialListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter CredentialListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter CredentialListResultIterator) Response() CredentialListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter CredentialListResultIterator) Value() Credential { + if !iter.page.NotDone() { + return Credential{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (clr CredentialListResult) IsEmpty() bool { + return clr.Value == nil || len(*clr.Value) == 0 +} + +// credentialListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (clr CredentialListResult) credentialListResultPreparer() (*http.Request, error) { + if clr.NextLink == nil || len(to.String(clr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(clr.NextLink))) +} + +// CredentialListResultPage contains a page of Credential values. +type CredentialListResultPage struct { + fn func(CredentialListResult) (CredentialListResult, error) + clr CredentialListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *CredentialListResultPage) Next() error { + next, err := page.fn(page.clr) + if err != nil { + return err + } + page.clr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page CredentialListResultPage) NotDone() bool { + return !page.clr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page CredentialListResultPage) Response() CredentialListResult { + return page.clr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page CredentialListResultPage) Values() []Credential { + if page.clr.IsEmpty() { + return nil + } + return *page.clr.Value +} + +// CredentialProperties definition of the credential properties +type CredentialProperties struct { + // UserName - Gets the user name of the credential. + UserName *string `json:"userName,omitempty"` + // CreationTime - Gets the creation time. + CreationTime *date.Time `json:"creationTime,omitempty"` + // LastModifiedTime - Gets the last modified time. + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + // Description - Gets or sets the description. + Description *string `json:"description,omitempty"` +} + +// CredentialUpdateParameters the parameters supplied to the Update credential operation. +type CredentialUpdateParameters struct { + // Name - Gets or sets the name of the credential. + Name *string `json:"name,omitempty"` + // CredentialUpdateProperties - Gets or sets the properties of the variable. + *CredentialUpdateProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for CredentialUpdateParameters. +func (cup CredentialUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cup.Name != nil { + objectMap["name"] = cup.Name + } + if cup.CredentialUpdateProperties != nil { + objectMap["properties"] = cup.CredentialUpdateProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for CredentialUpdateParameters struct. +func (cup *CredentialUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + cup.Name = &name + } + case "properties": + if v != nil { + var credentialUpdateProperties CredentialUpdateProperties + err = json.Unmarshal(*v, &credentialUpdateProperties) + if err != nil { + return err + } + cup.CredentialUpdateProperties = &credentialUpdateProperties + } + } + } + + return nil +} + +// CredentialUpdateProperties the properties of the Update credential +type CredentialUpdateProperties struct { + // UserName - Gets or sets the user name of the credential. + UserName *string `json:"userName,omitempty"` + // Password - Gets or sets the password of the credential. + Password *string `json:"password,omitempty"` + // Description - Gets or sets the description of the credential. + Description *string `json:"description,omitempty"` +} + +// DscCompilationJob definition of the Dsc Compilation job. +type DscCompilationJob struct { + autorest.Response `json:"-"` + // DscCompilationJobProperties - Gets or sets the properties of the Dsc Compilation job. + *DscCompilationJobProperties `json:"properties,omitempty"` + // ID - Fully qualified resource Id for the resource + ID *string `json:"id,omitempty"` + // Name - The name of the resource + Name *string `json:"name,omitempty"` + // Type - The type of the resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for DscCompilationJob. +func (dcj DscCompilationJob) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dcj.DscCompilationJobProperties != nil { + objectMap["properties"] = dcj.DscCompilationJobProperties + } + if dcj.ID != nil { + objectMap["id"] = dcj.ID + } + if dcj.Name != nil { + objectMap["name"] = dcj.Name + } + if dcj.Type != nil { + objectMap["type"] = dcj.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DscCompilationJob struct. +func (dcj *DscCompilationJob) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var dscCompilationJobProperties DscCompilationJobProperties + err = json.Unmarshal(*v, &dscCompilationJobProperties) + if err != nil { + return err + } + dcj.DscCompilationJobProperties = &dscCompilationJobProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + dcj.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dcj.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + dcj.Type = &typeVar + } + } + } + + return nil +} + +// DscCompilationJobCreateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type DscCompilationJobCreateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *DscCompilationJobCreateFuture) Result(client DscCompilationJobClient) (dcj DscCompilationJob, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobCreateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("automation.DscCompilationJobCreateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if dcj.Response.Response, err = future.GetResult(sender); err == nil && dcj.Response.Response.StatusCode != http.StatusNoContent { + dcj, err = client.CreateResponder(dcj.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobCreateFuture", "Result", dcj.Response.Response, "Failure responding to request") + } + } + return +} + +// DscCompilationJobCreateParameters the parameters supplied to the create compilation job operation. +type DscCompilationJobCreateParameters struct { + // DscCompilationJobCreateProperties - Gets or sets the list of compilation job properties. + *DscCompilationJobCreateProperties `json:"properties,omitempty"` + // Name - Gets or sets name of the resource. + Name *string `json:"name,omitempty"` + // Location - Gets or sets the location of the resource. + Location *string `json:"location,omitempty"` + // Tags - Gets or sets the tags attached to the resource. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for DscCompilationJobCreateParameters. +func (dcjcp DscCompilationJobCreateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dcjcp.DscCompilationJobCreateProperties != nil { + objectMap["properties"] = dcjcp.DscCompilationJobCreateProperties + } + if dcjcp.Name != nil { + objectMap["name"] = dcjcp.Name + } + if dcjcp.Location != nil { + objectMap["location"] = dcjcp.Location + } + if dcjcp.Tags != nil { + objectMap["tags"] = dcjcp.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DscCompilationJobCreateParameters struct. +func (dcjcp *DscCompilationJobCreateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var dscCompilationJobCreateProperties DscCompilationJobCreateProperties + err = json.Unmarshal(*v, &dscCompilationJobCreateProperties) + if err != nil { + return err + } + dcjcp.DscCompilationJobCreateProperties = &dscCompilationJobCreateProperties + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dcjcp.Name = &name + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + dcjcp.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + dcjcp.Tags = tags + } + } + } + + return nil +} + +// DscCompilationJobCreateProperties the parameters supplied to the create compilation job operation. +type DscCompilationJobCreateProperties struct { + // Configuration - Gets or sets the configuration. + Configuration *DscConfigurationAssociationProperty `json:"configuration,omitempty"` + // Parameters - Gets or sets the parameters of the job. + Parameters map[string]*string `json:"parameters"` + // IncrementNodeConfigurationBuild - If a new build version of NodeConfiguration is required. + IncrementNodeConfigurationBuild *bool `json:"incrementNodeConfigurationBuild,omitempty"` +} + +// MarshalJSON is the custom marshaler for DscCompilationJobCreateProperties. +func (dcjcp DscCompilationJobCreateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dcjcp.Configuration != nil { + objectMap["configuration"] = dcjcp.Configuration + } + if dcjcp.Parameters != nil { + objectMap["parameters"] = dcjcp.Parameters + } + if dcjcp.IncrementNodeConfigurationBuild != nil { + objectMap["incrementNodeConfigurationBuild"] = dcjcp.IncrementNodeConfigurationBuild + } + return json.Marshal(objectMap) +} + +// DscCompilationJobListResult the response model for the list job operation. +type DscCompilationJobListResult struct { + autorest.Response `json:"-"` + // Value - Gets or sets a list of Dsc Compilation jobs. + Value *[]DscCompilationJob `json:"value,omitempty"` + // NextLink - Gets or sets the next link. + NextLink *string `json:"nextLink,omitempty"` +} + +// DscCompilationJobListResultIterator provides access to a complete listing of DscCompilationJob values. +type DscCompilationJobListResultIterator struct { + i int + page DscCompilationJobListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *DscCompilationJobListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter DscCompilationJobListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter DscCompilationJobListResultIterator) Response() DscCompilationJobListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter DscCompilationJobListResultIterator) Value() DscCompilationJob { + if !iter.page.NotDone() { + return DscCompilationJob{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (dcjlr DscCompilationJobListResult) IsEmpty() bool { + return dcjlr.Value == nil || len(*dcjlr.Value) == 0 +} + +// dscCompilationJobListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (dcjlr DscCompilationJobListResult) dscCompilationJobListResultPreparer() (*http.Request, error) { + if dcjlr.NextLink == nil || len(to.String(dcjlr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(dcjlr.NextLink))) +} + +// DscCompilationJobListResultPage contains a page of DscCompilationJob values. +type DscCompilationJobListResultPage struct { + fn func(DscCompilationJobListResult) (DscCompilationJobListResult, error) + dcjlr DscCompilationJobListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *DscCompilationJobListResultPage) Next() error { + next, err := page.fn(page.dcjlr) + if err != nil { + return err + } + page.dcjlr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page DscCompilationJobListResultPage) NotDone() bool { + return !page.dcjlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page DscCompilationJobListResultPage) Response() DscCompilationJobListResult { + return page.dcjlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page DscCompilationJobListResultPage) Values() []DscCompilationJob { + if page.dcjlr.IsEmpty() { + return nil + } + return *page.dcjlr.Value +} + +// DscCompilationJobProperties definition of Dsc Compilation job properties. +type DscCompilationJobProperties struct { + // Configuration - Gets or sets the configuration. + Configuration *DscConfigurationAssociationProperty `json:"configuration,omitempty"` + // StartedBy - Gets the compilation job started by. + StartedBy *string `json:"startedBy,omitempty"` + // JobID - Gets the id of the job. + JobID *uuid.UUID `json:"jobId,omitempty"` + // CreationTime - Gets the creation time of the job. + CreationTime *date.Time `json:"creationTime,omitempty"` + // ProvisioningState - The current provisioning state of the job. Possible values include: 'JobProvisioningStateFailed', 'JobProvisioningStateSucceeded', 'JobProvisioningStateSuspended', 'JobProvisioningStateProcessing' + ProvisioningState JobProvisioningState `json:"provisioningState,omitempty"` + // RunOn - Gets or sets the runOn which specifies the group name where the job is to be executed. + RunOn *string `json:"runOn,omitempty"` + // Status - Gets or sets the status of the job. Possible values include: 'JobStatusNew', 'JobStatusActivating', 'JobStatusRunning', 'JobStatusCompleted', 'JobStatusFailed', 'JobStatusStopped', 'JobStatusBlocked', 'JobStatusSuspended', 'JobStatusDisconnected', 'JobStatusSuspending', 'JobStatusStopping', 'JobStatusResuming', 'JobStatusRemoving' + Status JobStatus `json:"status,omitempty"` + // StatusDetails - Gets or sets the status details of the job. + StatusDetails *string `json:"statusDetails,omitempty"` + // StartTime - Gets the start time of the job. + StartTime *date.Time `json:"startTime,omitempty"` + // EndTime - Gets the end time of the job. + EndTime *date.Time `json:"endTime,omitempty"` + // Exception - Gets the exception of the job. + Exception *string `json:"exception,omitempty"` + // LastModifiedTime - Gets the last modified time of the job. + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + // LastStatusModifiedTime - Gets the last status modified time of the job. + LastStatusModifiedTime *date.Time `json:"lastStatusModifiedTime,omitempty"` + // Parameters - Gets or sets the parameters of the job. + Parameters map[string]*string `json:"parameters"` +} + +// MarshalJSON is the custom marshaler for DscCompilationJobProperties. +func (dcjp DscCompilationJobProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dcjp.Configuration != nil { + objectMap["configuration"] = dcjp.Configuration + } + if dcjp.StartedBy != nil { + objectMap["startedBy"] = dcjp.StartedBy + } + if dcjp.JobID != nil { + objectMap["jobId"] = dcjp.JobID + } + if dcjp.CreationTime != nil { + objectMap["creationTime"] = dcjp.CreationTime + } + if dcjp.ProvisioningState != "" { + objectMap["provisioningState"] = dcjp.ProvisioningState + } + if dcjp.RunOn != nil { + objectMap["runOn"] = dcjp.RunOn + } + if dcjp.Status != "" { + objectMap["status"] = dcjp.Status + } + if dcjp.StatusDetails != nil { + objectMap["statusDetails"] = dcjp.StatusDetails + } + if dcjp.StartTime != nil { + objectMap["startTime"] = dcjp.StartTime + } + if dcjp.EndTime != nil { + objectMap["endTime"] = dcjp.EndTime + } + if dcjp.Exception != nil { + objectMap["exception"] = dcjp.Exception + } + if dcjp.LastModifiedTime != nil { + objectMap["lastModifiedTime"] = dcjp.LastModifiedTime + } + if dcjp.LastStatusModifiedTime != nil { + objectMap["lastStatusModifiedTime"] = dcjp.LastStatusModifiedTime + } + if dcjp.Parameters != nil { + objectMap["parameters"] = dcjp.Parameters + } + return json.Marshal(objectMap) +} + +// DscConfiguration definition of the configuration type. +type DscConfiguration struct { + autorest.Response `json:"-"` + // DscConfigurationProperties - Gets or sets the configuration properties. + *DscConfigurationProperties `json:"properties,omitempty"` + // Etag - Gets or sets the etag of the resource. + Etag *string `json:"etag,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The Azure Region where the resource lives + Location *string `json:"location,omitempty"` + // ID - Fully qualified resource Id for the resource + ID *string `json:"id,omitempty"` + // Name - The name of the resource + Name *string `json:"name,omitempty"` + // Type - The type of the resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for DscConfiguration. +func (dc DscConfiguration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dc.DscConfigurationProperties != nil { + objectMap["properties"] = dc.DscConfigurationProperties + } + if dc.Etag != nil { + objectMap["etag"] = dc.Etag + } + if dc.Tags != nil { + objectMap["tags"] = dc.Tags + } + if dc.Location != nil { + objectMap["location"] = dc.Location + } + if dc.ID != nil { + objectMap["id"] = dc.ID + } + if dc.Name != nil { + objectMap["name"] = dc.Name + } + if dc.Type != nil { + objectMap["type"] = dc.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DscConfiguration struct. +func (dc *DscConfiguration) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var dscConfigurationProperties DscConfigurationProperties + err = json.Unmarshal(*v, &dscConfigurationProperties) + if err != nil { + return err + } + dc.DscConfigurationProperties = &dscConfigurationProperties + } + case "etag": + if v != nil { + var etag string + err = json.Unmarshal(*v, &etag) + if err != nil { + return err + } + dc.Etag = &etag + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + dc.Tags = tags + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + dc.Location = &location + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + dc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + dc.Type = &typeVar + } + } + } + + return nil +} + +// DscConfigurationAssociationProperty the Dsc configuration property associated with the entity. +type DscConfigurationAssociationProperty struct { + // Name - Gets or sets the name of the Dsc configuration. + Name *string `json:"name,omitempty"` +} + +// DscConfigurationCreateOrUpdateParameters the parameters supplied to the create or update configuration +// operation. +type DscConfigurationCreateOrUpdateParameters struct { + // DscConfigurationCreateOrUpdateProperties - Gets or sets configuration create or update properties. + *DscConfigurationCreateOrUpdateProperties `json:"properties,omitempty"` + // Name - Gets or sets name of the resource. + Name *string `json:"name,omitempty"` + // Location - Gets or sets the location of the resource. + Location *string `json:"location,omitempty"` + // Tags - Gets or sets the tags attached to the resource. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for DscConfigurationCreateOrUpdateParameters. +func (dccoup DscConfigurationCreateOrUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dccoup.DscConfigurationCreateOrUpdateProperties != nil { + objectMap["properties"] = dccoup.DscConfigurationCreateOrUpdateProperties + } + if dccoup.Name != nil { + objectMap["name"] = dccoup.Name + } + if dccoup.Location != nil { + objectMap["location"] = dccoup.Location + } + if dccoup.Tags != nil { + objectMap["tags"] = dccoup.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DscConfigurationCreateOrUpdateParameters struct. +func (dccoup *DscConfigurationCreateOrUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var dscConfigurationCreateOrUpdateProperties DscConfigurationCreateOrUpdateProperties + err = json.Unmarshal(*v, &dscConfigurationCreateOrUpdateProperties) + if err != nil { + return err + } + dccoup.DscConfigurationCreateOrUpdateProperties = &dscConfigurationCreateOrUpdateProperties + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dccoup.Name = &name + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + dccoup.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + dccoup.Tags = tags + } + } + } + + return nil +} + +// DscConfigurationCreateOrUpdateProperties the properties to create or update configuration. +type DscConfigurationCreateOrUpdateProperties struct { + // LogVerbose - Gets or sets verbose log option. + LogVerbose *bool `json:"logVerbose,omitempty"` + // LogProgress - Gets or sets progress log option. + LogProgress *bool `json:"logProgress,omitempty"` + // Source - Gets or sets the source. + Source *ContentSource `json:"source,omitempty"` + // Parameters - Gets or sets the configuration parameters. + Parameters map[string]*DscConfigurationParameter `json:"parameters"` + // Description - Gets or sets the description of the configuration. + Description *string `json:"description,omitempty"` +} + +// MarshalJSON is the custom marshaler for DscConfigurationCreateOrUpdateProperties. +func (dccoup DscConfigurationCreateOrUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dccoup.LogVerbose != nil { + objectMap["logVerbose"] = dccoup.LogVerbose + } + if dccoup.LogProgress != nil { + objectMap["logProgress"] = dccoup.LogProgress + } + if dccoup.Source != nil { + objectMap["source"] = dccoup.Source + } + if dccoup.Parameters != nil { + objectMap["parameters"] = dccoup.Parameters + } + if dccoup.Description != nil { + objectMap["description"] = dccoup.Description + } + return json.Marshal(objectMap) +} + +// DscConfigurationListResult the response model for the list configuration operation. +type DscConfigurationListResult struct { + autorest.Response `json:"-"` + // Value - Gets or sets a list of configurations. + Value *[]DscConfiguration `json:"value,omitempty"` + // NextLink - Gets or sets the next link. + NextLink *string `json:"nextLink,omitempty"` + // TotalCount - Gets the total number of configurations matching filter criteria. + TotalCount *int32 `json:"totalCount,omitempty"` +} + +// DscConfigurationListResultIterator provides access to a complete listing of DscConfiguration values. +type DscConfigurationListResultIterator struct { + i int + page DscConfigurationListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *DscConfigurationListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter DscConfigurationListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter DscConfigurationListResultIterator) Response() DscConfigurationListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter DscConfigurationListResultIterator) Value() DscConfiguration { + if !iter.page.NotDone() { + return DscConfiguration{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (dclr DscConfigurationListResult) IsEmpty() bool { + return dclr.Value == nil || len(*dclr.Value) == 0 +} + +// dscConfigurationListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (dclr DscConfigurationListResult) dscConfigurationListResultPreparer() (*http.Request, error) { + if dclr.NextLink == nil || len(to.String(dclr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(dclr.NextLink))) +} + +// DscConfigurationListResultPage contains a page of DscConfiguration values. +type DscConfigurationListResultPage struct { + fn func(DscConfigurationListResult) (DscConfigurationListResult, error) + dclr DscConfigurationListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *DscConfigurationListResultPage) Next() error { + next, err := page.fn(page.dclr) + if err != nil { + return err + } + page.dclr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page DscConfigurationListResultPage) NotDone() bool { + return !page.dclr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page DscConfigurationListResultPage) Response() DscConfigurationListResult { + return page.dclr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page DscConfigurationListResultPage) Values() []DscConfiguration { + if page.dclr.IsEmpty() { + return nil + } + return *page.dclr.Value +} + +// DscConfigurationParameter definition of the configuration parameter type. +type DscConfigurationParameter struct { + // Type - Gets or sets the type of the parameter. + Type *string `json:"type,omitempty"` + // IsMandatory - Gets or sets a Boolean value to indicate whether the parameter is madatory or not. + IsMandatory *bool `json:"isMandatory,omitempty"` + // Position - Get or sets the position of the parameter. + Position *int32 `json:"position,omitempty"` + // DefaultValue - Gets or sets the default value of parameter. + DefaultValue *string `json:"defaultValue,omitempty"` +} + +// DscConfigurationProperties definition of the configuration property type. +type DscConfigurationProperties struct { + // ProvisioningState - Gets or sets the provisioning state of the configuration. Possible values include: 'Succeeded' + ProvisioningState DscConfigurationProvisioningState `json:"provisioningState,omitempty"` + // JobCount - Gets or sets the job count of the configuration. + JobCount *int32 `json:"jobCount,omitempty"` + // Parameters - Gets or sets the configuration parameters. + Parameters map[string]*DscConfigurationParameter `json:"parameters"` + // Source - Gets or sets the source. + Source *ContentSource `json:"source,omitempty"` + // State - Gets or sets the state of the configuration. Possible values include: 'DscConfigurationStateNew', 'DscConfigurationStateEdit', 'DscConfigurationStatePublished' + State DscConfigurationState `json:"state,omitempty"` + // LogVerbose - Gets or sets verbose log option. + LogVerbose *bool `json:"logVerbose,omitempty"` + // CreationTime - Gets or sets the creation time. + CreationTime *date.Time `json:"creationTime,omitempty"` + // LastModifiedTime - Gets or sets the last modified time. + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + // NodeConfigurationCount - Gets the number of compiled node configurations. + NodeConfigurationCount *int32 `json:"nodeConfigurationCount,omitempty"` + // Description - Gets or sets the description. + Description *string `json:"description,omitempty"` +} + +// MarshalJSON is the custom marshaler for DscConfigurationProperties. +func (dcp DscConfigurationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dcp.ProvisioningState != "" { + objectMap["provisioningState"] = dcp.ProvisioningState + } + if dcp.JobCount != nil { + objectMap["jobCount"] = dcp.JobCount + } + if dcp.Parameters != nil { + objectMap["parameters"] = dcp.Parameters + } + if dcp.Source != nil { + objectMap["source"] = dcp.Source + } + if dcp.State != "" { + objectMap["state"] = dcp.State + } + if dcp.LogVerbose != nil { + objectMap["logVerbose"] = dcp.LogVerbose + } + if dcp.CreationTime != nil { + objectMap["creationTime"] = dcp.CreationTime + } + if dcp.LastModifiedTime != nil { + objectMap["lastModifiedTime"] = dcp.LastModifiedTime + } + if dcp.NodeConfigurationCount != nil { + objectMap["nodeConfigurationCount"] = dcp.NodeConfigurationCount + } + if dcp.Description != nil { + objectMap["description"] = dcp.Description + } + return json.Marshal(objectMap) +} + +// DscConfigurationUpdateParameters the parameters supplied to the create or update configuration operation. +type DscConfigurationUpdateParameters struct { + // DscConfigurationCreateOrUpdateProperties - Gets or sets configuration create or update properties. + *DscConfigurationCreateOrUpdateProperties `json:"properties,omitempty"` + // Name - Gets or sets name of the resource. + Name *string `json:"name,omitempty"` + // Tags - Gets or sets the tags attached to the resource. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for DscConfigurationUpdateParameters. +func (dcup DscConfigurationUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dcup.DscConfigurationCreateOrUpdateProperties != nil { + objectMap["properties"] = dcup.DscConfigurationCreateOrUpdateProperties + } + if dcup.Name != nil { + objectMap["name"] = dcup.Name + } + if dcup.Tags != nil { + objectMap["tags"] = dcup.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DscConfigurationUpdateParameters struct. +func (dcup *DscConfigurationUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var dscConfigurationCreateOrUpdateProperties DscConfigurationCreateOrUpdateProperties + err = json.Unmarshal(*v, &dscConfigurationCreateOrUpdateProperties) + if err != nil { + return err + } + dcup.DscConfigurationCreateOrUpdateProperties = &dscConfigurationCreateOrUpdateProperties + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dcup.Name = &name + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + dcup.Tags = tags + } + } + } + + return nil +} + +// DscMetaConfiguration definition of the DSC Meta Configuration. +type DscMetaConfiguration struct { + // ConfigurationModeFrequencyMins - Gets or sets the ConfigurationModeFrequencyMins value of the meta configuration. + ConfigurationModeFrequencyMins *int32 `json:"configurationModeFrequencyMins,omitempty"` + // RebootNodeIfNeeded - Gets or sets the RebootNodeIfNeeded value of the meta configuration. + RebootNodeIfNeeded *bool `json:"rebootNodeIfNeeded,omitempty"` + // ConfigurationMode - Gets or sets the ConfigurationMode value of the meta configuration. + ConfigurationMode *string `json:"configurationMode,omitempty"` + // ActionAfterReboot - Gets or sets the ActionAfterReboot value of the meta configuration. + ActionAfterReboot *string `json:"actionAfterReboot,omitempty"` + // CertificateID - Gets or sets the CertificateId value of the meta configuration. + CertificateID *string `json:"certificateId,omitempty"` + // RefreshFrequencyMins - Gets or sets the RefreshFrequencyMins value of the meta configuration. + RefreshFrequencyMins *int32 `json:"refreshFrequencyMins,omitempty"` + // AllowModuleOverwrite - Gets or sets the AllowModuleOverwrite value of the meta configuration. + AllowModuleOverwrite *bool `json:"allowModuleOverwrite,omitempty"` +} + +// DscNode definition of a DscNode +type DscNode struct { + autorest.Response `json:"-"` + // DscNodeProperties - The properties of a DscNode. + *DscNodeProperties `json:"properties,omitempty"` + // ID - Fully qualified resource Id for the resource + ID *string `json:"id,omitempty"` + // Name - The name of the resource + Name *string `json:"name,omitempty"` + // Type - The type of the resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for DscNode. +func (dn DscNode) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dn.DscNodeProperties != nil { + objectMap["properties"] = dn.DscNodeProperties + } + if dn.ID != nil { + objectMap["id"] = dn.ID + } + if dn.Name != nil { + objectMap["name"] = dn.Name + } + if dn.Type != nil { + objectMap["type"] = dn.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DscNode struct. +func (dn *DscNode) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var dscNodeProperties DscNodeProperties + err = json.Unmarshal(*v, &dscNodeProperties) + if err != nil { + return err + } + dn.DscNodeProperties = &dscNodeProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + dn.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dn.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + dn.Type = &typeVar + } + } + } + + return nil +} + +// DscNodeConfiguration definition of the dsc node configuration. +type DscNodeConfiguration struct { + autorest.Response `json:"-"` + // DscNodeConfigurationProperties - Gets or sets the configuration properties. + *DscNodeConfigurationProperties `json:"properties,omitempty"` + // ID - Fully qualified resource Id for the resource + ID *string `json:"id,omitempty"` + // Name - The name of the resource + Name *string `json:"name,omitempty"` + // Type - The type of the resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for DscNodeConfiguration. +func (dnc DscNodeConfiguration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dnc.DscNodeConfigurationProperties != nil { + objectMap["properties"] = dnc.DscNodeConfigurationProperties + } + if dnc.ID != nil { + objectMap["id"] = dnc.ID + } + if dnc.Name != nil { + objectMap["name"] = dnc.Name + } + if dnc.Type != nil { + objectMap["type"] = dnc.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DscNodeConfiguration struct. +func (dnc *DscNodeConfiguration) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var dscNodeConfigurationProperties DscNodeConfigurationProperties + err = json.Unmarshal(*v, &dscNodeConfigurationProperties) + if err != nil { + return err + } + dnc.DscNodeConfigurationProperties = &dscNodeConfigurationProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + dnc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dnc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + dnc.Type = &typeVar + } + } + } + + return nil +} + +// DscNodeConfigurationAssociationProperty the dsc nodeconfiguration property associated with the entity. +type DscNodeConfigurationAssociationProperty struct { + // Name - Gets or sets the name of the dsc nodeconfiguration. + Name *string `json:"name,omitempty"` +} + +// DscNodeConfigurationCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type DscNodeConfigurationCreateOrUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *DscNodeConfigurationCreateOrUpdateFuture) Result(client DscNodeConfigurationClient) (dnc DscNodeConfiguration, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeConfigurationCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("automation.DscNodeConfigurationCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if dnc.Response.Response, err = future.GetResult(sender); err == nil && dnc.Response.Response.StatusCode != http.StatusNoContent { + dnc, err = client.CreateOrUpdateResponder(dnc.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeConfigurationCreateOrUpdateFuture", "Result", dnc.Response.Response, "Failure responding to request") + } + } + return +} + +// DscNodeConfigurationCreateOrUpdateParameters the parameters supplied to the create or update node configuration +// operation. +type DscNodeConfigurationCreateOrUpdateParameters struct { + // DscNodeConfigurationCreateOrUpdateParametersProperties - Node configuration properties + *DscNodeConfigurationCreateOrUpdateParametersProperties `json:"properties,omitempty"` + // Name - Name of the node configuration. + Name *string `json:"name,omitempty"` + // Tags - Gets or sets the tags attached to the resource. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for DscNodeConfigurationCreateOrUpdateParameters. +func (dnccoup DscNodeConfigurationCreateOrUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dnccoup.DscNodeConfigurationCreateOrUpdateParametersProperties != nil { + objectMap["properties"] = dnccoup.DscNodeConfigurationCreateOrUpdateParametersProperties + } + if dnccoup.Name != nil { + objectMap["name"] = dnccoup.Name + } + if dnccoup.Tags != nil { + objectMap["tags"] = dnccoup.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DscNodeConfigurationCreateOrUpdateParameters struct. +func (dnccoup *DscNodeConfigurationCreateOrUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var dscNodeConfigurationCreateOrUpdateParametersProperties DscNodeConfigurationCreateOrUpdateParametersProperties + err = json.Unmarshal(*v, &dscNodeConfigurationCreateOrUpdateParametersProperties) + if err != nil { + return err + } + dnccoup.DscNodeConfigurationCreateOrUpdateParametersProperties = &dscNodeConfigurationCreateOrUpdateParametersProperties + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dnccoup.Name = &name + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + dnccoup.Tags = tags + } + } + } + + return nil +} + +// DscNodeConfigurationCreateOrUpdateParametersProperties the parameter properties supplied to the create or update +// node configuration operation. +type DscNodeConfigurationCreateOrUpdateParametersProperties struct { + // Source - Gets or sets the source. + Source *ContentSource `json:"source,omitempty"` + // Configuration - Gets or sets the configuration of the node. + Configuration *DscConfigurationAssociationProperty `json:"configuration,omitempty"` + // IncrementNodeConfigurationBuild - If a new build version of NodeConfiguration is required. + IncrementNodeConfigurationBuild *bool `json:"incrementNodeConfigurationBuild,omitempty"` +} + +// DscNodeConfigurationListResult the response model for the list job operation. +type DscNodeConfigurationListResult struct { + autorest.Response `json:"-"` + // Value - Gets or sets a list of Dsc node configurations. + Value *[]DscNodeConfiguration `json:"value,omitempty"` + // NextLink - Gets or sets the next link. + NextLink *string `json:"nextLink,omitempty"` + // TotalCount - Gets or sets the total rows in query. + TotalCount *int32 `json:"totalCount,omitempty"` +} + +// DscNodeConfigurationListResultIterator provides access to a complete listing of DscNodeConfiguration values. +type DscNodeConfigurationListResultIterator struct { + i int + page DscNodeConfigurationListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *DscNodeConfigurationListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter DscNodeConfigurationListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter DscNodeConfigurationListResultIterator) Response() DscNodeConfigurationListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter DscNodeConfigurationListResultIterator) Value() DscNodeConfiguration { + if !iter.page.NotDone() { + return DscNodeConfiguration{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (dnclr DscNodeConfigurationListResult) IsEmpty() bool { + return dnclr.Value == nil || len(*dnclr.Value) == 0 +} + +// dscNodeConfigurationListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (dnclr DscNodeConfigurationListResult) dscNodeConfigurationListResultPreparer() (*http.Request, error) { + if dnclr.NextLink == nil || len(to.String(dnclr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(dnclr.NextLink))) +} + +// DscNodeConfigurationListResultPage contains a page of DscNodeConfiguration values. +type DscNodeConfigurationListResultPage struct { + fn func(DscNodeConfigurationListResult) (DscNodeConfigurationListResult, error) + dnclr DscNodeConfigurationListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *DscNodeConfigurationListResultPage) Next() error { + next, err := page.fn(page.dnclr) + if err != nil { + return err + } + page.dnclr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page DscNodeConfigurationListResultPage) NotDone() bool { + return !page.dnclr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page DscNodeConfigurationListResultPage) Response() DscNodeConfigurationListResult { + return page.dnclr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page DscNodeConfigurationListResultPage) Values() []DscNodeConfiguration { + if page.dnclr.IsEmpty() { + return nil + } + return *page.dnclr.Value +} + +// DscNodeConfigurationProperties properties for the DscNodeConfiguration +type DscNodeConfigurationProperties struct { + // LastModifiedTime - Gets or sets the last modified time. + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + // CreationTime - Gets or sets creation time. + CreationTime *date.Time `json:"creationTime,omitempty"` + // Configuration - Gets or sets the configuration of the node. + Configuration *DscConfigurationAssociationProperty `json:"configuration,omitempty"` + // Source - Source of node configuration. + Source *string `json:"source,omitempty"` + // NodeCount - Number of nodes with this nodeconfiguration assigned + NodeCount *int64 `json:"nodeCount,omitempty"` + // IncrementNodeConfigurationBuild - If a new build version of NodeConfiguration is required. + IncrementNodeConfigurationBuild *bool `json:"incrementNodeConfigurationBuild,omitempty"` +} + +// DscNodeExtensionHandlerAssociationProperty the dsc extensionHandler property associated with the node +type DscNodeExtensionHandlerAssociationProperty struct { + // Name - Gets or sets the name of the extension handler. + Name *string `json:"name,omitempty"` + // Version - Gets or sets the version of the extension handler. + Version *string `json:"version,omitempty"` +} + +// DscNodeListResult the response model for the list dsc nodes operation. +type DscNodeListResult struct { + autorest.Response `json:"-"` + // Value - Gets or sets a list of dsc nodes. + Value *[]DscNode `json:"value,omitempty"` + // NextLink - Gets or sets the next link. + NextLink *string `json:"nextLink,omitempty"` + // TotalCount - Gets the total number of nodes matching filter criteria. + TotalCount *int32 `json:"totalCount,omitempty"` +} + +// DscNodeListResultIterator provides access to a complete listing of DscNode values. +type DscNodeListResultIterator struct { + i int + page DscNodeListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *DscNodeListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter DscNodeListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter DscNodeListResultIterator) Response() DscNodeListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter DscNodeListResultIterator) Value() DscNode { + if !iter.page.NotDone() { + return DscNode{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (dnlr DscNodeListResult) IsEmpty() bool { + return dnlr.Value == nil || len(*dnlr.Value) == 0 +} + +// dscNodeListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (dnlr DscNodeListResult) dscNodeListResultPreparer() (*http.Request, error) { + if dnlr.NextLink == nil || len(to.String(dnlr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(dnlr.NextLink))) +} + +// DscNodeListResultPage contains a page of DscNode values. +type DscNodeListResultPage struct { + fn func(DscNodeListResult) (DscNodeListResult, error) + dnlr DscNodeListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *DscNodeListResultPage) Next() error { + next, err := page.fn(page.dnlr) + if err != nil { + return err + } + page.dnlr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page DscNodeListResultPage) NotDone() bool { + return !page.dnlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page DscNodeListResultPage) Response() DscNodeListResult { + return page.dnlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page DscNodeListResultPage) Values() []DscNode { + if page.dnlr.IsEmpty() { + return nil + } + return *page.dnlr.Value +} + +// DscNodeProperties the properties of a DscNode +type DscNodeProperties struct { + // LastSeen - Gets or sets the last seen time of the node. + LastSeen *date.Time `json:"lastSeen,omitempty"` + // RegistrationTime - Gets or sets the registration time of the node. + RegistrationTime *date.Time `json:"registrationTime,omitempty"` + // IP - Gets or sets the ip of the node. + IP *string `json:"ip,omitempty"` + // AccountID - Gets or sets the account id of the node. + AccountID *string `json:"accountId,omitempty"` + // DscNodeConfigurationAssociationProperty - Gets or sets the configuration of the node. + *DscNodeConfigurationAssociationProperty `json:"nodeConfiguration,omitempty"` + // Status - Gets or sets the status of the node. + Status *string `json:"status,omitempty"` + // NodeID - Gets or sets the node id. + NodeID *string `json:"nodeId,omitempty"` + // Etag - Gets or sets the etag of the resource. + Etag *string `json:"etag,omitempty"` + // TotalCount - Gets the total number of records matching filter criteria. + TotalCount *int32 `json:"totalCount,omitempty"` + // ExtensionHandler - Gets or sets the list of extensionHandler properties for a Node. + ExtensionHandler *[]DscNodeExtensionHandlerAssociationProperty `json:"extensionHandler,omitempty"` +} + +// MarshalJSON is the custom marshaler for DscNodeProperties. +func (dnp DscNodeProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dnp.LastSeen != nil { + objectMap["lastSeen"] = dnp.LastSeen + } + if dnp.RegistrationTime != nil { + objectMap["registrationTime"] = dnp.RegistrationTime + } + if dnp.IP != nil { + objectMap["ip"] = dnp.IP + } + if dnp.AccountID != nil { + objectMap["accountId"] = dnp.AccountID + } + if dnp.DscNodeConfigurationAssociationProperty != nil { + objectMap["nodeConfiguration"] = dnp.DscNodeConfigurationAssociationProperty + } + if dnp.Status != nil { + objectMap["status"] = dnp.Status + } + if dnp.NodeID != nil { + objectMap["nodeId"] = dnp.NodeID + } + if dnp.Etag != nil { + objectMap["etag"] = dnp.Etag + } + if dnp.TotalCount != nil { + objectMap["totalCount"] = dnp.TotalCount + } + if dnp.ExtensionHandler != nil { + objectMap["extensionHandler"] = dnp.ExtensionHandler + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DscNodeProperties struct. +func (dnp *DscNodeProperties) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "lastSeen": + if v != nil { + var lastSeen date.Time + err = json.Unmarshal(*v, &lastSeen) + if err != nil { + return err + } + dnp.LastSeen = &lastSeen + } + case "registrationTime": + if v != nil { + var registrationTime date.Time + err = json.Unmarshal(*v, ®istrationTime) + if err != nil { + return err + } + dnp.RegistrationTime = ®istrationTime + } + case "ip": + if v != nil { + var IP string + err = json.Unmarshal(*v, &IP) + if err != nil { + return err + } + dnp.IP = &IP + } + case "accountId": + if v != nil { + var accountID string + err = json.Unmarshal(*v, &accountID) + if err != nil { + return err + } + dnp.AccountID = &accountID + } + case "nodeConfiguration": + if v != nil { + var dscNodeConfigurationAssociationProperty DscNodeConfigurationAssociationProperty + err = json.Unmarshal(*v, &dscNodeConfigurationAssociationProperty) + if err != nil { + return err + } + dnp.DscNodeConfigurationAssociationProperty = &dscNodeConfigurationAssociationProperty + } + case "status": + if v != nil { + var status string + err = json.Unmarshal(*v, &status) + if err != nil { + return err + } + dnp.Status = &status + } + case "nodeId": + if v != nil { + var nodeID string + err = json.Unmarshal(*v, &nodeID) + if err != nil { + return err + } + dnp.NodeID = &nodeID + } + case "etag": + if v != nil { + var etag string + err = json.Unmarshal(*v, &etag) + if err != nil { + return err + } + dnp.Etag = &etag + } + case "totalCount": + if v != nil { + var totalCount int32 + err = json.Unmarshal(*v, &totalCount) + if err != nil { + return err + } + dnp.TotalCount = &totalCount + } + case "extensionHandler": + if v != nil { + var extensionHandler []DscNodeExtensionHandlerAssociationProperty + err = json.Unmarshal(*v, &extensionHandler) + if err != nil { + return err + } + dnp.ExtensionHandler = &extensionHandler + } + } + } + + return nil +} + +// DscNodeReport definition of the dsc node report type. +type DscNodeReport struct { + autorest.Response `json:"-"` + // EndTime - Gets or sets the end time of the node report. + EndTime *date.Time `json:"endTime,omitempty"` + // LastModifiedTime - Gets or sets the lastModifiedTime of the node report. + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + // StartTime - Gets or sets the start time of the node report. + StartTime *date.Time `json:"startTime,omitempty"` + // Type - Gets or sets the type of the node report. + Type *string `json:"type,omitempty"` + // ReportID - Gets or sets the id of the node report. + ReportID *string `json:"reportId,omitempty"` + // Status - Gets or sets the status of the node report. + Status *string `json:"status,omitempty"` + // RefreshMode - Gets or sets the refreshMode of the node report. + RefreshMode *string `json:"refreshMode,omitempty"` + // RebootRequested - Gets or sets the rebootRequested of the node report. + RebootRequested *string `json:"rebootRequested,omitempty"` + // ReportFormatVersion - Gets or sets the reportFormatVersion of the node report. + ReportFormatVersion *string `json:"reportFormatVersion,omitempty"` + // ConfigurationVersion - Gets or sets the configurationVersion of the node report. + ConfigurationVersion *string `json:"configurationVersion,omitempty"` + // ID - Gets or sets the id. + ID *string `json:"id,omitempty"` + // Errors - Gets or sets the errors for the node report. + Errors *[]DscReportError `json:"errors,omitempty"` + // Resources - Gets or sets the resource for the node report. + Resources *[]DscReportResource `json:"resources,omitempty"` + // MetaConfiguration - Gets or sets the metaConfiguration of the node at the time of the report. + MetaConfiguration *DscMetaConfiguration `json:"metaConfiguration,omitempty"` + // HostName - Gets or sets the hostname of the node that sent the report. + HostName *string `json:"hostName,omitempty"` + // IPV4Addresses - Gets or sets the IPv4 address of the node that sent the report. + IPV4Addresses *[]string `json:"iPV4Addresses,omitempty"` + // IPV6Addresses - Gets or sets the IPv6 address of the node that sent the report. + IPV6Addresses *[]string `json:"iPV6Addresses,omitempty"` + // NumberOfResources - Gets or sets the number of resource in the node report. + NumberOfResources *int32 `json:"numberOfResources,omitempty"` + // RawErrors - Gets or sets the unparsed errors for the node report. + RawErrors *string `json:"rawErrors,omitempty"` +} + +// DscNodeReportListResult the response model for the list dsc nodes operation. +type DscNodeReportListResult struct { + autorest.Response `json:"-"` + // Value - Gets or sets a list of dsc node reports. + Value *[]DscNodeReport `json:"value,omitempty"` + // NextLink - Gets or sets the next link. + NextLink *string `json:"nextLink,omitempty"` +} + +// DscNodeReportListResultIterator provides access to a complete listing of DscNodeReport values. +type DscNodeReportListResultIterator struct { + i int + page DscNodeReportListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *DscNodeReportListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter DscNodeReportListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter DscNodeReportListResultIterator) Response() DscNodeReportListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter DscNodeReportListResultIterator) Value() DscNodeReport { + if !iter.page.NotDone() { + return DscNodeReport{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (dnrlr DscNodeReportListResult) IsEmpty() bool { + return dnrlr.Value == nil || len(*dnrlr.Value) == 0 +} + +// dscNodeReportListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (dnrlr DscNodeReportListResult) dscNodeReportListResultPreparer() (*http.Request, error) { + if dnrlr.NextLink == nil || len(to.String(dnrlr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(dnrlr.NextLink))) +} + +// DscNodeReportListResultPage contains a page of DscNodeReport values. +type DscNodeReportListResultPage struct { + fn func(DscNodeReportListResult) (DscNodeReportListResult, error) + dnrlr DscNodeReportListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *DscNodeReportListResultPage) Next() error { + next, err := page.fn(page.dnrlr) + if err != nil { + return err + } + page.dnrlr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page DscNodeReportListResultPage) NotDone() bool { + return !page.dnrlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page DscNodeReportListResultPage) Response() DscNodeReportListResult { + return page.dnrlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page DscNodeReportListResultPage) Values() []DscNodeReport { + if page.dnrlr.IsEmpty() { + return nil + } + return *page.dnrlr.Value +} + +// DscNodeUpdateParameters the parameters supplied to the update dsc node operation. +type DscNodeUpdateParameters struct { + // NodeID - Gets or sets the id of the dsc node. + NodeID *string `json:"nodeId,omitempty"` + Properties *DscNodeUpdateParametersProperties `json:"properties,omitempty"` +} + +// DscNodeUpdateParametersProperties ... +type DscNodeUpdateParametersProperties struct { + // DscNodeConfigurationAssociationProperty - Gets or sets the configuration of the node. + *DscNodeConfigurationAssociationProperty `json:"nodeConfiguration,omitempty"` +} + +// MarshalJSON is the custom marshaler for DscNodeUpdateParametersProperties. +func (dnup DscNodeUpdateParametersProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dnup.DscNodeConfigurationAssociationProperty != nil { + objectMap["nodeConfiguration"] = dnup.DscNodeConfigurationAssociationProperty + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DscNodeUpdateParametersProperties struct. +func (dnup *DscNodeUpdateParametersProperties) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "nodeConfiguration": + if v != nil { + var dscNodeConfigurationAssociationProperty DscNodeConfigurationAssociationProperty + err = json.Unmarshal(*v, &dscNodeConfigurationAssociationProperty) + if err != nil { + return err + } + dnup.DscNodeConfigurationAssociationProperty = &dscNodeConfigurationAssociationProperty + } + } + } + + return nil +} + +// DscReportError definition of the dsc node report error type. +type DscReportError struct { + // ErrorSource - Gets or sets the source of the error. + ErrorSource *string `json:"errorSource,omitempty"` + // ResourceID - Gets or sets the resource ID which generated the error. + ResourceID *string `json:"resourceId,omitempty"` + // ErrorCode - Gets or sets the error code. + ErrorCode *string `json:"errorCode,omitempty"` + // ErrorMessage - Gets or sets the error message. + ErrorMessage *string `json:"errorMessage,omitempty"` + // Locale - Gets or sets the locale of the error. + Locale *string `json:"locale,omitempty"` + // ErrorDetails - Gets or sets the error details. + ErrorDetails *string `json:"errorDetails,omitempty"` +} + +// DscReportResource definition of the DSC Report Resource. +type DscReportResource struct { + // ResourceID - Gets or sets the ID of the resource. + ResourceID *string `json:"resourceId,omitempty"` + // SourceInfo - Gets or sets the source info of the resource. + SourceInfo *string `json:"sourceInfo,omitempty"` + // DependsOn - Gets or sets the Resource Navigation values for resources the resource depends on. + DependsOn *[]DscReportResourceNavigation `json:"dependsOn,omitempty"` + // ModuleName - Gets or sets the module name of the resource. + ModuleName *string `json:"moduleName,omitempty"` + // ModuleVersion - Gets or sets the module version of the resource. + ModuleVersion *string `json:"moduleVersion,omitempty"` + // ResourceName - Gets or sets the name of the resource. + ResourceName *string `json:"resourceName,omitempty"` + // Error - Gets or sets the error of the resource. + Error *string `json:"error,omitempty"` + // Status - Gets or sets the status of the resource. + Status *string `json:"status,omitempty"` + // DurationInSeconds - Gets or sets the duration in seconds for the resource. + DurationInSeconds *float64 `json:"durationInSeconds,omitempty"` + // StartDate - Gets or sets the start date of the resource. + StartDate *date.Time `json:"startDate,omitempty"` +} + +// DscReportResourceNavigation navigation for DSC Report Resource. +type DscReportResourceNavigation struct { + // ResourceID - Gets or sets the ID of the resource to navigate to. + ResourceID *string `json:"resourceId,omitempty"` +} + +// ErrorResponse error response of an operation failure +type ErrorResponse struct { + // Code - Error code + Code *string `json:"code,omitempty"` + // Message - Error message indicating why the operation failed. + Message *string `json:"message,omitempty"` +} + +// FieldDefinition definition of the connection fields. +type FieldDefinition struct { + // IsEncrypted - Gets or sets the isEncrypted flag of the connection field definition. + IsEncrypted *bool `json:"isEncrypted,omitempty"` + // IsOptional - Gets or sets the isOptional flag of the connection field definition. + IsOptional *bool `json:"isOptional,omitempty"` + // Type - Gets or sets the type of the connection field definition. + Type *string `json:"type,omitempty"` +} + +// HybridRunbookWorker definition of hybrid runbook worker. +type HybridRunbookWorker struct { + // Name - Gets or sets the worker machine name. + Name *string `json:"name,omitempty"` + // IP - Gets or sets the assigned machine IP address. + IP *string `json:"ip,omitempty"` + // RegistrationTime - Gets or sets the registration time of the worker machine. + RegistrationTime *date.Time `json:"registrationTime,omitempty"` + // LastSeenDateTime - Last Heartbeat from the Worker + LastSeenDateTime *date.Time `json:"lastSeenDateTime,omitempty"` +} + +// HybridRunbookWorkerGroup definition of hybrid runbook worker group. +type HybridRunbookWorkerGroup struct { + autorest.Response `json:"-"` + // ID - Gets or sets the id of the resource. + ID *string `json:"id,omitempty"` + // Name - Gets or sets the name of the group. + Name *string `json:"name,omitempty"` + // HybridRunbookWorkers - Gets or sets the list of hybrid runbook workers. + HybridRunbookWorkers *[]HybridRunbookWorker `json:"hybridRunbookWorkers,omitempty"` + // Credential - Sets the credential of a worker group. + Credential *RunAsCredentialAssociationProperty `json:"credential,omitempty"` + // GroupType - Type of the HybridWorkerGroup. Possible values include: 'User', 'System' + GroupType GroupTypeEnum `json:"groupType,omitempty"` +} + +// HybridRunbookWorkerGroupsListResult the response model for the list hybrid runbook worker groups. +type HybridRunbookWorkerGroupsListResult struct { + autorest.Response `json:"-"` + // Value - Gets or sets a list of hybrid runbook worker groups. + Value *[]HybridRunbookWorkerGroup `json:"value,omitempty"` + // NextLink - Gets or sets the next link. + NextLink *string `json:"nextLink,omitempty"` +} + +// HybridRunbookWorkerGroupsListResultIterator provides access to a complete listing of HybridRunbookWorkerGroup +// values. +type HybridRunbookWorkerGroupsListResultIterator struct { + i int + page HybridRunbookWorkerGroupsListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *HybridRunbookWorkerGroupsListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter HybridRunbookWorkerGroupsListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter HybridRunbookWorkerGroupsListResultIterator) Response() HybridRunbookWorkerGroupsListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter HybridRunbookWorkerGroupsListResultIterator) Value() HybridRunbookWorkerGroup { + if !iter.page.NotDone() { + return HybridRunbookWorkerGroup{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (hrwglr HybridRunbookWorkerGroupsListResult) IsEmpty() bool { + return hrwglr.Value == nil || len(*hrwglr.Value) == 0 +} + +// hybridRunbookWorkerGroupsListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (hrwglr HybridRunbookWorkerGroupsListResult) hybridRunbookWorkerGroupsListResultPreparer() (*http.Request, error) { + if hrwglr.NextLink == nil || len(to.String(hrwglr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(hrwglr.NextLink))) +} + +// HybridRunbookWorkerGroupsListResultPage contains a page of HybridRunbookWorkerGroup values. +type HybridRunbookWorkerGroupsListResultPage struct { + fn func(HybridRunbookWorkerGroupsListResult) (HybridRunbookWorkerGroupsListResult, error) + hrwglr HybridRunbookWorkerGroupsListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *HybridRunbookWorkerGroupsListResultPage) Next() error { + next, err := page.fn(page.hrwglr) + if err != nil { + return err + } + page.hrwglr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page HybridRunbookWorkerGroupsListResultPage) NotDone() bool { + return !page.hrwglr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page HybridRunbookWorkerGroupsListResultPage) Response() HybridRunbookWorkerGroupsListResult { + return page.hrwglr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page HybridRunbookWorkerGroupsListResultPage) Values() []HybridRunbookWorkerGroup { + if page.hrwglr.IsEmpty() { + return nil + } + return *page.hrwglr.Value +} + +// HybridRunbookWorkerGroupUpdateParameters parameters supplied to the update operation. +type HybridRunbookWorkerGroupUpdateParameters struct { + // Credential - Sets the credential of a worker group. + Credential *RunAsCredentialAssociationProperty `json:"credential,omitempty"` +} + +// Job definition of the job. +type Job struct { + autorest.Response `json:"-"` + // JobProperties - The properties of the job. + *JobProperties `json:"properties,omitempty"` + // ID - Fully qualified resource Id for the resource + ID *string `json:"id,omitempty"` + // Name - The name of the resource + Name *string `json:"name,omitempty"` + // Type - The type of the resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Job. +func (j Job) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if j.JobProperties != nil { + objectMap["properties"] = j.JobProperties + } + if j.ID != nil { + objectMap["id"] = j.ID + } + if j.Name != nil { + objectMap["name"] = j.Name + } + if j.Type != nil { + objectMap["type"] = j.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Job struct. +func (j *Job) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var jobProperties JobProperties + err = json.Unmarshal(*v, &jobProperties) + if err != nil { + return err + } + j.JobProperties = &jobProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + j.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + j.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + j.Type = &typeVar + } + } + } + + return nil +} + +// JobCollectionItem job collection item properties. +type JobCollectionItem struct { + // JobCollectionItemProperties - Job properties. + *JobCollectionItemProperties `json:"properties,omitempty"` + // ID - Fully qualified resource Id for the resource + ID *string `json:"id,omitempty"` + // Name - The name of the resource + Name *string `json:"name,omitempty"` + // Type - The type of the resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for JobCollectionItem. +func (jci JobCollectionItem) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if jci.JobCollectionItemProperties != nil { + objectMap["properties"] = jci.JobCollectionItemProperties + } + if jci.ID != nil { + objectMap["id"] = jci.ID + } + if jci.Name != nil { + objectMap["name"] = jci.Name + } + if jci.Type != nil { + objectMap["type"] = jci.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for JobCollectionItem struct. +func (jci *JobCollectionItem) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var jobCollectionItemProperties JobCollectionItemProperties + err = json.Unmarshal(*v, &jobCollectionItemProperties) + if err != nil { + return err + } + jci.JobCollectionItemProperties = &jobCollectionItemProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + jci.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + jci.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + jci.Type = &typeVar + } + } + } + + return nil +} + +// JobCollectionItemProperties job collection item properties. +type JobCollectionItemProperties struct { + // Runbook - The runbook association. + Runbook *RunbookAssociationProperty `json:"runbook,omitempty"` + // JobID - The id of the job. + JobID *uuid.UUID `json:"jobId,omitempty"` + // CreationTime - The creation time of the job. + CreationTime *date.Time `json:"creationTime,omitempty"` + // Status - The status of the job. Possible values include: 'JobStatusNew', 'JobStatusActivating', 'JobStatusRunning', 'JobStatusCompleted', 'JobStatusFailed', 'JobStatusStopped', 'JobStatusBlocked', 'JobStatusSuspended', 'JobStatusDisconnected', 'JobStatusSuspending', 'JobStatusStopping', 'JobStatusResuming', 'JobStatusRemoving' + Status JobStatus `json:"status,omitempty"` + // StartTime - The start time of the job. + StartTime *date.Time `json:"startTime,omitempty"` + // EndTime - The end time of the job. + EndTime *date.Time `json:"endTime,omitempty"` + // LastModifiedTime - The last modified time of the job. + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + // ProvisioningState - The provisioning state of a resource. + ProvisioningState *string `json:"provisioningState,omitempty"` + // RunOn - Specifies the runOn group name where the job was executed. + RunOn *string `json:"runOn,omitempty"` +} + +// JobCreateParameters the parameters supplied to the create job operation. +type JobCreateParameters struct { + // JobCreateProperties - Gets or sets the list of job properties. + *JobCreateProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for JobCreateParameters. +func (jcp JobCreateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if jcp.JobCreateProperties != nil { + objectMap["properties"] = jcp.JobCreateProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for JobCreateParameters struct. +func (jcp *JobCreateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var jobCreateProperties JobCreateProperties + err = json.Unmarshal(*v, &jobCreateProperties) + if err != nil { + return err + } + jcp.JobCreateProperties = &jobCreateProperties + } + } + } + + return nil +} + +// JobCreateProperties ... +type JobCreateProperties struct { + // Runbook - Gets or sets the runbook. + Runbook *RunbookAssociationProperty `json:"runbook,omitempty"` + // Parameters - Gets or sets the parameters of the job. + Parameters map[string]*string `json:"parameters"` + // RunOn - Gets or sets the runOn which specifies the group name where the job is to be executed. + RunOn *string `json:"runOn,omitempty"` +} + +// MarshalJSON is the custom marshaler for JobCreateProperties. +func (jcp JobCreateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if jcp.Runbook != nil { + objectMap["runbook"] = jcp.Runbook + } + if jcp.Parameters != nil { + objectMap["parameters"] = jcp.Parameters + } + if jcp.RunOn != nil { + objectMap["runOn"] = jcp.RunOn + } + return json.Marshal(objectMap) +} + +// JobListResultV2 the response model for the list job operation. +type JobListResultV2 struct { + autorest.Response `json:"-"` + // Value - List of jobs. + Value *[]JobCollectionItem `json:"value,omitempty"` + // NextLink - The link to the next page. + NextLink *string `json:"nextLink,omitempty"` +} + +// JobListResultV2Iterator provides access to a complete listing of JobCollectionItem values. +type JobListResultV2Iterator struct { + i int + page JobListResultV2Page +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *JobListResultV2Iterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter JobListResultV2Iterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter JobListResultV2Iterator) Response() JobListResultV2 { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter JobListResultV2Iterator) Value() JobCollectionItem { + if !iter.page.NotDone() { + return JobCollectionItem{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (jlrv JobListResultV2) IsEmpty() bool { + return jlrv.Value == nil || len(*jlrv.Value) == 0 +} + +// jobListResultV2Preparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (jlrv JobListResultV2) jobListResultV2Preparer() (*http.Request, error) { + if jlrv.NextLink == nil || len(to.String(jlrv.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(jlrv.NextLink))) +} + +// JobListResultV2Page contains a page of JobCollectionItem values. +type JobListResultV2Page struct { + fn func(JobListResultV2) (JobListResultV2, error) + jlrv JobListResultV2 +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *JobListResultV2Page) Next() error { + next, err := page.fn(page.jlrv) + if err != nil { + return err + } + page.jlrv = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page JobListResultV2Page) NotDone() bool { + return !page.jlrv.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page JobListResultV2Page) Response() JobListResultV2 { + return page.jlrv +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page JobListResultV2Page) Values() []JobCollectionItem { + if page.jlrv.IsEmpty() { + return nil + } + return *page.jlrv.Value +} + +// JobNavigation software update configuration machine run job navigation properties. +type JobNavigation struct { + // ID - Id of the job associated with the software update configuration run + ID *string `json:"id,omitempty"` +} + +// JobProperties definition of job properties. +type JobProperties struct { + // Runbook - Gets or sets the runbook. + Runbook *RunbookAssociationProperty `json:"runbook,omitempty"` + // StartedBy - Gets or sets the job started by. + StartedBy *string `json:"startedBy,omitempty"` + // RunOn - Gets or sets the runOn which specifies the group name where the job is to be executed. + RunOn *string `json:"runOn,omitempty"` + // JobID - Gets or sets the id of the job. + JobID *uuid.UUID `json:"jobId,omitempty"` + // CreationTime - Gets or sets the creation time of the job. + CreationTime *date.Time `json:"creationTime,omitempty"` + // Status - Gets or sets the status of the job. Possible values include: 'JobStatusNew', 'JobStatusActivating', 'JobStatusRunning', 'JobStatusCompleted', 'JobStatusFailed', 'JobStatusStopped', 'JobStatusBlocked', 'JobStatusSuspended', 'JobStatusDisconnected', 'JobStatusSuspending', 'JobStatusStopping', 'JobStatusResuming', 'JobStatusRemoving' + Status JobStatus `json:"status,omitempty"` + // StatusDetails - Gets or sets the status details of the job. + StatusDetails *string `json:"statusDetails,omitempty"` + // StartTime - Gets or sets the start time of the job. + StartTime *date.Time `json:"startTime,omitempty"` + // EndTime - Gets or sets the end time of the job. + EndTime *date.Time `json:"endTime,omitempty"` + // Exception - Gets or sets the exception of the job. + Exception *string `json:"exception,omitempty"` + // LastModifiedTime - Gets or sets the last modified time of the job. + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + // LastStatusModifiedTime - Gets or sets the last status modified time of the job. + LastStatusModifiedTime *date.Time `json:"lastStatusModifiedTime,omitempty"` + // Parameters - Gets or sets the parameters of the job. + Parameters map[string]*string `json:"parameters"` + // ProvisioningState - The current provisioning state of the job. Possible values include: 'JobProvisioningStateFailed', 'JobProvisioningStateSucceeded', 'JobProvisioningStateSuspended', 'JobProvisioningStateProcessing' + ProvisioningState JobProvisioningState `json:"provisioningState,omitempty"` +} + +// MarshalJSON is the custom marshaler for JobProperties. +func (jp JobProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if jp.Runbook != nil { + objectMap["runbook"] = jp.Runbook + } + if jp.StartedBy != nil { + objectMap["startedBy"] = jp.StartedBy + } + if jp.RunOn != nil { + objectMap["runOn"] = jp.RunOn + } + if jp.JobID != nil { + objectMap["jobId"] = jp.JobID + } + if jp.CreationTime != nil { + objectMap["creationTime"] = jp.CreationTime + } + if jp.Status != "" { + objectMap["status"] = jp.Status + } + if jp.StatusDetails != nil { + objectMap["statusDetails"] = jp.StatusDetails + } + if jp.StartTime != nil { + objectMap["startTime"] = jp.StartTime + } + if jp.EndTime != nil { + objectMap["endTime"] = jp.EndTime + } + if jp.Exception != nil { + objectMap["exception"] = jp.Exception + } + if jp.LastModifiedTime != nil { + objectMap["lastModifiedTime"] = jp.LastModifiedTime + } + if jp.LastStatusModifiedTime != nil { + objectMap["lastStatusModifiedTime"] = jp.LastStatusModifiedTime + } + if jp.Parameters != nil { + objectMap["parameters"] = jp.Parameters + } + if jp.ProvisioningState != "" { + objectMap["provisioningState"] = jp.ProvisioningState + } + return json.Marshal(objectMap) +} + +// JobSchedule definition of the job schedule. +type JobSchedule struct { + autorest.Response `json:"-"` + // ID - Gets the id of the resource. + ID *string `json:"id,omitempty"` + // Name - Gets the name of the variable. + Name *string `json:"name,omitempty"` + // Type - Resource type + Type *string `json:"type,omitempty"` + // JobScheduleProperties - Gets or sets the properties of the job schedule. + *JobScheduleProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for JobSchedule. +func (js JobSchedule) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if js.ID != nil { + objectMap["id"] = js.ID + } + if js.Name != nil { + objectMap["name"] = js.Name + } + if js.Type != nil { + objectMap["type"] = js.Type + } + if js.JobScheduleProperties != nil { + objectMap["properties"] = js.JobScheduleProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for JobSchedule struct. +func (js *JobSchedule) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + js.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + js.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + js.Type = &typeVar + } + case "properties": + if v != nil { + var jobScheduleProperties JobScheduleProperties + err = json.Unmarshal(*v, &jobScheduleProperties) + if err != nil { + return err + } + js.JobScheduleProperties = &jobScheduleProperties + } + } + } + + return nil +} + +// JobScheduleCreateParameters the parameters supplied to the create job schedule operation. +type JobScheduleCreateParameters struct { + // JobScheduleCreateProperties - Gets or sets the list of job schedule properties. + *JobScheduleCreateProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for JobScheduleCreateParameters. +func (jscp JobScheduleCreateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if jscp.JobScheduleCreateProperties != nil { + objectMap["properties"] = jscp.JobScheduleCreateProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for JobScheduleCreateParameters struct. +func (jscp *JobScheduleCreateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var jobScheduleCreateProperties JobScheduleCreateProperties + err = json.Unmarshal(*v, &jobScheduleCreateProperties) + if err != nil { + return err + } + jscp.JobScheduleCreateProperties = &jobScheduleCreateProperties + } + } + } + + return nil +} + +// JobScheduleCreateProperties the parameters supplied to the create job schedule operation. +type JobScheduleCreateProperties struct { + // Schedule - Gets or sets the schedule. + Schedule *ScheduleAssociationProperty `json:"schedule,omitempty"` + // Runbook - Gets or sets the runbook. + Runbook *RunbookAssociationProperty `json:"runbook,omitempty"` + // RunOn - Gets or sets the hybrid worker group that the scheduled job should run on. + RunOn *string `json:"runOn,omitempty"` + // Parameters - Gets or sets a list of job properties. + Parameters map[string]*string `json:"parameters"` +} + +// MarshalJSON is the custom marshaler for JobScheduleCreateProperties. +func (jscp JobScheduleCreateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if jscp.Schedule != nil { + objectMap["schedule"] = jscp.Schedule + } + if jscp.Runbook != nil { + objectMap["runbook"] = jscp.Runbook + } + if jscp.RunOn != nil { + objectMap["runOn"] = jscp.RunOn + } + if jscp.Parameters != nil { + objectMap["parameters"] = jscp.Parameters + } + return json.Marshal(objectMap) +} + +// JobScheduleListResult the response model for the list job schedule operation. +type JobScheduleListResult struct { + autorest.Response `json:"-"` + // Value - Gets or sets a list of job schedules. + Value *[]JobSchedule `json:"value,omitempty"` + // NextLink - Gets or sets the next link. + NextLink *string `json:"nextLink,omitempty"` +} + +// JobScheduleListResultIterator provides access to a complete listing of JobSchedule values. +type JobScheduleListResultIterator struct { + i int + page JobScheduleListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *JobScheduleListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter JobScheduleListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter JobScheduleListResultIterator) Response() JobScheduleListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter JobScheduleListResultIterator) Value() JobSchedule { + if !iter.page.NotDone() { + return JobSchedule{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (jslr JobScheduleListResult) IsEmpty() bool { + return jslr.Value == nil || len(*jslr.Value) == 0 +} + +// jobScheduleListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (jslr JobScheduleListResult) jobScheduleListResultPreparer() (*http.Request, error) { + if jslr.NextLink == nil || len(to.String(jslr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(jslr.NextLink))) +} + +// JobScheduleListResultPage contains a page of JobSchedule values. +type JobScheduleListResultPage struct { + fn func(JobScheduleListResult) (JobScheduleListResult, error) + jslr JobScheduleListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *JobScheduleListResultPage) Next() error { + next, err := page.fn(page.jslr) + if err != nil { + return err + } + page.jslr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page JobScheduleListResultPage) NotDone() bool { + return !page.jslr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page JobScheduleListResultPage) Response() JobScheduleListResult { + return page.jslr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page JobScheduleListResultPage) Values() []JobSchedule { + if page.jslr.IsEmpty() { + return nil + } + return *page.jslr.Value +} + +// JobScheduleProperties definition of job schedule parameters. +type JobScheduleProperties struct { + // JobScheduleID - Gets or sets the id of job schedule. + JobScheduleID *string `json:"jobScheduleId,omitempty"` + // Schedule - Gets or sets the schedule. + Schedule *ScheduleAssociationProperty `json:"schedule,omitempty"` + // Runbook - Gets or sets the runbook. + Runbook *RunbookAssociationProperty `json:"runbook,omitempty"` + // RunOn - Gets or sets the hybrid worker group that the scheduled job should run on. + RunOn *string `json:"runOn,omitempty"` + // Parameters - Gets or sets the parameters of the job schedule. + Parameters map[string]*string `json:"parameters"` +} + +// MarshalJSON is the custom marshaler for JobScheduleProperties. +func (jsp JobScheduleProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if jsp.JobScheduleID != nil { + objectMap["jobScheduleId"] = jsp.JobScheduleID + } + if jsp.Schedule != nil { + objectMap["schedule"] = jsp.Schedule + } + if jsp.Runbook != nil { + objectMap["runbook"] = jsp.Runbook + } + if jsp.RunOn != nil { + objectMap["runOn"] = jsp.RunOn + } + if jsp.Parameters != nil { + objectMap["parameters"] = jsp.Parameters + } + return json.Marshal(objectMap) +} + +// JobStream definition of the job stream. +type JobStream struct { + autorest.Response `json:"-"` + // ID - Gets or sets the id of the resource. + ID *string `json:"id,omitempty"` + // JobStreamProperties - Gets or sets the id of the job stream. + *JobStreamProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for JobStream. +func (js JobStream) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if js.ID != nil { + objectMap["id"] = js.ID + } + if js.JobStreamProperties != nil { + objectMap["properties"] = js.JobStreamProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for JobStream struct. +func (js *JobStream) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + js.ID = &ID + } + case "properties": + if v != nil { + var jobStreamProperties JobStreamProperties + err = json.Unmarshal(*v, &jobStreamProperties) + if err != nil { + return err + } + js.JobStreamProperties = &jobStreamProperties + } + } + } + + return nil +} + +// JobStreamListResult the response model for the list job stream operation. +type JobStreamListResult struct { + autorest.Response `json:"-"` + // Value - A list of job streams. + Value *[]JobStream `json:"value,omitempty"` + // NextLink - Gets or sets the next link. + NextLink *string `json:"nextLink,omitempty"` +} + +// JobStreamListResultIterator provides access to a complete listing of JobStream values. +type JobStreamListResultIterator struct { + i int + page JobStreamListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *JobStreamListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter JobStreamListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter JobStreamListResultIterator) Response() JobStreamListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter JobStreamListResultIterator) Value() JobStream { + if !iter.page.NotDone() { + return JobStream{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (jslr JobStreamListResult) IsEmpty() bool { + return jslr.Value == nil || len(*jslr.Value) == 0 +} + +// jobStreamListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (jslr JobStreamListResult) jobStreamListResultPreparer() (*http.Request, error) { + if jslr.NextLink == nil || len(to.String(jslr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(jslr.NextLink))) +} + +// JobStreamListResultPage contains a page of JobStream values. +type JobStreamListResultPage struct { + fn func(JobStreamListResult) (JobStreamListResult, error) + jslr JobStreamListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *JobStreamListResultPage) Next() error { + next, err := page.fn(page.jslr) + if err != nil { + return err + } + page.jslr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page JobStreamListResultPage) NotDone() bool { + return !page.jslr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page JobStreamListResultPage) Response() JobStreamListResult { + return page.jslr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page JobStreamListResultPage) Values() []JobStream { + if page.jslr.IsEmpty() { + return nil + } + return *page.jslr.Value +} + +// JobStreamProperties definition of the job stream. +type JobStreamProperties struct { + // JobStreamID - Gets or sets the id of the job stream. + JobStreamID *string `json:"jobStreamId,omitempty"` + // Time - Gets or sets the creation time of the job. + Time *date.Time `json:"time,omitempty"` + // StreamType - Gets or sets the stream type. Possible values include: 'Progress', 'Output', 'Warning', 'Error', 'Debug', 'Verbose', 'Any' + StreamType JobStreamType `json:"streamType,omitempty"` + // StreamText - Gets or sets the stream text. + StreamText *string `json:"streamText,omitempty"` + // Summary - Gets or sets the summary. + Summary *string `json:"summary,omitempty"` + // Value - Gets or sets the values of the job stream. + Value map[string]interface{} `json:"value"` +} + +// MarshalJSON is the custom marshaler for JobStreamProperties. +func (jsp JobStreamProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if jsp.JobStreamID != nil { + objectMap["jobStreamId"] = jsp.JobStreamID + } + if jsp.Time != nil { + objectMap["time"] = jsp.Time + } + if jsp.StreamType != "" { + objectMap["streamType"] = jsp.StreamType + } + if jsp.StreamText != nil { + objectMap["streamText"] = jsp.StreamText + } + if jsp.Summary != nil { + objectMap["summary"] = jsp.Summary + } + if jsp.Value != nil { + objectMap["value"] = jsp.Value + } + 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: 'Read', '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:"-"` + // Keys - Lists the automation keys. + Keys *[]Key `json:"keys,omitempty"` +} + +// LinkedWorkspace definition of the linked workspace. +type LinkedWorkspace struct { + autorest.Response `json:"-"` + // ID - Gets the id of the linked workspace. + ID *string `json:"id,omitempty"` +} + +// LinuxProperties linux specific update configuration. +type LinuxProperties struct { + // IncludedPackageClassifications - Update classifications included in the software update configuration. Possible values include: 'Unclassified', 'Critical', 'Security', 'Other' + IncludedPackageClassifications LinuxUpdateClasses `json:"includedPackageClassifications,omitempty"` + // ExcludedPackageNameMasks - packages excluded from the software update configuration. + ExcludedPackageNameMasks *[]string `json:"excludedPackageNameMasks,omitempty"` + // IncludedPackageNameMasks - packages included from the software update configuration. + IncludedPackageNameMasks *[]string `json:"includedPackageNameMasks,omitempty"` + // RebootSetting - Reboot setting for the software update configuration. + RebootSetting *string `json:"rebootSetting,omitempty"` +} + +// Module definition of the module type. +type Module struct { + autorest.Response `json:"-"` + // ModuleProperties - Gets or sets the module properties. + *ModuleProperties `json:"properties,omitempty"` + // Etag - Gets or sets the etag of the resource. + Etag *string `json:"etag,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The Azure Region where the resource lives + Location *string `json:"location,omitempty"` + // ID - Fully qualified resource Id for the resource + ID *string `json:"id,omitempty"` + // Name - The name of the resource + Name *string `json:"name,omitempty"` + // Type - The type of the resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Module. +func (mVar Module) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mVar.ModuleProperties != nil { + objectMap["properties"] = mVar.ModuleProperties + } + if mVar.Etag != nil { + objectMap["etag"] = mVar.Etag + } + if mVar.Tags != nil { + objectMap["tags"] = mVar.Tags + } + if mVar.Location != nil { + objectMap["location"] = mVar.Location + } + if mVar.ID != nil { + objectMap["id"] = mVar.ID + } + if mVar.Name != nil { + objectMap["name"] = mVar.Name + } + if mVar.Type != nil { + objectMap["type"] = mVar.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Module struct. +func (mVar *Module) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var moduleProperties ModuleProperties + err = json.Unmarshal(*v, &moduleProperties) + if err != nil { + return err + } + mVar.ModuleProperties = &moduleProperties + } + case "etag": + if v != nil { + var etag string + err = json.Unmarshal(*v, &etag) + if err != nil { + return err + } + mVar.Etag = &etag + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + mVar.Tags = tags + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + mVar.Location = &location + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + mVar.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mVar.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + mVar.Type = &typeVar + } + } + } + + return nil +} + +// ModuleCreateOrUpdateParameters the parameters supplied to the create or update module operation. +type ModuleCreateOrUpdateParameters struct { + // ModuleCreateOrUpdateProperties - Gets or sets the module create properties. + *ModuleCreateOrUpdateProperties `json:"properties,omitempty"` + // Name - Gets or sets name of the resource. + Name *string `json:"name,omitempty"` + // Location - Gets or sets the location of the resource. + Location *string `json:"location,omitempty"` + // Tags - Gets or sets the tags attached to the resource. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for ModuleCreateOrUpdateParameters. +func (mcoup ModuleCreateOrUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mcoup.ModuleCreateOrUpdateProperties != nil { + objectMap["properties"] = mcoup.ModuleCreateOrUpdateProperties + } + if mcoup.Name != nil { + objectMap["name"] = mcoup.Name + } + if mcoup.Location != nil { + objectMap["location"] = mcoup.Location + } + if mcoup.Tags != nil { + objectMap["tags"] = mcoup.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ModuleCreateOrUpdateParameters struct. +func (mcoup *ModuleCreateOrUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var moduleCreateOrUpdateProperties ModuleCreateOrUpdateProperties + err = json.Unmarshal(*v, &moduleCreateOrUpdateProperties) + if err != nil { + return err + } + mcoup.ModuleCreateOrUpdateProperties = &moduleCreateOrUpdateProperties + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mcoup.Name = &name + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + mcoup.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + mcoup.Tags = tags + } + } + } + + return nil +} + +// ModuleCreateOrUpdateProperties the parameters supplied to the create or update module properties. +type ModuleCreateOrUpdateProperties struct { + // ContentLink - Gets or sets the module content link. + ContentLink *ContentLink `json:"contentLink,omitempty"` +} + +// ModuleErrorInfo definition of the module error info type. +type ModuleErrorInfo struct { + // Code - Gets or sets the error code. + Code *string `json:"code,omitempty"` + // Message - Gets or sets the error message. + Message *string `json:"message,omitempty"` +} + +// ModuleListResult the response model for the list module operation. +type ModuleListResult struct { + autorest.Response `json:"-"` + // Value - Gets or sets a list of modules. + Value *[]Module `json:"value,omitempty"` + // NextLink - Gets or sets the next link. + NextLink *string `json:"nextLink,omitempty"` +} + +// ModuleListResultIterator provides access to a complete listing of Module values. +type ModuleListResultIterator struct { + i int + page ModuleListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ModuleListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ModuleListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ModuleListResultIterator) Response() ModuleListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ModuleListResultIterator) Value() Module { + if !iter.page.NotDone() { + return Module{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (mlr ModuleListResult) IsEmpty() bool { + return mlr.Value == nil || len(*mlr.Value) == 0 +} + +// moduleListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (mlr ModuleListResult) moduleListResultPreparer() (*http.Request, error) { + if mlr.NextLink == nil || len(to.String(mlr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(mlr.NextLink))) +} + +// ModuleListResultPage contains a page of Module values. +type ModuleListResultPage struct { + fn func(ModuleListResult) (ModuleListResult, error) + mlr ModuleListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ModuleListResultPage) Next() error { + next, err := page.fn(page.mlr) + if err != nil { + return err + } + page.mlr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ModuleListResultPage) NotDone() bool { + return !page.mlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ModuleListResultPage) Response() ModuleListResult { + return page.mlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ModuleListResultPage) Values() []Module { + if page.mlr.IsEmpty() { + return nil + } + return *page.mlr.Value +} + +// ModuleProperties definition of the module property type. +type ModuleProperties struct { + // IsGlobal - Gets or sets the isGlobal flag of the module. + IsGlobal *bool `json:"isGlobal,omitempty"` + // Version - Gets or sets the version of the module. + Version *string `json:"version,omitempty"` + // SizeInBytes - Gets or sets the size in bytes of the module. + SizeInBytes *int64 `json:"sizeInBytes,omitempty"` + // ActivityCount - Gets or sets the activity count of the module. + ActivityCount *int32 `json:"activityCount,omitempty"` + // ProvisioningState - Gets or sets the provisioning state of the module. Possible values include: 'ModuleProvisioningStateCreated', 'ModuleProvisioningStateCreating', 'ModuleProvisioningStateStartingImportModuleRunbook', 'ModuleProvisioningStateRunningImportModuleRunbook', 'ModuleProvisioningStateContentRetrieved', 'ModuleProvisioningStateContentDownloaded', 'ModuleProvisioningStateContentValidated', 'ModuleProvisioningStateConnectionTypeImported', 'ModuleProvisioningStateContentStored', 'ModuleProvisioningStateModuleDataStored', 'ModuleProvisioningStateActivitiesStored', 'ModuleProvisioningStateModuleImportRunbookComplete', 'ModuleProvisioningStateSucceeded', 'ModuleProvisioningStateFailed', 'ModuleProvisioningStateCancelled', 'ModuleProvisioningStateUpdating' + ProvisioningState ModuleProvisioningState `json:"provisioningState,omitempty"` + // ContentLink - Gets or sets the contentLink of the module. + ContentLink *ContentLink `json:"contentLink,omitempty"` + // Error - Gets or sets the error info of the module. + Error *ModuleErrorInfo `json:"error,omitempty"` + // CreationTime - Gets or sets the creation time. + CreationTime *date.Time `json:"creationTime,omitempty"` + // LastModifiedTime - Gets or sets the last modified time. + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + // Description - Gets or sets the description. + Description *string `json:"description,omitempty"` + // IsComposite - Gets or sets type of module, if its composite or not. + IsComposite *bool `json:"isComposite,omitempty"` +} + +// ModuleUpdateParameters the parameters supplied to the update module operation. +type ModuleUpdateParameters struct { + // ModuleUpdateProperties - Gets or sets the module update properties. + *ModuleUpdateProperties `json:"properties,omitempty"` + // Name - Gets or sets name of the resource. + Name *string `json:"name,omitempty"` + // Location - Gets or sets the location of the resource. + Location *string `json:"location,omitempty"` + // Tags - Gets or sets the tags attached to the resource. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for ModuleUpdateParameters. +func (mup ModuleUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mup.ModuleUpdateProperties != nil { + objectMap["properties"] = mup.ModuleUpdateProperties + } + if mup.Name != nil { + objectMap["name"] = mup.Name + } + if mup.Location != nil { + objectMap["location"] = mup.Location + } + if mup.Tags != nil { + objectMap["tags"] = mup.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ModuleUpdateParameters struct. +func (mup *ModuleUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var moduleUpdateProperties ModuleUpdateProperties + err = json.Unmarshal(*v, &moduleUpdateProperties) + if err != nil { + return err + } + mup.ModuleUpdateProperties = &moduleUpdateProperties + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mup.Name = &name + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + mup.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + mup.Tags = tags + } + } + } + + return nil +} + +// ModuleUpdateProperties the parameters supplied to the update properties. +type ModuleUpdateProperties struct { + // ContentLink - Gets or sets the module content link. + ContentLink *ContentLink `json:"contentLink,omitempty"` +} + +// NodeCount number of nodes based on the Filter +type NodeCount struct { + // Name - Gets the name of a count type + Name *string `json:"name,omitempty"` + Properties *NodeCountProperties `json:"properties,omitempty"` +} + +// NodeCountProperties ... +type NodeCountProperties struct { + // Count - Gets the count for the name + Count *int32 `json:"count,omitempty"` +} + +// NodeCounts gets the count of nodes by count type +type NodeCounts struct { + autorest.Response `json:"-"` + // Value - Gets an array of counts + Value *[]NodeCount `json:"value,omitempty"` + // TotalCount - Gets the total number of records matching countType criteria. + TotalCount *int32 `json:"totalCount,omitempty"` +} + +// Operation automation REST API operation +type Operation struct { + // Name - Operation name: {provider}/{resource}/{operation} + Name *string `json:"name,omitempty"` + // Display - Provider, Resource and Operation values + Display *OperationDisplay `json:"display,omitempty"` +} + +// OperationDisplay provider, Resource and Operation values +type OperationDisplay struct { + // Provider - Service provider: Microsoft.Automation + Provider *string `json:"provider,omitempty"` + // Resource - Resource on which the operation is performed: Runbooks, Jobs etc. + Resource *string `json:"resource,omitempty"` + // Operation - Operation type: Read, write, delete, etc. + Operation *string `json:"operation,omitempty"` +} + +// OperationListResult the response model for the list of Automation operations +type OperationListResult struct { + autorest.Response `json:"-"` + // Value - List of Automation operations supported by the Automation resource provider. + Value *[]Operation `json:"value,omitempty"` +} + +// ProxyResource ARM proxy resource. +type ProxyResource struct { + // ID - Fully qualified resource Id for the resource + ID *string `json:"id,omitempty"` + // Name - The name of the resource + Name *string `json:"name,omitempty"` + // Type - The type of the resource. + Type *string `json:"type,omitempty"` +} + +// ReadCloser ... +type ReadCloser struct { + autorest.Response `json:"-"` + Value *io.ReadCloser `json:"value,omitempty"` +} + +// Resource the core properties of ARM resources +type Resource struct { + // ID - Fully qualified resource Id for the resource + ID *string `json:"id,omitempty"` + // Name - The name of the resource + Name *string `json:"name,omitempty"` + // Type - The type of the resource. + Type *string `json:"type,omitempty"` +} + +// RunAsCredentialAssociationProperty definition of runas credential to use for hybrid worker. +type RunAsCredentialAssociationProperty struct { + // Name - Gets or sets the name of the credential. + Name *string `json:"name,omitempty"` +} + +// Runbook definition of the runbook type. +type Runbook struct { + autorest.Response `json:"-"` + // RunbookProperties - Gets or sets the runbook properties. + *RunbookProperties `json:"properties,omitempty"` + // Etag - Gets or sets the etag of the resource. + Etag *string `json:"etag,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The Azure Region where the resource lives + Location *string `json:"location,omitempty"` + // ID - Fully qualified resource Id for the resource + ID *string `json:"id,omitempty"` + // Name - The name of the resource + Name *string `json:"name,omitempty"` + // Type - The type of the resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Runbook. +func (r Runbook) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if r.RunbookProperties != nil { + objectMap["properties"] = r.RunbookProperties + } + if r.Etag != nil { + objectMap["etag"] = r.Etag + } + if r.Tags != nil { + objectMap["tags"] = r.Tags + } + if r.Location != nil { + objectMap["location"] = r.Location + } + if r.ID != nil { + objectMap["id"] = r.ID + } + if r.Name != nil { + objectMap["name"] = r.Name + } + if r.Type != nil { + objectMap["type"] = r.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Runbook struct. +func (r *Runbook) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var runbookProperties RunbookProperties + err = json.Unmarshal(*v, &runbookProperties) + if err != nil { + return err + } + r.RunbookProperties = &runbookProperties + } + case "etag": + if v != nil { + var etag string + err = json.Unmarshal(*v, &etag) + if err != nil { + return err + } + r.Etag = &etag + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + r.Tags = tags + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + r.Location = &location + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + r.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + r.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + r.Type = &typeVar + } + } + } + + return nil +} + +// RunbookAssociationProperty the runbook property associated with the entity. +type RunbookAssociationProperty struct { + // Name - Gets or sets the name of the runbook. + Name *string `json:"name,omitempty"` +} + +// RunbookCreateOrUpdateDraftParameters the parameters supplied to the create or update runbook operation. +type RunbookCreateOrUpdateDraftParameters struct { + // RunbookContent - Content of the Runbook. + RunbookContent *string `json:"runbookContent,omitempty"` +} + +// RunbookCreateOrUpdateDraftProperties the parameters supplied to the create or update dratft runbook properties. +type RunbookCreateOrUpdateDraftProperties struct { + // LogVerbose - Gets or sets verbose log option. + LogVerbose *bool `json:"logVerbose,omitempty"` + // LogProgress - Gets or sets progress log option. + LogProgress *bool `json:"logProgress,omitempty"` + // RunbookType - Gets or sets the type of the runbook. Possible values include: 'Script', 'Graph', 'PowerShellWorkflow', 'PowerShell', 'GraphPowerShellWorkflow', 'GraphPowerShell' + RunbookType RunbookTypeEnum `json:"runbookType,omitempty"` + // Draft - Gets or sets the draft runbook properties. + Draft *RunbookDraft `json:"draft,omitempty"` + // Description - Gets or sets the description of the runbook. + Description *string `json:"description,omitempty"` + // LogActivityTrace - Gets or sets the activity-level tracing options of the runbook. + LogActivityTrace *int32 `json:"logActivityTrace,omitempty"` +} + +// RunbookCreateOrUpdateParameters the parameters supplied to the create or update runbook operation. +type RunbookCreateOrUpdateParameters struct { + // RunbookCreateOrUpdateProperties - Gets or sets runbook create or update properties. + *RunbookCreateOrUpdateProperties `json:"properties,omitempty"` + // Name - Gets or sets the name of the resource. + Name *string `json:"name,omitempty"` + // Location - Gets or sets the location of the resource. + Location *string `json:"location,omitempty"` + // Tags - Gets or sets the tags attached to the resource. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for RunbookCreateOrUpdateParameters. +func (rcoup RunbookCreateOrUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rcoup.RunbookCreateOrUpdateProperties != nil { + objectMap["properties"] = rcoup.RunbookCreateOrUpdateProperties + } + if rcoup.Name != nil { + objectMap["name"] = rcoup.Name + } + if rcoup.Location != nil { + objectMap["location"] = rcoup.Location + } + if rcoup.Tags != nil { + objectMap["tags"] = rcoup.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RunbookCreateOrUpdateParameters struct. +func (rcoup *RunbookCreateOrUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var runbookCreateOrUpdateProperties RunbookCreateOrUpdateProperties + err = json.Unmarshal(*v, &runbookCreateOrUpdateProperties) + if err != nil { + return err + } + rcoup.RunbookCreateOrUpdateProperties = &runbookCreateOrUpdateProperties + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rcoup.Name = &name + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + rcoup.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + rcoup.Tags = tags + } + } + } + + return nil +} + +// RunbookCreateOrUpdateProperties the parameters supplied to the create or update runbook properties. +type RunbookCreateOrUpdateProperties struct { + // LogVerbose - Gets or sets verbose log option. + LogVerbose *bool `json:"logVerbose,omitempty"` + // LogProgress - Gets or sets progress log option. + LogProgress *bool `json:"logProgress,omitempty"` + // RunbookType - Gets or sets the type of the runbook. Possible values include: 'Script', 'Graph', 'PowerShellWorkflow', 'PowerShell', 'GraphPowerShellWorkflow', 'GraphPowerShell' + RunbookType RunbookTypeEnum `json:"runbookType,omitempty"` + // Draft - Gets or sets the draft runbook properties. + Draft *RunbookDraft `json:"draft,omitempty"` + // PublishContentLink - Gets or sets the published runbook content link. + PublishContentLink *ContentLink `json:"publishContentLink,omitempty"` + // Description - Gets or sets the description of the runbook. + Description *string `json:"description,omitempty"` + // LogActivityTrace - Gets or sets the activity-level tracing options of the runbook. + LogActivityTrace *int32 `json:"logActivityTrace,omitempty"` +} + +// RunbookDraft ... +type RunbookDraft struct { + autorest.Response `json:"-"` + // InEdit - Gets or sets whether runbook is in edit mode. + InEdit *bool `json:"inEdit,omitempty"` + // DraftContentLink - Gets or sets the draft runbook content link. + DraftContentLink *ContentLink `json:"draftContentLink,omitempty"` + // CreationTime - Gets or sets the creation time of the runbook draft. + CreationTime *date.Time `json:"creationTime,omitempty"` + // LastModifiedTime - Gets or sets the last modified time of the runbook draft. + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + // Parameters - Gets or sets the runbook draft parameters. + Parameters map[string]*RunbookParameter `json:"parameters"` + // OutputTypes - Gets or sets the runbook output types. + OutputTypes *[]string `json:"outputTypes,omitempty"` +} + +// MarshalJSON is the custom marshaler for RunbookDraft. +func (rd RunbookDraft) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rd.InEdit != nil { + objectMap["inEdit"] = rd.InEdit + } + if rd.DraftContentLink != nil { + objectMap["draftContentLink"] = rd.DraftContentLink + } + if rd.CreationTime != nil { + objectMap["creationTime"] = rd.CreationTime + } + if rd.LastModifiedTime != nil { + objectMap["lastModifiedTime"] = rd.LastModifiedTime + } + if rd.Parameters != nil { + objectMap["parameters"] = rd.Parameters + } + if rd.OutputTypes != nil { + objectMap["outputTypes"] = rd.OutputTypes + } + return json.Marshal(objectMap) +} + +// RunbookDraftPublishFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type RunbookDraftPublishFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *RunbookDraftPublishFuture) Result(client RunbookDraftClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookDraftPublishFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("automation.RunbookDraftPublishFuture") + return + } + ar.Response = future.Response() + return +} + +// RunbookDraftReplaceContentFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type RunbookDraftReplaceContentFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *RunbookDraftReplaceContentFuture) Result(client RunbookDraftClient) (rc ReadCloser, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookDraftReplaceContentFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("automation.RunbookDraftReplaceContentFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if rc.Response.Response, err = future.GetResult(sender); err == nil && rc.Response.Response.StatusCode != http.StatusNoContent { + rc, err = client.ReplaceContentResponder(rc.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookDraftReplaceContentFuture", "Result", rc.Response.Response, "Failure responding to request") + } + } + return +} + +// RunbookDraftUndoEditResult the response model for the undoedit runbook operation. +type RunbookDraftUndoEditResult struct { + autorest.Response `json:"-"` + // StatusCode - Possible values include: 'Continue', 'SwitchingProtocols', 'OK', 'Created', 'Accepted', 'NonAuthoritativeInformation', 'NoContent', 'ResetContent', 'PartialContent', 'MultipleChoices', 'Ambiguous', 'MovedPermanently', 'Moved', 'Found', 'Redirect', 'SeeOther', 'RedirectMethod', 'NotModified', 'UseProxy', 'Unused', 'TemporaryRedirect', 'RedirectKeepVerb', 'BadRequest', 'Unauthorized', 'PaymentRequired', 'Forbidden', 'NotFound', 'MethodNotAllowed', 'NotAcceptable', 'ProxyAuthenticationRequired', 'RequestTimeout', 'Conflict', 'Gone', 'LengthRequired', 'PreconditionFailed', 'RequestEntityTooLarge', 'RequestURITooLong', 'UnsupportedMediaType', 'RequestedRangeNotSatisfiable', 'ExpectationFailed', 'UpgradeRequired', 'InternalServerError', 'NotImplemented', 'BadGateway', 'ServiceUnavailable', 'GatewayTimeout', 'HTTPVersionNotSupported' + StatusCode HTTPStatusCode `json:"statusCode,omitempty"` + RequestID *string `json:"requestId,omitempty"` +} + +// RunbookListResult the response model for the list runbook operation. +type RunbookListResult struct { + autorest.Response `json:"-"` + // Value - Gets or sets a list of runbooks. + Value *[]Runbook `json:"value,omitempty"` + // NextLink - Gets or sets the next link. + NextLink *string `json:"nextLink,omitempty"` +} + +// RunbookListResultIterator provides access to a complete listing of Runbook values. +type RunbookListResultIterator struct { + i int + page RunbookListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *RunbookListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter RunbookListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter RunbookListResultIterator) Response() RunbookListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter RunbookListResultIterator) Value() Runbook { + if !iter.page.NotDone() { + return Runbook{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (rlr RunbookListResult) IsEmpty() bool { + return rlr.Value == nil || len(*rlr.Value) == 0 +} + +// runbookListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (rlr RunbookListResult) runbookListResultPreparer() (*http.Request, error) { + if rlr.NextLink == nil || len(to.String(rlr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(rlr.NextLink))) +} + +// RunbookListResultPage contains a page of Runbook values. +type RunbookListResultPage struct { + fn func(RunbookListResult) (RunbookListResult, error) + rlr RunbookListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *RunbookListResultPage) Next() error { + next, err := page.fn(page.rlr) + if err != nil { + return err + } + page.rlr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page RunbookListResultPage) NotDone() bool { + return !page.rlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page RunbookListResultPage) Response() RunbookListResult { + return page.rlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page RunbookListResultPage) Values() []Runbook { + if page.rlr.IsEmpty() { + return nil + } + return *page.rlr.Value +} + +// RunbookParameter definition of the runbook parameter type. +type RunbookParameter struct { + // Type - Gets or sets the type of the parameter. + Type *string `json:"type,omitempty"` + // IsMandatory - Gets or sets a Boolean value to indicate whether the parameter is madatory or not. + IsMandatory *bool `json:"isMandatory,omitempty"` + // Position - Get or sets the position of the parameter. + Position *int32 `json:"position,omitempty"` + // DefaultValue - Gets or sets the default value of parameter. + DefaultValue *string `json:"defaultValue,omitempty"` +} + +// RunbookProperties definition of the runbook property type. +type RunbookProperties struct { + // RunbookType - Gets or sets the type of the runbook. Possible values include: 'Script', 'Graph', 'PowerShellWorkflow', 'PowerShell', 'GraphPowerShellWorkflow', 'GraphPowerShell' + RunbookType RunbookTypeEnum `json:"runbookType,omitempty"` + // PublishContentLink - Gets or sets the published runbook content link. + PublishContentLink *ContentLink `json:"publishContentLink,omitempty"` + // State - Gets or sets the state of the runbook. Possible values include: 'RunbookStateNew', 'RunbookStateEdit', 'RunbookStatePublished' + State RunbookState `json:"state,omitempty"` + // LogVerbose - Gets or sets verbose log option. + LogVerbose *bool `json:"logVerbose,omitempty"` + // LogProgress - Gets or sets progress log option. + LogProgress *bool `json:"logProgress,omitempty"` + // LogActivityTrace - Gets or sets the option to log activity trace of the runbook. + LogActivityTrace *int32 `json:"logActivityTrace,omitempty"` + // JobCount - Gets or sets the job count of the runbook. + JobCount *int32 `json:"jobCount,omitempty"` + // Parameters - Gets or sets the runbook parameters. + Parameters map[string]*RunbookParameter `json:"parameters"` + // OutputTypes - Gets or sets the runbook output types. + OutputTypes *[]string `json:"outputTypes,omitempty"` + // Draft - Gets or sets the draft runbook properties. + Draft *RunbookDraft `json:"draft,omitempty"` + // ProvisioningState - Gets or sets the provisioning state of the runbook. Possible values include: 'RunbookProvisioningStateSucceeded' + ProvisioningState RunbookProvisioningState `json:"provisioningState,omitempty"` + // LastModifiedBy - Gets or sets the last modified by. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + // CreationTime - Gets or sets the creation time. + CreationTime *date.Time `json:"creationTime,omitempty"` + // LastModifiedTime - Gets or sets the last modified time. + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + // Description - Gets or sets the description. + Description *string `json:"description,omitempty"` +} + +// MarshalJSON is the custom marshaler for RunbookProperties. +func (rp RunbookProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rp.RunbookType != "" { + objectMap["runbookType"] = rp.RunbookType + } + if rp.PublishContentLink != nil { + objectMap["publishContentLink"] = rp.PublishContentLink + } + if rp.State != "" { + objectMap["state"] = rp.State + } + if rp.LogVerbose != nil { + objectMap["logVerbose"] = rp.LogVerbose + } + if rp.LogProgress != nil { + objectMap["logProgress"] = rp.LogProgress + } + if rp.LogActivityTrace != nil { + objectMap["logActivityTrace"] = rp.LogActivityTrace + } + if rp.JobCount != nil { + objectMap["jobCount"] = rp.JobCount + } + if rp.Parameters != nil { + objectMap["parameters"] = rp.Parameters + } + if rp.OutputTypes != nil { + objectMap["outputTypes"] = rp.OutputTypes + } + if rp.Draft != nil { + objectMap["draft"] = rp.Draft + } + if rp.ProvisioningState != "" { + objectMap["provisioningState"] = rp.ProvisioningState + } + if rp.LastModifiedBy != nil { + objectMap["lastModifiedBy"] = rp.LastModifiedBy + } + if rp.CreationTime != nil { + objectMap["creationTime"] = rp.CreationTime + } + if rp.LastModifiedTime != nil { + objectMap["lastModifiedTime"] = rp.LastModifiedTime + } + if rp.Description != nil { + objectMap["description"] = rp.Description + } + return json.Marshal(objectMap) +} + +// RunbookUpdateParameters the parameters supplied to the update runbook operation. +type RunbookUpdateParameters struct { + // RunbookUpdateProperties - Gets or sets the runbook update properties. + *RunbookUpdateProperties `json:"properties,omitempty"` + // Name - Gets or sets the name of the resource. + Name *string `json:"name,omitempty"` + // Location - Gets or sets the location of the resource. + Location *string `json:"location,omitempty"` + // Tags - Gets or sets the tags attached to the resource. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for RunbookUpdateParameters. +func (rup RunbookUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rup.RunbookUpdateProperties != nil { + objectMap["properties"] = rup.RunbookUpdateProperties + } + if rup.Name != nil { + objectMap["name"] = rup.Name + } + if rup.Location != nil { + objectMap["location"] = rup.Location + } + if rup.Tags != nil { + objectMap["tags"] = rup.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RunbookUpdateParameters struct. +func (rup *RunbookUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var runbookUpdateProperties RunbookUpdateProperties + err = json.Unmarshal(*v, &runbookUpdateProperties) + if err != nil { + return err + } + rup.RunbookUpdateProperties = &runbookUpdateProperties + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rup.Name = &name + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + rup.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + rup.Tags = tags + } + } + } + + return nil +} + +// RunbookUpdateProperties the parameters supplied to the update runbook properties. +type RunbookUpdateProperties struct { + // Description - Gets or sets the description of the runbook. + Description *string `json:"description,omitempty"` + // LogVerbose - Gets or sets verbose log option. + LogVerbose *bool `json:"logVerbose,omitempty"` + // LogProgress - Gets or sets progress log option. + LogProgress *bool `json:"logProgress,omitempty"` + // LogActivityTrace - Gets or sets the activity-level tracing options of the runbook. + LogActivityTrace *int32 `json:"logActivityTrace,omitempty"` +} + +// Schedule definition of the schedule. +type Schedule struct { + autorest.Response `json:"-"` + // ScheduleProperties - Gets or sets the properties of the schedule. + *ScheduleProperties `json:"properties,omitempty"` + // ID - Fully qualified resource Id for the resource + ID *string `json:"id,omitempty"` + // Name - The name of the resource + Name *string `json:"name,omitempty"` + // Type - The type of the resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Schedule. +func (s Schedule) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if s.ScheduleProperties != nil { + objectMap["properties"] = s.ScheduleProperties + } + if s.ID != nil { + objectMap["id"] = s.ID + } + if s.Name != nil { + objectMap["name"] = s.Name + } + if s.Type != nil { + objectMap["type"] = s.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Schedule struct. +func (s *Schedule) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var scheduleProperties ScheduleProperties + err = json.Unmarshal(*v, &scheduleProperties) + if err != nil { + return err + } + s.ScheduleProperties = &scheduleProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + s.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + s.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + s.Type = &typeVar + } + } + } + + return nil +} + +// ScheduleAssociationProperty the schedule property associated with the entity. +type ScheduleAssociationProperty struct { + // Name - Gets or sets the name of the Schedule. + Name *string `json:"name,omitempty"` +} + +// ScheduleCreateOrUpdateParameters the parameters supplied to the create or update schedule operation. +type ScheduleCreateOrUpdateParameters struct { + // Name - Gets or sets the name of the Schedule. + Name *string `json:"name,omitempty"` + // ScheduleCreateOrUpdateProperties - Gets or sets the list of schedule properties. + *ScheduleCreateOrUpdateProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for ScheduleCreateOrUpdateParameters. +func (scoup ScheduleCreateOrUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if scoup.Name != nil { + objectMap["name"] = scoup.Name + } + if scoup.ScheduleCreateOrUpdateProperties != nil { + objectMap["properties"] = scoup.ScheduleCreateOrUpdateProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ScheduleCreateOrUpdateParameters struct. +func (scoup *ScheduleCreateOrUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + scoup.Name = &name + } + case "properties": + if v != nil { + var scheduleCreateOrUpdateProperties ScheduleCreateOrUpdateProperties + err = json.Unmarshal(*v, &scheduleCreateOrUpdateProperties) + if err != nil { + return err + } + scoup.ScheduleCreateOrUpdateProperties = &scheduleCreateOrUpdateProperties + } + } + } + + return nil +} + +// ScheduleCreateOrUpdateProperties the parameters supplied to the create or update schedule operation. +type ScheduleCreateOrUpdateProperties struct { + // Description - Gets or sets the description of the schedule. + Description *string `json:"description,omitempty"` + // StartTime - Gets or sets the start time of the schedule. + StartTime *date.Time `json:"startTime,omitempty"` + // ExpiryTime - Gets or sets the end time of the schedule. + ExpiryTime *date.Time `json:"expiryTime,omitempty"` + // Interval - Gets or sets the interval of the schedule. + Interval interface{} `json:"interval,omitempty"` + // Frequency - Possible values include: 'OneTime', 'Day', 'Hour', 'Week', 'Month' + Frequency ScheduleFrequency `json:"frequency,omitempty"` + // TimeZone - Gets or sets the time zone of the schedule. + TimeZone *string `json:"timeZone,omitempty"` + // AdvancedSchedule - Gets or sets the AdvancedSchedule. + AdvancedSchedule *AdvancedSchedule `json:"advancedSchedule,omitempty"` +} + +// ScheduleListResult the response model for the list schedule operation. +type ScheduleListResult struct { + autorest.Response `json:"-"` + // Value - Gets or sets a list of schedules. + Value *[]Schedule `json:"value,omitempty"` + // NextLink - Gets or sets the next link. + NextLink *string `json:"nextLink,omitempty"` +} + +// ScheduleListResultIterator provides access to a complete listing of Schedule values. +type ScheduleListResultIterator struct { + i int + page ScheduleListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ScheduleListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ScheduleListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ScheduleListResultIterator) Response() ScheduleListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ScheduleListResultIterator) Value() Schedule { + if !iter.page.NotDone() { + return Schedule{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (slr ScheduleListResult) IsEmpty() bool { + return slr.Value == nil || len(*slr.Value) == 0 +} + +// scheduleListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (slr ScheduleListResult) scheduleListResultPreparer() (*http.Request, error) { + if slr.NextLink == nil || len(to.String(slr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(slr.NextLink))) +} + +// ScheduleListResultPage contains a page of Schedule values. +type ScheduleListResultPage struct { + fn func(ScheduleListResult) (ScheduleListResult, error) + slr ScheduleListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ScheduleListResultPage) Next() error { + next, err := page.fn(page.slr) + if err != nil { + return err + } + page.slr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ScheduleListResultPage) NotDone() bool { + return !page.slr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ScheduleListResultPage) Response() ScheduleListResult { + return page.slr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ScheduleListResultPage) Values() []Schedule { + if page.slr.IsEmpty() { + return nil + } + return *page.slr.Value +} + +// ScheduleProperties definition of schedule parameters. +type ScheduleProperties struct { + // StartTime - Gets or sets the start time of the schedule. + StartTime *date.Time `json:"startTime,omitempty"` + // StartTimeOffsetMinutes - Gets the start time's offset in minutes. + StartTimeOffsetMinutes *float64 `json:"startTimeOffsetMinutes,omitempty"` + // ExpiryTime - Gets or sets the end time of the schedule. + ExpiryTime *date.Time `json:"expiryTime,omitempty"` + // ExpiryTimeOffsetMinutes - Gets or sets the expiry time's offset in minutes. + ExpiryTimeOffsetMinutes *float64 `json:"expiryTimeOffsetMinutes,omitempty"` + // IsEnabled - Gets or sets a value indicating whether this schedule is enabled. + IsEnabled *bool `json:"isEnabled,omitempty"` + // NextRun - Gets or sets the next run time of the schedule. + NextRun *date.Time `json:"nextRun,omitempty"` + // NextRunOffsetMinutes - Gets or sets the next run time's offset in minutes. + NextRunOffsetMinutes *float64 `json:"nextRunOffsetMinutes,omitempty"` + // Interval - Gets or sets the interval of the schedule. + Interval *int32 `json:"interval,omitempty"` + // Frequency - Gets or sets the frequency of the schedule. Possible values include: 'OneTime', 'Day', 'Hour', 'Week', 'Month' + Frequency ScheduleFrequency `json:"frequency,omitempty"` + // TimeZone - Gets or sets the time zone of the schedule. + TimeZone *string `json:"timeZone,omitempty"` + // AdvancedSchedule - Gets or sets the advanced schedule. + AdvancedSchedule *AdvancedSchedule `json:"advancedSchedule,omitempty"` + // CreationTime - Gets or sets the creation time. + CreationTime *date.Time `json:"creationTime,omitempty"` + // LastModifiedTime - Gets or sets the last modified time. + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + // Description - Gets or sets the description. + Description *string `json:"description,omitempty"` +} + +// ScheduleUpdateParameters the parameters supplied to the update schedule operation. +type ScheduleUpdateParameters struct { + // Name - Gets or sets the name of the Schedule. + Name *string `json:"name,omitempty"` + // ScheduleUpdateProperties - Gets or sets the list of schedule properties. + *ScheduleUpdateProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for ScheduleUpdateParameters. +func (sup ScheduleUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sup.Name != nil { + objectMap["name"] = sup.Name + } + if sup.ScheduleUpdateProperties != nil { + objectMap["properties"] = sup.ScheduleUpdateProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ScheduleUpdateParameters struct. +func (sup *ScheduleUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sup.Name = &name + } + case "properties": + if v != nil { + var scheduleUpdateProperties ScheduleUpdateProperties + err = json.Unmarshal(*v, &scheduleUpdateProperties) + if err != nil { + return err + } + sup.ScheduleUpdateProperties = &scheduleUpdateProperties + } + } + } + + return nil +} + +// ScheduleUpdateProperties the parameters supplied to the update schedule operation. +type ScheduleUpdateProperties struct { + // Description - Gets or sets the description of the schedule. + Description *string `json:"description,omitempty"` + // IsEnabled - Gets or sets a value indicating whether this schedule is enabled. + IsEnabled *bool `json:"isEnabled,omitempty"` +} + +// SetObject ... +type SetObject struct { + autorest.Response `json:"-"` + Value interface{} `json:"value,omitempty"` +} + +// Sku the account SKU. +type Sku struct { + // Name - Gets or sets the SKU name of the account. Possible values include: 'Free', 'Basic' + Name SkuNameEnum `json:"name,omitempty"` + // Family - Gets or sets the SKU family. + Family *string `json:"family,omitempty"` + // Capacity - Gets or sets the SKU capacity. + Capacity *int32 `json:"capacity,omitempty"` +} + +// SoftwareUpdateConfiguration software update configuration properties. +type SoftwareUpdateConfiguration struct { + autorest.Response `json:"-"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // ID - Resource Id. + ID *string `json:"id,omitempty"` + // Type - Resource type + Type *string `json:"type,omitempty"` + // SoftwareUpdateConfigurationProperties - Software update configuration properties. + *SoftwareUpdateConfigurationProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for SoftwareUpdateConfiguration. +func (suc SoftwareUpdateConfiguration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if suc.Name != nil { + objectMap["name"] = suc.Name + } + if suc.ID != nil { + objectMap["id"] = suc.ID + } + if suc.Type != nil { + objectMap["type"] = suc.Type + } + if suc.SoftwareUpdateConfigurationProperties != nil { + objectMap["properties"] = suc.SoftwareUpdateConfigurationProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SoftwareUpdateConfiguration struct. +func (suc *SoftwareUpdateConfiguration) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + suc.Name = &name + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + suc.ID = &ID + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + suc.Type = &typeVar + } + case "properties": + if v != nil { + var softwareUpdateConfigurationProperties SoftwareUpdateConfigurationProperties + err = json.Unmarshal(*v, &softwareUpdateConfigurationProperties) + if err != nil { + return err + } + suc.SoftwareUpdateConfigurationProperties = &softwareUpdateConfigurationProperties + } + } + } + + return nil +} + +// SoftwareUpdateConfigurationCollectionItem software update configuration collection item properties. +type SoftwareUpdateConfigurationCollectionItem struct { + // Name - Name of the software update configuration. + Name *string `json:"name,omitempty"` + // ID - Resource Id of the software update configuration + ID *string `json:"id,omitempty"` + // SoftwareUpdateConfigurationCollectionItemProperties - Software update configuration properties. + *SoftwareUpdateConfigurationCollectionItemProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for SoftwareUpdateConfigurationCollectionItem. +func (succi SoftwareUpdateConfigurationCollectionItem) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if succi.Name != nil { + objectMap["name"] = succi.Name + } + if succi.ID != nil { + objectMap["id"] = succi.ID + } + if succi.SoftwareUpdateConfigurationCollectionItemProperties != nil { + objectMap["properties"] = succi.SoftwareUpdateConfigurationCollectionItemProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SoftwareUpdateConfigurationCollectionItem struct. +func (succi *SoftwareUpdateConfigurationCollectionItem) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + succi.Name = &name + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + succi.ID = &ID + } + case "properties": + if v != nil { + var softwareUpdateConfigurationCollectionItemProperties SoftwareUpdateConfigurationCollectionItemProperties + err = json.Unmarshal(*v, &softwareUpdateConfigurationCollectionItemProperties) + if err != nil { + return err + } + succi.SoftwareUpdateConfigurationCollectionItemProperties = &softwareUpdateConfigurationCollectionItemProperties + } + } + } + + return nil +} + +// SoftwareUpdateConfigurationCollectionItemProperties software update configuration collection item properties. +type SoftwareUpdateConfigurationCollectionItemProperties struct { + // UpdateConfiguration - Update specific properties of the software update configuration. + UpdateConfiguration *CollectionItemUpdateConfiguration `json:"updateConfiguration,omitempty"` + // Frequency - execution frequency of the schedule associated with the software update configuration. Possible values include: 'OneTime', 'Day', 'Hour', 'Week', 'Month' + Frequency ScheduleFrequency `json:"frequency,omitempty"` + // StartTime - the start time of the update. + StartTime *date.Time `json:"startTime,omitempty"` + // CreationTime - Creation time of the software update configuration, which only appears in the response. + CreationTime *date.Time `json:"creationTime,omitempty"` + // LastModifiedTime - Last time software update configuration was modified, which only appears in the response. + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + // ProvisioningState - Provisioning state for the software update configuration, which only appears in the response. + ProvisioningState *string `json:"provisioningState,omitempty"` + // NextRun - ext run time of the update. + NextRun *date.Time `json:"nextRun,omitempty"` +} + +// SoftwareUpdateConfigurationListResult result of listing all software update configuration +type SoftwareUpdateConfigurationListResult struct { + autorest.Response `json:"-"` + // Value - outer object returned when listing all software update configurations + Value *[]SoftwareUpdateConfigurationCollectionItem `json:"value,omitempty"` +} + +// SoftwareUpdateConfigurationMachineRun software update configuration machine run model. +type SoftwareUpdateConfigurationMachineRun struct { + autorest.Response `json:"-"` + // Name - Name of the software update configuration machine run + Name *string `json:"name,omitempty"` + // ID - Resource Id of the software update configuration machine run + ID *string `json:"id,omitempty"` + // UpdateConfigurationMachineRunProperties - Software update configuration machine run properties. + *UpdateConfigurationMachineRunProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for SoftwareUpdateConfigurationMachineRun. +func (sucmr SoftwareUpdateConfigurationMachineRun) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sucmr.Name != nil { + objectMap["name"] = sucmr.Name + } + if sucmr.ID != nil { + objectMap["id"] = sucmr.ID + } + if sucmr.UpdateConfigurationMachineRunProperties != nil { + objectMap["properties"] = sucmr.UpdateConfigurationMachineRunProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SoftwareUpdateConfigurationMachineRun struct. +func (sucmr *SoftwareUpdateConfigurationMachineRun) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sucmr.Name = &name + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sucmr.ID = &ID + } + case "properties": + if v != nil { + var updateConfigurationMachineRunProperties UpdateConfigurationMachineRunProperties + err = json.Unmarshal(*v, &updateConfigurationMachineRunProperties) + if err != nil { + return err + } + sucmr.UpdateConfigurationMachineRunProperties = &updateConfigurationMachineRunProperties + } + } + } + + return nil +} + +// SoftwareUpdateConfigurationMachineRunListResult result of listing all software update configuration machine runs +type SoftwareUpdateConfigurationMachineRunListResult struct { + autorest.Response `json:"-"` + // Value - outer object returned when listing all software update configuration machine runs + Value *[]SoftwareUpdateConfigurationMachineRun `json:"value,omitempty"` + // NextLink - link to next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// SoftwareUpdateConfigurationProperties software update configuration properties. +type SoftwareUpdateConfigurationProperties struct { + // UpdateConfiguration - update specific properties for the Software update configuration + UpdateConfiguration *UpdateConfiguration `json:"updateConfiguration,omitempty"` + // ScheduleInfo - Schedule information for the Software update configuration + ScheduleInfo *ScheduleProperties `json:"scheduleInfo,omitempty"` + // ProvisioningState - Provisioning state for the software update configuration, which only appears in the response. + ProvisioningState *string `json:"provisioningState,omitempty"` + // Error - detailes of provisioning error + Error *ErrorResponse `json:"error,omitempty"` + // CreationTime - Creation time of theresource, which only appears in the response. + CreationTime *date.Time `json:"creationTime,omitempty"` + // CreatedBy - createdBy property, which only appears in the response. + CreatedBy *string `json:"createdBy,omitempty"` + // LastModifiedTime - Last time resource was modified, which only appears in the response. + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + // LastModifiedBy - lastModifiedBy property, which only appears in the response. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` +} + +// SoftwareUpdateConfigurationRun software update configuration Run properties. +type SoftwareUpdateConfigurationRun struct { + autorest.Response `json:"-"` + // Name - Name of the software update configuration run. + Name *string `json:"name,omitempty"` + // ID - Resource Id of the software update configuration run + ID *string `json:"id,omitempty"` + // SoftwareUpdateConfigurationRunProperties - Software update configuration Run properties. + *SoftwareUpdateConfigurationRunProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for SoftwareUpdateConfigurationRun. +func (sucr SoftwareUpdateConfigurationRun) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sucr.Name != nil { + objectMap["name"] = sucr.Name + } + if sucr.ID != nil { + objectMap["id"] = sucr.ID + } + if sucr.SoftwareUpdateConfigurationRunProperties != nil { + objectMap["properties"] = sucr.SoftwareUpdateConfigurationRunProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SoftwareUpdateConfigurationRun struct. +func (sucr *SoftwareUpdateConfigurationRun) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sucr.Name = &name + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sucr.ID = &ID + } + case "properties": + if v != nil { + var softwareUpdateConfigurationRunProperties SoftwareUpdateConfigurationRunProperties + err = json.Unmarshal(*v, &softwareUpdateConfigurationRunProperties) + if err != nil { + return err + } + sucr.SoftwareUpdateConfigurationRunProperties = &softwareUpdateConfigurationRunProperties + } + } + } + + return nil +} + +// SoftwareUpdateConfigurationRunListResult result of listing all software update configuration runs +type SoftwareUpdateConfigurationRunListResult struct { + autorest.Response `json:"-"` + // Value - outer object returned when listing all software update configuration runs + Value *[]SoftwareUpdateConfigurationRun `json:"value,omitempty"` + // NextLink - link to next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// SoftwareUpdateConfigurationRunProperties software update configuration properties. +type SoftwareUpdateConfigurationRunProperties struct { + // SoftwareUpdateConfiguration - software update configuration triggered this run + SoftwareUpdateConfiguration *UpdateConfigurationNavigation `json:"softwareUpdateConfiguration,omitempty"` + // Status - Status of the software update configuration run. + Status *string `json:"status,omitempty"` + // ConfiguredDuration - configured duration for the software update configuration run. + ConfiguredDuration *string `json:"configuredDuration,omitempty"` + // OsType - Operating system target of the software update configuration triggered this run + OsType *string `json:"osType,omitempty"` + // StartTime - Etart time of the software update configuration run. + StartTime *date.Time `json:"startTime,omitempty"` + // EndTime - End time of the software update configuration run. + EndTime *date.Time `json:"endTime,omitempty"` + // ComputerCount - Number of computers in the software update configuration run. + ComputerCount *int32 `json:"computerCount,omitempty"` + // FailedCount - Number of computers with failed status. + FailedCount *int32 `json:"failedCount,omitempty"` + // CreationTime - Creation time of theresource, which only appears in the response. + CreationTime *date.Time `json:"creationTime,omitempty"` + // CreatedBy - createdBy property, which only appears in the response. + CreatedBy *string `json:"createdBy,omitempty"` + // LastModifiedTime - Last time resource was modified, which only appears in the response. + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + // LastModifiedBy - lastModifiedBy property, which only appears in the response. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` +} + +// SourceControl definition of the source control. +type SourceControl struct { + autorest.Response `json:"-"` + // SourceControlProperties - The properties of the source control. + *SourceControlProperties `json:"properties,omitempty"` + // ID - Fully qualified resource Id for the resource + ID *string `json:"id,omitempty"` + // Name - The name of the resource + Name *string `json:"name,omitempty"` + // Type - The type of the resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for SourceControl. +func (sc SourceControl) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sc.SourceControlProperties != nil { + objectMap["properties"] = sc.SourceControlProperties + } + if sc.ID != nil { + objectMap["id"] = sc.ID + } + if sc.Name != nil { + objectMap["name"] = sc.Name + } + if sc.Type != nil { + objectMap["type"] = sc.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SourceControl struct. +func (sc *SourceControl) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var sourceControlProperties SourceControlProperties + err = json.Unmarshal(*v, &sourceControlProperties) + if err != nil { + return err + } + sc.SourceControlProperties = &sourceControlProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sc.Type = &typeVar + } + } + } + + return nil +} + +// SourceControlCreateOrUpdateParameters the parameters supplied to the create or update source control operation. +type SourceControlCreateOrUpdateParameters struct { + // SourceControlCreateOrUpdateProperties - The properties of the source control. + *SourceControlCreateOrUpdateProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for SourceControlCreateOrUpdateParameters. +func (sccoup SourceControlCreateOrUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sccoup.SourceControlCreateOrUpdateProperties != nil { + objectMap["properties"] = sccoup.SourceControlCreateOrUpdateProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SourceControlCreateOrUpdateParameters struct. +func (sccoup *SourceControlCreateOrUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var sourceControlCreateOrUpdateProperties SourceControlCreateOrUpdateProperties + err = json.Unmarshal(*v, &sourceControlCreateOrUpdateProperties) + if err != nil { + return err + } + sccoup.SourceControlCreateOrUpdateProperties = &sourceControlCreateOrUpdateProperties + } + } + } + + return nil +} + +// SourceControlCreateOrUpdateProperties the properties of the create source control operation. +type SourceControlCreateOrUpdateProperties struct { + // RepoURL - The repo url of the source control. + RepoURL *string `json:"repoUrl,omitempty"` + // Branch - The repo branch of the source control. Include branch as empty string for VsoTfvc. + Branch *string `json:"branch,omitempty"` + // FolderPath - The folder path of the source control. Path must be relative. + FolderPath *string `json:"folderPath,omitempty"` + // AutoSync - The auto async of the source control. Default is false. + AutoSync *bool `json:"autoSync,omitempty"` + // PublishRunbook - The auto publish of the source control. Default is true. + PublishRunbook *bool `json:"publishRunbook,omitempty"` + // SourceType - The source type. Must be one of VsoGit, VsoTfvc, GitHub, case sensitive. Possible values include: 'VsoGit', 'VsoTfvc', 'GitHub' + SourceType SourceType `json:"sourceType,omitempty"` + // SecurityToken - The authorization token for the repo of the source control. + SecurityToken *SourceControlSecurityTokenProperties `json:"securityToken,omitempty"` + // Description - The user description of the source control. + Description *string `json:"description,omitempty"` +} + +// SourceControlListResult the response model for the list source controls operation. +type SourceControlListResult struct { + autorest.Response `json:"-"` + // Value - The list of souce controls. + Value *[]SourceControl `json:"value,omitempty"` + // NextLink - The next link. + NextLink *string `json:"nextLink,omitempty"` +} + +// SourceControlListResultIterator provides access to a complete listing of SourceControl values. +type SourceControlListResultIterator struct { + i int + page SourceControlListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *SourceControlListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter SourceControlListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter SourceControlListResultIterator) Response() SourceControlListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter SourceControlListResultIterator) Value() SourceControl { + if !iter.page.NotDone() { + return SourceControl{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (sclr SourceControlListResult) IsEmpty() bool { + return sclr.Value == nil || len(*sclr.Value) == 0 +} + +// sourceControlListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sclr SourceControlListResult) sourceControlListResultPreparer() (*http.Request, error) { + if sclr.NextLink == nil || len(to.String(sclr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sclr.NextLink))) +} + +// SourceControlListResultPage contains a page of SourceControl values. +type SourceControlListResultPage struct { + fn func(SourceControlListResult) (SourceControlListResult, error) + sclr SourceControlListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *SourceControlListResultPage) Next() error { + next, err := page.fn(page.sclr) + if err != nil { + return err + } + page.sclr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page SourceControlListResultPage) NotDone() bool { + return !page.sclr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page SourceControlListResultPage) Response() SourceControlListResult { + return page.sclr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page SourceControlListResultPage) Values() []SourceControl { + if page.sclr.IsEmpty() { + return nil + } + return *page.sclr.Value +} + +// SourceControlProperties definition of the source control properties +type SourceControlProperties struct { + // RepoURL - The repo url of the source control. + RepoURL *string `json:"repoUrl,omitempty"` + // Branch - The repo branch of the source control. Include branch as empty string for VsoTfvc. + Branch *string `json:"branch,omitempty"` + // FolderPath - The folder path of the source control. + FolderPath *string `json:"folderPath,omitempty"` + // AutoSync - The auto sync of the source control. Default is false. + AutoSync *bool `json:"autoSync,omitempty"` + // PublishRunbook - The auto publish of the source control. Default is true. + PublishRunbook *bool `json:"publishRunbook,omitempty"` + // SourceType - The source type. Must be one of VsoGit, VsoTfvc, GitHub. Possible values include: 'VsoGit', 'VsoTfvc', 'GitHub' + SourceType SourceType `json:"sourceType,omitempty"` + // Description - The description. + Description *string `json:"description,omitempty"` + // CreationTime - The creation time. + CreationTime *date.Time `json:"creationTime,omitempty"` + // LastModifiedTime - The last modified time. + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` +} + +// SourceControlSecurityTokenProperties ... +type SourceControlSecurityTokenProperties struct { + // AccessToken - The access token. + AccessToken *string `json:"accessToken,omitempty"` + // RefreshToken - The refresh token. + RefreshToken *string `json:"refreshToken,omitempty"` + // TokenType - The token type. Must be either PersonalAccessToken or Oauth. Possible values include: 'PersonalAccessToken', 'Oauth' + TokenType TokenType `json:"tokenType,omitempty"` +} + +// SourceControlSyncJob definition of the source control sync job. +type SourceControlSyncJob struct { + autorest.Response `json:"-"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` + // ID - Resource id. + ID *string `json:"id,omitempty"` + // SourceControlSyncJobProperties - The properties of the source control sync job. + *SourceControlSyncJobProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for SourceControlSyncJob. +func (scsj SourceControlSyncJob) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if scsj.Name != nil { + objectMap["name"] = scsj.Name + } + if scsj.Type != nil { + objectMap["type"] = scsj.Type + } + if scsj.ID != nil { + objectMap["id"] = scsj.ID + } + if scsj.SourceControlSyncJobProperties != nil { + objectMap["properties"] = scsj.SourceControlSyncJobProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SourceControlSyncJob struct. +func (scsj *SourceControlSyncJob) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + scsj.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + scsj.Type = &typeVar + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + scsj.ID = &ID + } + case "properties": + if v != nil { + var sourceControlSyncJobProperties SourceControlSyncJobProperties + err = json.Unmarshal(*v, &sourceControlSyncJobProperties) + if err != nil { + return err + } + scsj.SourceControlSyncJobProperties = &sourceControlSyncJobProperties + } + } + } + + return nil +} + +// SourceControlSyncJobByID definition of the source control sync job. +type SourceControlSyncJobByID struct { + autorest.Response `json:"-"` + // ID - The id of the job. + ID *string `json:"id,omitempty"` + // SourceControlSyncJobByIDProperties - The properties of the source control sync job. + *SourceControlSyncJobByIDProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for SourceControlSyncJobByID. +func (scsjbi SourceControlSyncJobByID) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if scsjbi.ID != nil { + objectMap["id"] = scsjbi.ID + } + if scsjbi.SourceControlSyncJobByIDProperties != nil { + objectMap["properties"] = scsjbi.SourceControlSyncJobByIDProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SourceControlSyncJobByID struct. +func (scsjbi *SourceControlSyncJobByID) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + scsjbi.ID = &ID + } + case "properties": + if v != nil { + var sourceControlSyncJobByIDProperties SourceControlSyncJobByIDProperties + err = json.Unmarshal(*v, &sourceControlSyncJobByIDProperties) + if err != nil { + return err + } + scsjbi.SourceControlSyncJobByIDProperties = &sourceControlSyncJobByIDProperties + } + } + } + + return nil +} + +// SourceControlSyncJobByIDProperties definition of source control sync job properties. +type SourceControlSyncJobByIDProperties struct { + // SourceControlSyncJobID - The source control sync job id. + SourceControlSyncJobID *string `json:"sourceControlSyncJobId,omitempty"` + // CreationTime - The creation time of the job. + CreationTime *date.Time `json:"creationTime,omitempty"` + // ProvisioningState - The provisioning state of the job. Possible values include: 'Completed', 'Failed', 'Running' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + // StartTime - The start time of the job. + StartTime *date.Time `json:"startTime,omitempty"` + // EndTime - The end time of the job. + EndTime *date.Time `json:"endTime,omitempty"` + // SyncType - The sync type. Possible values include: 'PartialSync', 'FullSync' + SyncType SyncType `json:"syncType,omitempty"` + // Exception - The exceptions that occured while running the sync job. + Exception *string `json:"exception,omitempty"` +} + +// SourceControlSyncJobCreateParameters the parameters supplied to the create source control sync job operation. +type SourceControlSyncJobCreateParameters struct { + // SourceControlSyncJobCreateProperties - The properties of the source control sync job. + *SourceControlSyncJobCreateProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for SourceControlSyncJobCreateParameters. +func (scsjcp SourceControlSyncJobCreateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if scsjcp.SourceControlSyncJobCreateProperties != nil { + objectMap["properties"] = scsjcp.SourceControlSyncJobCreateProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SourceControlSyncJobCreateParameters struct. +func (scsjcp *SourceControlSyncJobCreateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var sourceControlSyncJobCreateProperties SourceControlSyncJobCreateProperties + err = json.Unmarshal(*v, &sourceControlSyncJobCreateProperties) + if err != nil { + return err + } + scsjcp.SourceControlSyncJobCreateProperties = &sourceControlSyncJobCreateProperties + } + } + } + + return nil +} + +// SourceControlSyncJobCreateProperties definition of create source control sync job properties. +type SourceControlSyncJobCreateProperties struct { + // CommitID - The commit id of the source control sync job. If not syncing to a commitId, enter an empty string. + CommitID *string `json:"commitId,omitempty"` +} + +// SourceControlSyncJobListResult the response model for the list source control sync jobs operation. +type SourceControlSyncJobListResult struct { + autorest.Response `json:"-"` + // Value - The list of source control sync jobs. + Value *[]SourceControlSyncJob `json:"value,omitempty"` + // NextLink - The next link. + NextLink *string `json:"nextLink,omitempty"` +} + +// SourceControlSyncJobListResultIterator provides access to a complete listing of SourceControlSyncJob values. +type SourceControlSyncJobListResultIterator struct { + i int + page SourceControlSyncJobListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *SourceControlSyncJobListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter SourceControlSyncJobListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter SourceControlSyncJobListResultIterator) Response() SourceControlSyncJobListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter SourceControlSyncJobListResultIterator) Value() SourceControlSyncJob { + if !iter.page.NotDone() { + return SourceControlSyncJob{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (scsjlr SourceControlSyncJobListResult) IsEmpty() bool { + return scsjlr.Value == nil || len(*scsjlr.Value) == 0 +} + +// sourceControlSyncJobListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (scsjlr SourceControlSyncJobListResult) sourceControlSyncJobListResultPreparer() (*http.Request, error) { + if scsjlr.NextLink == nil || len(to.String(scsjlr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(scsjlr.NextLink))) +} + +// SourceControlSyncJobListResultPage contains a page of SourceControlSyncJob values. +type SourceControlSyncJobListResultPage struct { + fn func(SourceControlSyncJobListResult) (SourceControlSyncJobListResult, error) + scsjlr SourceControlSyncJobListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *SourceControlSyncJobListResultPage) Next() error { + next, err := page.fn(page.scsjlr) + if err != nil { + return err + } + page.scsjlr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page SourceControlSyncJobListResultPage) NotDone() bool { + return !page.scsjlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page SourceControlSyncJobListResultPage) Response() SourceControlSyncJobListResult { + return page.scsjlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page SourceControlSyncJobListResultPage) Values() []SourceControlSyncJob { + if page.scsjlr.IsEmpty() { + return nil + } + return *page.scsjlr.Value +} + +// SourceControlSyncJobProperties definition of source control sync job properties. +type SourceControlSyncJobProperties struct { + // SourceControlSyncJobID - The source control sync job id. + SourceControlSyncJobID *string `json:"sourceControlSyncJobId,omitempty"` + // CreationTime - The creation time of the job. + CreationTime *date.Time `json:"creationTime,omitempty"` + // ProvisioningState - The provisioning state of the job. Possible values include: 'Completed', 'Failed', 'Running' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + // StartTime - The start time of the job. + StartTime *date.Time `json:"startTime,omitempty"` + // EndTime - The end time of the job. + EndTime *date.Time `json:"endTime,omitempty"` + // SyncType - The sync type. Possible values include: 'PartialSync', 'FullSync' + SyncType SyncType `json:"syncType,omitempty"` +} + +// SourceControlSyncJobStream definition of the source control sync job stream. +type SourceControlSyncJobStream struct { + // ID - Resource id. + ID *string `json:"id,omitempty"` + // SourceControlSyncJobStreamProperties - The properties of the source control sync job stream. + *SourceControlSyncJobStreamProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for SourceControlSyncJobStream. +func (scsjs SourceControlSyncJobStream) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if scsjs.ID != nil { + objectMap["id"] = scsjs.ID + } + if scsjs.SourceControlSyncJobStreamProperties != nil { + objectMap["properties"] = scsjs.SourceControlSyncJobStreamProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SourceControlSyncJobStream struct. +func (scsjs *SourceControlSyncJobStream) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + scsjs.ID = &ID + } + case "properties": + if v != nil { + var sourceControlSyncJobStreamProperties SourceControlSyncJobStreamProperties + err = json.Unmarshal(*v, &sourceControlSyncJobStreamProperties) + if err != nil { + return err + } + scsjs.SourceControlSyncJobStreamProperties = &sourceControlSyncJobStreamProperties + } + } + } + + return nil +} + +// SourceControlSyncJobStreamByID definition of the source control sync job stream by id. +type SourceControlSyncJobStreamByID struct { + autorest.Response `json:"-"` + // ID - Resource id. + ID *string `json:"id,omitempty"` + // SourceControlSyncJobStreamByIDProperties - The properties of the source control sync job stream. + *SourceControlSyncJobStreamByIDProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for SourceControlSyncJobStreamByID. +func (scsjsbi SourceControlSyncJobStreamByID) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if scsjsbi.ID != nil { + objectMap["id"] = scsjsbi.ID + } + if scsjsbi.SourceControlSyncJobStreamByIDProperties != nil { + objectMap["properties"] = scsjsbi.SourceControlSyncJobStreamByIDProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SourceControlSyncJobStreamByID struct. +func (scsjsbi *SourceControlSyncJobStreamByID) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + scsjsbi.ID = &ID + } + case "properties": + if v != nil { + var sourceControlSyncJobStreamByIDProperties SourceControlSyncJobStreamByIDProperties + err = json.Unmarshal(*v, &sourceControlSyncJobStreamByIDProperties) + if err != nil { + return err + } + scsjsbi.SourceControlSyncJobStreamByIDProperties = &sourceControlSyncJobStreamByIDProperties + } + } + } + + return nil +} + +// SourceControlSyncJobStreamByIDProperties definition of source control sync job stream by id properties. +type SourceControlSyncJobStreamByIDProperties struct { + // SourceControlSyncJobStreamID - The sync job stream id. + SourceControlSyncJobStreamID *string `json:"sourceControlSyncJobStreamId,omitempty"` + // Summary - The summary of the sync job stream. + Summary *string `json:"summary,omitempty"` + // Time - The time of the sync job stream. + Time *date.Time `json:"time,omitempty"` + // StreamType - The type of the sync job stream. Possible values include: 'StreamTypeError', 'StreamTypeOutput' + StreamType StreamType `json:"streamType,omitempty"` + // StreamText - The text of the sync job stream. + StreamText *string `json:"streamText,omitempty"` + // Value - The values of the job stream. + Value map[string]interface{} `json:"value"` +} + +// MarshalJSON is the custom marshaler for SourceControlSyncJobStreamByIDProperties. +func (scsjsbip SourceControlSyncJobStreamByIDProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if scsjsbip.SourceControlSyncJobStreamID != nil { + objectMap["sourceControlSyncJobStreamId"] = scsjsbip.SourceControlSyncJobStreamID + } + if scsjsbip.Summary != nil { + objectMap["summary"] = scsjsbip.Summary + } + if scsjsbip.Time != nil { + objectMap["time"] = scsjsbip.Time + } + if scsjsbip.StreamType != "" { + objectMap["streamType"] = scsjsbip.StreamType + } + if scsjsbip.StreamText != nil { + objectMap["streamText"] = scsjsbip.StreamText + } + if scsjsbip.Value != nil { + objectMap["value"] = scsjsbip.Value + } + return json.Marshal(objectMap) +} + +// SourceControlSyncJobStreamProperties definition of source control sync job stream properties. +type SourceControlSyncJobStreamProperties struct { + // SourceControlSyncJobStreamID - The sync job stream id. + SourceControlSyncJobStreamID *string `json:"sourceControlSyncJobStreamId,omitempty"` + // Summary - The summary of the sync job stream. + Summary *string `json:"summary,omitempty"` + // Time - The time of the sync job stream. + Time *date.Time `json:"time,omitempty"` + // StreamType - The type of the sync job stream. Possible values include: 'StreamTypeError', 'StreamTypeOutput' + StreamType StreamType `json:"streamType,omitempty"` +} + +// SourceControlSyncJobStreamsListBySyncJob the response model for the list source control sync job streams +// operation. +type SourceControlSyncJobStreamsListBySyncJob struct { + autorest.Response `json:"-"` + // Value - The list of source control sync job streams. + Value *[]SourceControlSyncJobStream `json:"value,omitempty"` + // NextLink - The next link. + NextLink *string `json:"nextLink,omitempty"` +} + +// SourceControlSyncJobStreamsListBySyncJobIterator provides access to a complete listing of +// SourceControlSyncJobStream values. +type SourceControlSyncJobStreamsListBySyncJobIterator struct { + i int + page SourceControlSyncJobStreamsListBySyncJobPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *SourceControlSyncJobStreamsListBySyncJobIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter SourceControlSyncJobStreamsListBySyncJobIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter SourceControlSyncJobStreamsListBySyncJobIterator) Response() SourceControlSyncJobStreamsListBySyncJob { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter SourceControlSyncJobStreamsListBySyncJobIterator) Value() SourceControlSyncJobStream { + if !iter.page.NotDone() { + return SourceControlSyncJobStream{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (scsjslbsj SourceControlSyncJobStreamsListBySyncJob) IsEmpty() bool { + return scsjslbsj.Value == nil || len(*scsjslbsj.Value) == 0 +} + +// sourceControlSyncJobStreamsListBySyncJobPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (scsjslbsj SourceControlSyncJobStreamsListBySyncJob) sourceControlSyncJobStreamsListBySyncJobPreparer() (*http.Request, error) { + if scsjslbsj.NextLink == nil || len(to.String(scsjslbsj.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(scsjslbsj.NextLink))) +} + +// SourceControlSyncJobStreamsListBySyncJobPage contains a page of SourceControlSyncJobStream values. +type SourceControlSyncJobStreamsListBySyncJobPage struct { + fn func(SourceControlSyncJobStreamsListBySyncJob) (SourceControlSyncJobStreamsListBySyncJob, error) + scsjslbsj SourceControlSyncJobStreamsListBySyncJob +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *SourceControlSyncJobStreamsListBySyncJobPage) Next() error { + next, err := page.fn(page.scsjslbsj) + if err != nil { + return err + } + page.scsjslbsj = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page SourceControlSyncJobStreamsListBySyncJobPage) NotDone() bool { + return !page.scsjslbsj.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page SourceControlSyncJobStreamsListBySyncJobPage) Response() SourceControlSyncJobStreamsListBySyncJob { + return page.scsjslbsj +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page SourceControlSyncJobStreamsListBySyncJobPage) Values() []SourceControlSyncJobStream { + if page.scsjslbsj.IsEmpty() { + return nil + } + return *page.scsjslbsj.Value +} + +// SourceControlUpdateParameters the parameters supplied to the update source control operation. +type SourceControlUpdateParameters struct { + // SourceControlUpdateProperties - The value of the source control. + *SourceControlUpdateProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for SourceControlUpdateParameters. +func (scup SourceControlUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if scup.SourceControlUpdateProperties != nil { + objectMap["properties"] = scup.SourceControlUpdateProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SourceControlUpdateParameters struct. +func (scup *SourceControlUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var sourceControlUpdateProperties SourceControlUpdateProperties + err = json.Unmarshal(*v, &sourceControlUpdateProperties) + if err != nil { + return err + } + scup.SourceControlUpdateProperties = &sourceControlUpdateProperties + } + } + } + + return nil +} + +// SourceControlUpdateProperties the properties of the update source control +type SourceControlUpdateProperties struct { + // Branch - The repo branch of the source control. + Branch *string `json:"branch,omitempty"` + // FolderPath - The folder path of the source control. Path must be relative. + FolderPath *string `json:"folderPath,omitempty"` + // AutoSync - The auto sync of the source control. Default is false. + AutoSync *bool `json:"autoSync,omitempty"` + // PublishRunbook - The auto publish of the source control. Default is true. + PublishRunbook *bool `json:"publishRunbook,omitempty"` + // SecurityToken - The authorization token for the repo of the source control. + SecurityToken *SourceControlSecurityTokenProperties `json:"securityToken,omitempty"` + // Description - The user description of the source control. + Description *string `json:"description,omitempty"` +} + +// Statistics definition of the statistic. +type Statistics struct { + // CounterProperty - Gets the property value of the statistic. + CounterProperty *string `json:"counterProperty,omitempty"` + // CounterValue - Gets the value of the statistic. + CounterValue *int64 `json:"counterValue,omitempty"` + // StartTime - Gets the startTime of the statistic. + StartTime *date.Time `json:"startTime,omitempty"` + // EndTime - Gets the endTime of the statistic. + EndTime *date.Time `json:"endTime,omitempty"` + // ID - Gets the id. + ID *string `json:"id,omitempty"` +} + +// StatisticsListResult the response model for the list statistics operation. +type StatisticsListResult struct { + autorest.Response `json:"-"` + // Value - Gets or sets a list of statistics. + Value *[]Statistics `json:"value,omitempty"` +} + +// String ... +type String struct { + autorest.Response `json:"-"` + Value *string `json:"value,omitempty"` +} + +// TagSettingsProperties tag filter information for the VM. +type TagSettingsProperties struct { + // Tags - Dictionary of tags with its list of values. + Tags map[string][]string `json:"tags"` + // FilterOperator - Filter VMs by Any or All specified tags. Possible values include: 'TagOperatorsAll', 'TagOperatorsAny' + FilterOperator TagOperators `json:"filterOperator,omitempty"` +} + +// MarshalJSON is the custom marshaler for TagSettingsProperties. +func (tsp TagSettingsProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tsp.Tags != nil { + objectMap["tags"] = tsp.Tags + } + if tsp.FilterOperator != "" { + objectMap["filterOperator"] = tsp.FilterOperator + } + return json.Marshal(objectMap) +} + +// TargetProperties group specific to the update configuration. +type TargetProperties struct { + // AzureQueries - List of Azure queries in the software update configuration. + AzureQueries *[]AzureQueryProperties `json:"azureQueries,omitempty"` +} + +// TestJob definition of the test job. +type TestJob struct { + autorest.Response `json:"-"` + // CreationTime - Gets or sets the creation time of the test job. + CreationTime *date.Time `json:"creationTime,omitempty"` + // Status - Gets or sets the status of the test job. + Status *string `json:"status,omitempty"` + // StatusDetails - Gets or sets the status details of the test job. + StatusDetails *string `json:"statusDetails,omitempty"` + // RunOn - Gets or sets the runOn which specifies the group name where the job is to be executed. + RunOn *string `json:"runOn,omitempty"` + // StartTime - Gets or sets the start time of the test job. + StartTime *date.Time `json:"startTime,omitempty"` + // EndTime - Gets or sets the end time of the test job. + EndTime *date.Time `json:"endTime,omitempty"` + // Exception - Gets or sets the exception of the test job. + Exception *string `json:"exception,omitempty"` + // LastModifiedTime - Gets or sets the last modified time of the test job. + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + // LastStatusModifiedTime - Gets or sets the last status modified time of the test job. + LastStatusModifiedTime *date.Time `json:"lastStatusModifiedTime,omitempty"` + // Parameters - Gets or sets the parameters of the test job. + Parameters map[string]*string `json:"parameters"` + // LogActivityTrace - The activity-level tracing options of the runbook. + LogActivityTrace *int32 `json:"logActivityTrace,omitempty"` +} + +// MarshalJSON is the custom marshaler for TestJob. +func (tj TestJob) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tj.CreationTime != nil { + objectMap["creationTime"] = tj.CreationTime + } + if tj.Status != nil { + objectMap["status"] = tj.Status + } + if tj.StatusDetails != nil { + objectMap["statusDetails"] = tj.StatusDetails + } + if tj.RunOn != nil { + objectMap["runOn"] = tj.RunOn + } + if tj.StartTime != nil { + objectMap["startTime"] = tj.StartTime + } + if tj.EndTime != nil { + objectMap["endTime"] = tj.EndTime + } + if tj.Exception != nil { + objectMap["exception"] = tj.Exception + } + if tj.LastModifiedTime != nil { + objectMap["lastModifiedTime"] = tj.LastModifiedTime + } + if tj.LastStatusModifiedTime != nil { + objectMap["lastStatusModifiedTime"] = tj.LastStatusModifiedTime + } + if tj.Parameters != nil { + objectMap["parameters"] = tj.Parameters + } + if tj.LogActivityTrace != nil { + objectMap["logActivityTrace"] = tj.LogActivityTrace + } + return json.Marshal(objectMap) +} + +// TestJobCreateParameters the parameters supplied to the create test job operation. +type TestJobCreateParameters struct { + // Parameters - Gets or sets the parameters of the test job. + Parameters map[string]*string `json:"parameters"` + // RunOn - Gets or sets the runOn which specifies the group name where the job is to be executed. + RunOn *string `json:"runOn,omitempty"` +} + +// MarshalJSON is the custom marshaler for TestJobCreateParameters. +func (tjcp TestJobCreateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tjcp.Parameters != nil { + objectMap["parameters"] = tjcp.Parameters + } + if tjcp.RunOn != nil { + objectMap["runOn"] = tjcp.RunOn + } + return json.Marshal(objectMap) +} + +// TrackedResource the resource model definition for a ARM tracked top level resource +type TrackedResource struct { + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The Azure Region where the resource lives + Location *string `json:"location,omitempty"` + // ID - Fully qualified resource Id for the resource + ID *string `json:"id,omitempty"` + // Name - The name of the resource + Name *string `json:"name,omitempty"` + // Type - The type of the resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for TrackedResource. +func (tr TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tr.Tags != nil { + objectMap["tags"] = tr.Tags + } + if tr.Location != nil { + objectMap["location"] = tr.Location + } + if tr.ID != nil { + objectMap["id"] = tr.ID + } + if tr.Name != nil { + objectMap["name"] = tr.Name + } + if tr.Type != nil { + objectMap["type"] = tr.Type + } + return json.Marshal(objectMap) +} + +// TypeField information about a field of a type. +type TypeField struct { + // Name - Gets or sets the name of the field. + Name *string `json:"name,omitempty"` + // Type - Gets or sets the type of the field. + Type *string `json:"type,omitempty"` +} + +// TypeFieldListResult the response model for the list fields operation. +type TypeFieldListResult struct { + autorest.Response `json:"-"` + // Value - Gets or sets a list of fields. + Value *[]TypeField `json:"value,omitempty"` +} + +// UpdateConfiguration update specifc properties of the software update configuration. +type UpdateConfiguration struct { + // OperatingSystem - operating system of target machines. Possible values include: 'Windows', 'Linux' + OperatingSystem OperatingSystemType `json:"operatingSystem,omitempty"` + // Windows - Windows specific update configuration. + Windows *WindowsProperties `json:"windows,omitempty"` + // Linux - Linux specific update configuration. + Linux *LinuxProperties `json:"linux,omitempty"` + // Duration - Maximum time allowed for the software update configuration run. Duration needs to be specified using the format PT[n]H[n]M[n]S as per ISO8601 + Duration *string `json:"duration,omitempty"` + // AzureVirtualMachines - List of azure resource Ids for azure virtual machines targeted by the software update configuration. + AzureVirtualMachines *[]string `json:"azureVirtualMachines,omitempty"` + // NonAzureComputerNames - List of names of non-azure machines targeted by the software update configuration. + NonAzureComputerNames *[]string `json:"nonAzureComputerNames,omitempty"` + // Targets - Group targets for the software update configuration. + Targets *TargetProperties `json:"targets,omitempty"` +} + +// UpdateConfigurationMachineRunProperties software update configuration machine run properties. +type UpdateConfigurationMachineRunProperties struct { + // TargetComputer - name of the updated computer + TargetComputer *string `json:"targetComputer,omitempty"` + // TargetComputerType - type of the updated computer. + TargetComputerType *string `json:"targetComputerType,omitempty"` + // SoftwareUpdateConfiguration - software update configuration triggered this run + SoftwareUpdateConfiguration *UpdateConfigurationNavigation `json:"softwareUpdateConfiguration,omitempty"` + // Status - Status of the software update configuration machine run. + Status *string `json:"status,omitempty"` + // OsType - Operating system target of the software update configuration triggered this run + OsType *string `json:"osType,omitempty"` + // CorrelationID - correlation id of the software update configuration machine run + CorrelationID *uuid.UUID `json:"correlationId,omitempty"` + // SourceComputerID - source computer id of the software update configuration machine run + SourceComputerID *uuid.UUID `json:"sourceComputerId,omitempty"` + // StartTime - Start time of the software update configuration machine run. + StartTime *date.Time `json:"startTime,omitempty"` + // EndTime - End time of the software update configuration machine run. + EndTime *date.Time `json:"endTime,omitempty"` + // ConfiguredDuration - configured duration for the software update configuration run. + ConfiguredDuration *string `json:"configuredDuration,omitempty"` + // Job - Job associated with the software update configuration machine run + Job *JobNavigation `json:"job,omitempty"` + // CreationTime - Creation time of theresource, which only appears in the response. + CreationTime *date.Time `json:"creationTime,omitempty"` + // CreatedBy - createdBy property, which only appears in the response. + CreatedBy *string `json:"createdBy,omitempty"` + // LastModifiedTime - Last time resource was modified, which only appears in the response. + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + // LastModifiedBy - lastModifiedBy property, which only appears in the response. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` +} + +// UpdateConfigurationNavigation software update configuration Run Navigation model. +type UpdateConfigurationNavigation struct { + // Name - Name of the software update configuration triggered the software update configuration run + Name *string `json:"name,omitempty"` +} + +// Usage definition of Usage. +type Usage struct { + // ID - Gets or sets the id of the resource. + ID *string `json:"id,omitempty"` + // Name - Gets or sets the usage counter name. + Name *UsageCounterName `json:"name,omitempty"` + // Unit - Gets or sets the usage unit name. + Unit *string `json:"unit,omitempty"` + // CurrentValue - Gets or sets the current usage value. + CurrentValue *float64 `json:"currentValue,omitempty"` + // Limit - Gets or sets max limit. -1 for unlimited + Limit *int64 `json:"limit,omitempty"` + // ThrottleStatus - Gets or sets the throttle status. + ThrottleStatus *string `json:"throttleStatus,omitempty"` +} + +// UsageCounterName definition of usage counter name. +type UsageCounterName struct { + // Value - Gets or sets the usage counter name. + Value *string `json:"value,omitempty"` + // LocalizedValue - Gets or sets the localized usage counter name. + LocalizedValue *string `json:"localizedValue,omitempty"` +} + +// UsageListResult the response model for the get usage operation. +type UsageListResult struct { + autorest.Response `json:"-"` + // Value - Gets or sets usage. + Value *[]Usage `json:"value,omitempty"` +} + +// Variable definition of the varible. +type Variable struct { + autorest.Response `json:"-"` + // VariableProperties - Gets or sets the properties of the variable. + *VariableProperties `json:"properties,omitempty"` + // ID - Fully qualified resource Id for the resource + ID *string `json:"id,omitempty"` + // Name - The name of the resource + Name *string `json:"name,omitempty"` + // Type - The type of the resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Variable. +func (vVar Variable) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if vVar.VariableProperties != nil { + objectMap["properties"] = vVar.VariableProperties + } + if vVar.ID != nil { + objectMap["id"] = vVar.ID + } + if vVar.Name != nil { + objectMap["name"] = vVar.Name + } + if vVar.Type != nil { + objectMap["type"] = vVar.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Variable struct. +func (vVar *Variable) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var variableProperties VariableProperties + err = json.Unmarshal(*v, &variableProperties) + if err != nil { + return err + } + vVar.VariableProperties = &variableProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + vVar.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + vVar.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + vVar.Type = &typeVar + } + } + } + + return nil +} + +// VariableCreateOrUpdateParameters the parameters supplied to the create or update variable operation. +type VariableCreateOrUpdateParameters struct { + // Name - Gets or sets the name of the variable. + Name *string `json:"name,omitempty"` + // VariableCreateOrUpdateProperties - Gets or sets the properties of the variable. + *VariableCreateOrUpdateProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for VariableCreateOrUpdateParameters. +func (vcoup VariableCreateOrUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if vcoup.Name != nil { + objectMap["name"] = vcoup.Name + } + if vcoup.VariableCreateOrUpdateProperties != nil { + objectMap["properties"] = vcoup.VariableCreateOrUpdateProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for VariableCreateOrUpdateParameters struct. +func (vcoup *VariableCreateOrUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + vcoup.Name = &name + } + case "properties": + if v != nil { + var variableCreateOrUpdateProperties VariableCreateOrUpdateProperties + err = json.Unmarshal(*v, &variableCreateOrUpdateProperties) + if err != nil { + return err + } + vcoup.VariableCreateOrUpdateProperties = &variableCreateOrUpdateProperties + } + } + } + + return nil +} + +// VariableCreateOrUpdateProperties the properties of the create variable operation. +type VariableCreateOrUpdateProperties struct { + // Value - Gets or sets the value of the variable. + Value *string `json:"value,omitempty"` + // Description - Gets or sets the description of the variable. + Description *string `json:"description,omitempty"` + // IsEncrypted - Gets or sets the encrypted flag of the variable. + IsEncrypted *bool `json:"isEncrypted,omitempty"` +} + +// VariableListResult the response model for the list variables operation. +type VariableListResult struct { + autorest.Response `json:"-"` + // Value - Gets or sets a list of variables. + Value *[]Variable `json:"value,omitempty"` + // NextLink - Gets or sets the next link. + NextLink *string `json:"nextLink,omitempty"` +} + +// VariableListResultIterator provides access to a complete listing of Variable values. +type VariableListResultIterator struct { + i int + page VariableListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *VariableListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter VariableListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter VariableListResultIterator) Response() VariableListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter VariableListResultIterator) Value() Variable { + if !iter.page.NotDone() { + return Variable{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (vlr VariableListResult) IsEmpty() bool { + return vlr.Value == nil || len(*vlr.Value) == 0 +} + +// variableListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (vlr VariableListResult) variableListResultPreparer() (*http.Request, error) { + if vlr.NextLink == nil || len(to.String(vlr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(vlr.NextLink))) +} + +// VariableListResultPage contains a page of Variable values. +type VariableListResultPage struct { + fn func(VariableListResult) (VariableListResult, error) + vlr VariableListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *VariableListResultPage) Next() error { + next, err := page.fn(page.vlr) + if err != nil { + return err + } + page.vlr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page VariableListResultPage) NotDone() bool { + return !page.vlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page VariableListResultPage) Response() VariableListResult { + return page.vlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page VariableListResultPage) Values() []Variable { + if page.vlr.IsEmpty() { + return nil + } + return *page.vlr.Value +} + +// VariableProperties definition of the varible properties +type VariableProperties struct { + // Value - Gets or sets the value of the variable. + Value *string `json:"value,omitempty"` + // IsEncrypted - Gets or sets the encrypted flag of the variable. + IsEncrypted *bool `json:"isEncrypted,omitempty"` + // CreationTime - Gets or sets the creation time. + CreationTime *date.Time `json:"creationTime,omitempty"` + // LastModifiedTime - Gets or sets the last modified time. + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + // Description - Gets or sets the description. + Description *string `json:"description,omitempty"` +} + +// VariableUpdateParameters the parameters supplied to the update variable operation. +type VariableUpdateParameters struct { + // Name - Gets or sets the name of the variable. + Name *string `json:"name,omitempty"` + // VariableUpdateProperties - Gets or sets the value of the variable. + *VariableUpdateProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for VariableUpdateParameters. +func (vup VariableUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if vup.Name != nil { + objectMap["name"] = vup.Name + } + if vup.VariableUpdateProperties != nil { + objectMap["properties"] = vup.VariableUpdateProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for VariableUpdateParameters struct. +func (vup *VariableUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + vup.Name = &name + } + case "properties": + if v != nil { + var variableUpdateProperties VariableUpdateProperties + err = json.Unmarshal(*v, &variableUpdateProperties) + if err != nil { + return err + } + vup.VariableUpdateProperties = &variableUpdateProperties + } + } + } + + return nil +} + +// VariableUpdateProperties the properties of the update variable +type VariableUpdateProperties struct { + // Value - Gets or sets the value of the variable. + Value *string `json:"value,omitempty"` + // Description - Gets or sets the description of the variable. + Description *string `json:"description,omitempty"` +} + +// Watcher definition of the watcher type. +type Watcher struct { + autorest.Response `json:"-"` + // WatcherProperties - Gets or sets the watcher properties. + *WatcherProperties `json:"properties,omitempty"` + // Etag - Gets or sets the etag of the resource. + Etag *string `json:"etag,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The Azure Region where the resource lives + Location *string `json:"location,omitempty"` + // ID - Fully qualified resource Id for the resource + ID *string `json:"id,omitempty"` + // Name - The name of the resource + Name *string `json:"name,omitempty"` + // Type - The type of the resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Watcher. +func (w Watcher) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if w.WatcherProperties != nil { + objectMap["properties"] = w.WatcherProperties + } + if w.Etag != nil { + objectMap["etag"] = w.Etag + } + if w.Tags != nil { + objectMap["tags"] = w.Tags + } + if w.Location != nil { + objectMap["location"] = w.Location + } + if w.ID != nil { + objectMap["id"] = w.ID + } + if w.Name != nil { + objectMap["name"] = w.Name + } + if w.Type != nil { + objectMap["type"] = w.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Watcher struct. +func (w *Watcher) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var watcherProperties WatcherProperties + err = json.Unmarshal(*v, &watcherProperties) + if err != nil { + return err + } + w.WatcherProperties = &watcherProperties + } + case "etag": + if v != nil { + var etag string + err = json.Unmarshal(*v, &etag) + if err != nil { + return err + } + w.Etag = &etag + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + w.Tags = tags + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + w.Location = &location + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + w.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + w.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + w.Type = &typeVar + } + } + } + + return nil +} + +// WatcherListResult the response model for the list watcher operation. +type WatcherListResult struct { + autorest.Response `json:"-"` + // Value - Gets or sets a list of watchers. + Value *[]Watcher `json:"value,omitempty"` + // NextLink - Gets or sets the next link. + NextLink *string `json:"nextLink,omitempty"` +} + +// WatcherListResultIterator provides access to a complete listing of Watcher values. +type WatcherListResultIterator struct { + i int + page WatcherListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *WatcherListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter WatcherListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter WatcherListResultIterator) Response() WatcherListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter WatcherListResultIterator) Value() Watcher { + if !iter.page.NotDone() { + return Watcher{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (wlr WatcherListResult) IsEmpty() bool { + return wlr.Value == nil || len(*wlr.Value) == 0 +} + +// watcherListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (wlr WatcherListResult) watcherListResultPreparer() (*http.Request, error) { + if wlr.NextLink == nil || len(to.String(wlr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(wlr.NextLink))) +} + +// WatcherListResultPage contains a page of Watcher values. +type WatcherListResultPage struct { + fn func(WatcherListResult) (WatcherListResult, error) + wlr WatcherListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *WatcherListResultPage) Next() error { + next, err := page.fn(page.wlr) + if err != nil { + return err + } + page.wlr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page WatcherListResultPage) NotDone() bool { + return !page.wlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page WatcherListResultPage) Response() WatcherListResult { + return page.wlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page WatcherListResultPage) Values() []Watcher { + if page.wlr.IsEmpty() { + return nil + } + return *page.wlr.Value +} + +// WatcherProperties definition of the watcher properties +type WatcherProperties struct { + // ExecutionFrequencyInSeconds - Gets or sets the frequency at which the watcher is invoked. + ExecutionFrequencyInSeconds *int64 `json:"executionFrequencyInSeconds,omitempty"` + // ScriptName - Gets or sets the name of the script the watcher is attached to, i.e. the name of an existing runbook. + ScriptName *string `json:"scriptName,omitempty"` + // ScriptParameters - Gets or sets the parameters of the script. + ScriptParameters map[string]*string `json:"scriptParameters"` + // ScriptRunOn - Gets or sets the name of the hybrid worker group the watcher will run on. + ScriptRunOn *string `json:"scriptRunOn,omitempty"` + // Status - Gets the current status of the watcher. + Status *string `json:"status,omitempty"` + // CreationTime - Gets or sets the creation time. + CreationTime *date.Time `json:"creationTime,omitempty"` + // LastModifiedTime - Gets or sets the last modified time. + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + // LastModifiedBy - Details of the user who last modified the watcher. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + // Description - Gets or sets the description. + Description *string `json:"description,omitempty"` +} + +// MarshalJSON is the custom marshaler for WatcherProperties. +func (wp WatcherProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if wp.ExecutionFrequencyInSeconds != nil { + objectMap["executionFrequencyInSeconds"] = wp.ExecutionFrequencyInSeconds + } + if wp.ScriptName != nil { + objectMap["scriptName"] = wp.ScriptName + } + if wp.ScriptParameters != nil { + objectMap["scriptParameters"] = wp.ScriptParameters + } + if wp.ScriptRunOn != nil { + objectMap["scriptRunOn"] = wp.ScriptRunOn + } + if wp.Status != nil { + objectMap["status"] = wp.Status + } + if wp.CreationTime != nil { + objectMap["creationTime"] = wp.CreationTime + } + if wp.LastModifiedTime != nil { + objectMap["lastModifiedTime"] = wp.LastModifiedTime + } + if wp.LastModifiedBy != nil { + objectMap["lastModifiedBy"] = wp.LastModifiedBy + } + if wp.Description != nil { + objectMap["description"] = wp.Description + } + return json.Marshal(objectMap) +} + +// WatcherUpdateParameters ... +type WatcherUpdateParameters struct { + // WatcherUpdateProperties - Gets or sets the watcher update properties. + *WatcherUpdateProperties `json:"properties,omitempty"` + // Name - Gets or sets the name of the resource. + Name *string `json:"name,omitempty"` +} + +// MarshalJSON is the custom marshaler for WatcherUpdateParameters. +func (wup WatcherUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if wup.WatcherUpdateProperties != nil { + objectMap["properties"] = wup.WatcherUpdateProperties + } + if wup.Name != nil { + objectMap["name"] = wup.Name + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for WatcherUpdateParameters struct. +func (wup *WatcherUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var watcherUpdateProperties WatcherUpdateProperties + err = json.Unmarshal(*v, &watcherUpdateProperties) + if err != nil { + return err + } + wup.WatcherUpdateProperties = &watcherUpdateProperties + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + wup.Name = &name + } + } + } + + return nil +} + +// WatcherUpdateProperties the properties of the update watcher operation. +type WatcherUpdateProperties struct { + // ExecutionFrequencyInSeconds - Gets or sets the frequency at which the watcher is invoked. + ExecutionFrequencyInSeconds *int64 `json:"executionFrequencyInSeconds,omitempty"` +} + +// Webhook definition of the webhook type. +type Webhook struct { + autorest.Response `json:"-"` + // WebhookProperties - Gets or sets the webhook properties. + *WebhookProperties `json:"properties,omitempty"` + // ID - Fully qualified resource Id for the resource + ID *string `json:"id,omitempty"` + // Name - The name of the resource + Name *string `json:"name,omitempty"` + // Type - The type of the resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Webhook. +func (w Webhook) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if w.WebhookProperties != nil { + objectMap["properties"] = w.WebhookProperties + } + if w.ID != nil { + objectMap["id"] = w.ID + } + if w.Name != nil { + objectMap["name"] = w.Name + } + if w.Type != nil { + objectMap["type"] = w.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Webhook struct. +func (w *Webhook) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var webhookProperties WebhookProperties + err = json.Unmarshal(*v, &webhookProperties) + if err != nil { + return err + } + w.WebhookProperties = &webhookProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + w.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + w.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + w.Type = &typeVar + } + } + } + + return nil +} + +// WebhookCreateOrUpdateParameters the parameters supplied to the create or update webhook operation. +type WebhookCreateOrUpdateParameters struct { + // Name - Gets or sets the name of the webhook. + Name *string `json:"name,omitempty"` + // WebhookCreateOrUpdateProperties - Gets or sets the properties of the webhook. + *WebhookCreateOrUpdateProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for WebhookCreateOrUpdateParameters. +func (wcoup WebhookCreateOrUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if wcoup.Name != nil { + objectMap["name"] = wcoup.Name + } + if wcoup.WebhookCreateOrUpdateProperties != nil { + objectMap["properties"] = wcoup.WebhookCreateOrUpdateProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for WebhookCreateOrUpdateParameters struct. +func (wcoup *WebhookCreateOrUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + wcoup.Name = &name + } + case "properties": + if v != nil { + var webhookCreateOrUpdateProperties WebhookCreateOrUpdateProperties + err = json.Unmarshal(*v, &webhookCreateOrUpdateProperties) + if err != nil { + return err + } + wcoup.WebhookCreateOrUpdateProperties = &webhookCreateOrUpdateProperties + } + } + } + + return nil +} + +// WebhookCreateOrUpdateProperties the properties of the create webhook operation. +type WebhookCreateOrUpdateProperties struct { + // IsEnabled - Gets or sets the value of the enabled flag of webhook. + IsEnabled *bool `json:"isEnabled,omitempty"` + // URI - Gets or sets the uri. + URI *string `json:"uri,omitempty"` + // ExpiryTime - Gets or sets the expiry time. + ExpiryTime *date.Time `json:"expiryTime,omitempty"` + // Parameters - Gets or sets the parameters of the job. + Parameters map[string]*string `json:"parameters"` + // Runbook - Gets or sets the runbook. + Runbook *RunbookAssociationProperty `json:"runbook,omitempty"` + // RunOn - Gets or sets the name of the hybrid worker group the webhook job will run on. + RunOn *string `json:"runOn,omitempty"` +} + +// MarshalJSON is the custom marshaler for WebhookCreateOrUpdateProperties. +func (wcoup WebhookCreateOrUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if wcoup.IsEnabled != nil { + objectMap["isEnabled"] = wcoup.IsEnabled + } + if wcoup.URI != nil { + objectMap["uri"] = wcoup.URI + } + if wcoup.ExpiryTime != nil { + objectMap["expiryTime"] = wcoup.ExpiryTime + } + if wcoup.Parameters != nil { + objectMap["parameters"] = wcoup.Parameters + } + if wcoup.Runbook != nil { + objectMap["runbook"] = wcoup.Runbook + } + if wcoup.RunOn != nil { + objectMap["runOn"] = wcoup.RunOn + } + return json.Marshal(objectMap) +} + +// WebhookListResult the response model for the list webhook operation. +type WebhookListResult struct { + autorest.Response `json:"-"` + // Value - Gets or sets a list of webhooks. + Value *[]Webhook `json:"value,omitempty"` + // NextLink - Gets or sets the next link. + NextLink *string `json:"nextLink,omitempty"` +} + +// WebhookListResultIterator provides access to a complete listing of Webhook values. +type WebhookListResultIterator struct { + i int + page WebhookListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *WebhookListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter WebhookListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter WebhookListResultIterator) Response() WebhookListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter WebhookListResultIterator) Value() Webhook { + if !iter.page.NotDone() { + return Webhook{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (wlr WebhookListResult) IsEmpty() bool { + return wlr.Value == nil || len(*wlr.Value) == 0 +} + +// webhookListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (wlr WebhookListResult) webhookListResultPreparer() (*http.Request, error) { + if wlr.NextLink == nil || len(to.String(wlr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(wlr.NextLink))) +} + +// WebhookListResultPage contains a page of Webhook values. +type WebhookListResultPage struct { + fn func(WebhookListResult) (WebhookListResult, error) + wlr WebhookListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *WebhookListResultPage) Next() error { + next, err := page.fn(page.wlr) + if err != nil { + return err + } + page.wlr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page WebhookListResultPage) NotDone() bool { + return !page.wlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page WebhookListResultPage) Response() WebhookListResult { + return page.wlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page WebhookListResultPage) Values() []Webhook { + if page.wlr.IsEmpty() { + return nil + } + return *page.wlr.Value +} + +// WebhookProperties definition of the webhook properties +type WebhookProperties struct { + // IsEnabled - Gets or sets the value of the enabled flag of the webhook. + IsEnabled *bool `json:"isEnabled,omitempty"` + // URI - Gets or sets the webhook uri. + URI *string `json:"uri,omitempty"` + // ExpiryTime - Gets or sets the expiry time. + ExpiryTime *date.Time `json:"expiryTime,omitempty"` + // LastInvokedTime - Gets or sets the last invoked time. + LastInvokedTime *date.Time `json:"lastInvokedTime,omitempty"` + // Parameters - Gets or sets the parameters of the job that is created when the webhook calls the runbook it is associated with. + Parameters map[string]*string `json:"parameters"` + // Runbook - Gets or sets the runbook the webhook is associated with. + Runbook *RunbookAssociationProperty `json:"runbook,omitempty"` + // RunOn - Gets or sets the name of the hybrid worker group the webhook job will run on. + RunOn *string `json:"runOn,omitempty"` + // CreationTime - Gets or sets the creation time. + CreationTime *date.Time `json:"creationTime,omitempty"` + // LastModifiedTime - Gets or sets the last modified time. + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + // LastModifiedBy - Details of the user who last modified the Webhook + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + // Description - Gets or sets the description. + Description *string `json:"description,omitempty"` +} + +// MarshalJSON is the custom marshaler for WebhookProperties. +func (wp WebhookProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if wp.IsEnabled != nil { + objectMap["isEnabled"] = wp.IsEnabled + } + if wp.URI != nil { + objectMap["uri"] = wp.URI + } + if wp.ExpiryTime != nil { + objectMap["expiryTime"] = wp.ExpiryTime + } + if wp.LastInvokedTime != nil { + objectMap["lastInvokedTime"] = wp.LastInvokedTime + } + if wp.Parameters != nil { + objectMap["parameters"] = wp.Parameters + } + if wp.Runbook != nil { + objectMap["runbook"] = wp.Runbook + } + if wp.RunOn != nil { + objectMap["runOn"] = wp.RunOn + } + if wp.CreationTime != nil { + objectMap["creationTime"] = wp.CreationTime + } + if wp.LastModifiedTime != nil { + objectMap["lastModifiedTime"] = wp.LastModifiedTime + } + if wp.LastModifiedBy != nil { + objectMap["lastModifiedBy"] = wp.LastModifiedBy + } + if wp.Description != nil { + objectMap["description"] = wp.Description + } + return json.Marshal(objectMap) +} + +// WebhookUpdateParameters the parameters supplied to the update webhook operation. +type WebhookUpdateParameters struct { + // Name - Gets or sets the name of the webhook. + Name *string `json:"name,omitempty"` + // WebhookUpdateProperties - Gets or sets the value of the webhook. + *WebhookUpdateProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for WebhookUpdateParameters. +func (wup WebhookUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if wup.Name != nil { + objectMap["name"] = wup.Name + } + if wup.WebhookUpdateProperties != nil { + objectMap["properties"] = wup.WebhookUpdateProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for WebhookUpdateParameters struct. +func (wup *WebhookUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + wup.Name = &name + } + case "properties": + if v != nil { + var webhookUpdateProperties WebhookUpdateProperties + err = json.Unmarshal(*v, &webhookUpdateProperties) + if err != nil { + return err + } + wup.WebhookUpdateProperties = &webhookUpdateProperties + } + } + } + + return nil +} + +// WebhookUpdateProperties the properties of the update webhook. +type WebhookUpdateProperties struct { + // IsEnabled - Gets or sets the value of the enabled flag of webhook. + IsEnabled *bool `json:"isEnabled,omitempty"` + // RunOn - Gets or sets the name of the hybrid worker group the webhook job will run on. + RunOn *string `json:"runOn,omitempty"` + // Parameters - Gets or sets the parameters of the job. + Parameters map[string]*string `json:"parameters"` + // Description - Gets or sets the description of the webhook. + Description *string `json:"description,omitempty"` +} + +// MarshalJSON is the custom marshaler for WebhookUpdateProperties. +func (wup WebhookUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if wup.IsEnabled != nil { + objectMap["isEnabled"] = wup.IsEnabled + } + if wup.RunOn != nil { + objectMap["runOn"] = wup.RunOn + } + if wup.Parameters != nil { + objectMap["parameters"] = wup.Parameters + } + if wup.Description != nil { + objectMap["description"] = wup.Description + } + return json.Marshal(objectMap) +} + +// WindowsProperties windows specific update configuration. +type WindowsProperties struct { + // IncludedUpdateClassifications - Update classification included in the software update configuration. A comma separated string with required values. Possible values include: 'WindowsUpdateClassesUnclassified', 'WindowsUpdateClassesCritical', 'WindowsUpdateClassesSecurity', 'WindowsUpdateClassesUpdateRollup', 'WindowsUpdateClassesFeaturePack', 'WindowsUpdateClassesServicePack', 'WindowsUpdateClassesDefinition', 'WindowsUpdateClassesTools', 'WindowsUpdateClassesUpdates' + IncludedUpdateClassifications WindowsUpdateClasses `json:"includedUpdateClassifications,omitempty"` + // ExcludedKbNumbers - KB numbers excluded from the software update configuration. + ExcludedKbNumbers *[]string `json:"excludedKbNumbers,omitempty"` + // IncludedKbNumbers - KB numbers included from the software update configuration. + IncludedKbNumbers *[]string `json:"includedKbNumbers,omitempty"` + // RebootSetting - Reboot setting for the software update configuration. + RebootSetting *string `json:"rebootSetting,omitempty"` +} diff --git a/services/preview/automation/mgmt/2018-01-15-preview/automation/module.go b/services/preview/automation/mgmt/2018-01-15-preview/automation/module.go new file mode 100644 index 000000000000..5c7a761c1936 --- /dev/null +++ b/services/preview/automation/mgmt/2018-01-15-preview/automation/module.go @@ -0,0 +1,466 @@ +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" +) + +// ModuleClient is the automation Client +type ModuleClient struct { + BaseClient +} + +// NewModuleClient creates an instance of the ModuleClient client. +func NewModuleClient(subscriptionID string, countType1 CountType) ModuleClient { + return NewModuleClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewModuleClientWithBaseURI creates an instance of the ModuleClient client. +func NewModuleClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) ModuleClient { + return ModuleClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// CreateOrUpdate create or Update the module identified by module name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// moduleName - the name of module. +// parameters - the create or update parameters for module. +func (client ModuleClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, automationAccountName string, moduleName string, parameters ModuleCreateOrUpdateParameters) (result Module, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.ModuleCreateOrUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ModuleCreateOrUpdateProperties.ContentLink", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ModuleCreateOrUpdateProperties.ContentLink.ContentHash", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ModuleCreateOrUpdateProperties.ContentLink.ContentHash.Algorithm", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ModuleCreateOrUpdateProperties.ContentLink.ContentHash.Value", Name: validation.Null, Rule: true, Chain: nil}, + }}, + }}, + }}}}}); err != nil { + return result, validation.NewError("automation.ModuleClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, automationAccountName, moduleName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ModuleClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, moduleName string, parameters ModuleCreateOrUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "moduleName": autorest.Encode("path", moduleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ModuleClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ModuleClient) CreateOrUpdateResponder(resp *http.Response) (result Module, 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 delete the module by name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// moduleName - the module name. +func (client ModuleClient) Delete(ctx context.Context, resourceGroupName string, automationAccountName string, moduleName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.ModuleClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, automationAccountName, moduleName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ModuleClient) DeletePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, moduleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "moduleName": autorest.Encode("path", moduleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ModuleClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ModuleClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get retrieve the module identified by module name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// moduleName - the module name. +func (client ModuleClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string, moduleName string) (result Module, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.ModuleClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName, moduleName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ModuleClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, moduleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "moduleName": autorest.Encode("path", moduleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ModuleClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ModuleClient) GetResponder(resp *http.Response) (result Module, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of modules. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +func (client ModuleClient) ListByAutomationAccount(ctx context.Context, resourceGroupName string, automationAccountName string) (result ModuleListResultPage, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.ModuleClient", "ListByAutomationAccount", err.Error()) + } + + result.fn = client.listByAutomationAccountNextResults + req, err := client.ListByAutomationAccountPreparer(ctx, resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.mlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result.mlr, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client ModuleClient) ListByAutomationAccountPreparer(ctx context.Context, resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules", 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 ModuleClient) 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 ModuleClient) ListByAutomationAccountResponder(resp *http.Response) (result ModuleListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByAutomationAccountNextResults retrieves the next set of results, if any. +func (client ModuleClient) listByAutomationAccountNextResults(lastResults ModuleListResult) (result ModuleListResult, err error) { + req, err := lastResults.moduleListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.ModuleClient", "listByAutomationAccountNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.ModuleClient", "listByAutomationAccountNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "listByAutomationAccountNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByAutomationAccountComplete enumerates all values, automatically crossing page boundaries as required. +func (client ModuleClient) ListByAutomationAccountComplete(ctx context.Context, resourceGroupName string, automationAccountName string) (result ModuleListResultIterator, err error) { + result.page, err = client.ListByAutomationAccount(ctx, resourceGroupName, automationAccountName) + return +} + +// Update update the module identified by module name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// moduleName - the name of module. +// parameters - the update parameters for module. +func (client ModuleClient) Update(ctx context.Context, resourceGroupName string, automationAccountName string, moduleName string, parameters ModuleUpdateParameters) (result Module, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.ModuleClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, automationAccountName, moduleName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ModuleClient) UpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, moduleName string, parameters ModuleUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "moduleName": autorest.Encode("path", moduleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client ModuleClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ModuleClient) UpdateResponder(resp *http.Response) (result Module, 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/preview/automation/mgmt/2018-01-15-preview/automation/nodecountinformation.go b/services/preview/automation/mgmt/2018-01-15-preview/automation/nodecountinformation.go new file mode 100644 index 000000000000..4227722e39d2 --- /dev/null +++ b/services/preview/automation/mgmt/2018-01-15-preview/automation/nodecountinformation.go @@ -0,0 +1,117 @@ +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" +) + +// NodeCountInformationClient is the automation Client +type NodeCountInformationClient struct { + BaseClient +} + +// NewNodeCountInformationClient creates an instance of the NodeCountInformationClient client. +func NewNodeCountInformationClient(subscriptionID string, countType1 CountType) NodeCountInformationClient { + return NewNodeCountInformationClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewNodeCountInformationClientWithBaseURI creates an instance of the NodeCountInformationClient client. +func NewNodeCountInformationClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) NodeCountInformationClient { + return NodeCountInformationClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// Get retrieve counts for Dsc Nodes. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +func (client NodeCountInformationClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string) (result NodeCounts, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.NodeCountInformationClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.NodeCountInformationClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.NodeCountInformationClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.NodeCountInformationClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client NodeCountInformationClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "countType": autorest.Encode("path", client.CountType1), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-01-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodecounts/{countType}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client NodeCountInformationClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client NodeCountInformationClient) GetResponder(resp *http.Response) (result NodeCounts, 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/preview/automation/mgmt/2018-01-15-preview/automation/nodereports.go b/services/preview/automation/mgmt/2018-01-15-preview/automation/nodereports.go new file mode 100644 index 000000000000..a6c3428b4af9 --- /dev/null +++ b/services/preview/automation/mgmt/2018-01-15-preview/automation/nodereports.go @@ -0,0 +1,308 @@ +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" +) + +// NodeReportsClient is the automation Client +type NodeReportsClient struct { + BaseClient +} + +// NewNodeReportsClient creates an instance of the NodeReportsClient client. +func NewNodeReportsClient(subscriptionID string, countType1 CountType) NodeReportsClient { + return NewNodeReportsClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewNodeReportsClientWithBaseURI creates an instance of the NodeReportsClient client. +func NewNodeReportsClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) NodeReportsClient { + return NodeReportsClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// Get retrieve the Dsc node report data by node id and report id. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// nodeID - the Dsc node id. +// reportID - the report id. +func (client NodeReportsClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string, nodeID string, reportID string) (result DscNodeReport, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.NodeReportsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName, nodeID, reportID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.NodeReportsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.NodeReportsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.NodeReportsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client NodeReportsClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, nodeID string, reportID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "nodeId": autorest.Encode("path", nodeID), + "reportId": autorest.Encode("path", reportID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-01-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}/reports/{reportId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client NodeReportsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client NodeReportsClient) GetResponder(resp *http.Response) (result DscNodeReport, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetContent retrieve the Dsc node reports by node id and report id. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// nodeID - the Dsc node id. +// reportID - the report id. +func (client NodeReportsClient) GetContent(ctx context.Context, resourceGroupName string, automationAccountName string, nodeID string, reportID string) (result SetObject, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.NodeReportsClient", "GetContent", err.Error()) + } + + req, err := client.GetContentPreparer(ctx, resourceGroupName, automationAccountName, nodeID, reportID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.NodeReportsClient", "GetContent", nil, "Failure preparing request") + return + } + + resp, err := client.GetContentSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.NodeReportsClient", "GetContent", resp, "Failure sending request") + return + } + + result, err = client.GetContentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.NodeReportsClient", "GetContent", resp, "Failure responding to request") + } + + return +} + +// GetContentPreparer prepares the GetContent request. +func (client NodeReportsClient) GetContentPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, nodeID string, reportID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "nodeId": autorest.Encode("path", nodeID), + "reportId": autorest.Encode("path", reportID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-01-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}/reports/{reportId}/content", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetContentSender sends the GetContent request. The method will close the +// http.Response Body if it receives an error. +func (client NodeReportsClient) GetContentSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetContentResponder handles the response to the GetContent request. The method always +// closes the http.Response Body. +func (client NodeReportsClient) GetContentResponder(resp *http.Response) (result SetObject, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Value), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByNode retrieve the Dsc node report list by node id. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// nodeID - the parameters supplied to the list operation. +// filter - the filter to apply on the operation. +func (client NodeReportsClient) ListByNode(ctx context.Context, resourceGroupName string, automationAccountName string, nodeID string, filter string) (result DscNodeReportListResultPage, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.NodeReportsClient", "ListByNode", err.Error()) + } + + result.fn = client.listByNodeNextResults + req, err := client.ListByNodePreparer(ctx, resourceGroupName, automationAccountName, nodeID, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.NodeReportsClient", "ListByNode", nil, "Failure preparing request") + return + } + + resp, err := client.ListByNodeSender(req) + if err != nil { + result.dnrlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.NodeReportsClient", "ListByNode", resp, "Failure sending request") + return + } + + result.dnrlr, err = client.ListByNodeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.NodeReportsClient", "ListByNode", resp, "Failure responding to request") + } + + return +} + +// ListByNodePreparer prepares the ListByNode request. +func (client NodeReportsClient) ListByNodePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, nodeID string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "nodeId": autorest.Encode("path", nodeID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-01-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}/reports", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByNodeSender sends the ListByNode request. The method will close the +// http.Response Body if it receives an error. +func (client NodeReportsClient) ListByNodeSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByNodeResponder handles the response to the ListByNode request. The method always +// closes the http.Response Body. +func (client NodeReportsClient) ListByNodeResponder(resp *http.Response) (result DscNodeReportListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByNodeNextResults retrieves the next set of results, if any. +func (client NodeReportsClient) listByNodeNextResults(lastResults DscNodeReportListResult) (result DscNodeReportListResult, err error) { + req, err := lastResults.dscNodeReportListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.NodeReportsClient", "listByNodeNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByNodeSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.NodeReportsClient", "listByNodeNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByNodeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.NodeReportsClient", "listByNodeNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByNodeComplete enumerates all values, automatically crossing page boundaries as required. +func (client NodeReportsClient) ListByNodeComplete(ctx context.Context, resourceGroupName string, automationAccountName string, nodeID string, filter string) (result DscNodeReportListResultIterator, err error) { + result.page, err = client.ListByNode(ctx, resourceGroupName, automationAccountName, nodeID, filter) + return +} diff --git a/services/preview/automation/mgmt/2018-01-15-preview/automation/objectdatatypes.go b/services/preview/automation/mgmt/2018-01-15-preview/automation/objectdatatypes.go new file mode 100644 index 000000000000..6c6ebe8d3204 --- /dev/null +++ b/services/preview/automation/mgmt/2018-01-15-preview/automation/objectdatatypes.go @@ -0,0 +1,197 @@ +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" +) + +// ObjectDataTypesClient is the automation Client +type ObjectDataTypesClient struct { + BaseClient +} + +// NewObjectDataTypesClient creates an instance of the ObjectDataTypesClient client. +func NewObjectDataTypesClient(subscriptionID string, countType1 CountType) ObjectDataTypesClient { + return NewObjectDataTypesClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewObjectDataTypesClientWithBaseURI creates an instance of the ObjectDataTypesClient client. +func NewObjectDataTypesClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) ObjectDataTypesClient { + return ObjectDataTypesClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// ListFieldsByModuleAndType retrieve a list of fields of a given type identified by module name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// moduleName - the name of module. +// typeName - the name of type. +func (client ObjectDataTypesClient) ListFieldsByModuleAndType(ctx context.Context, resourceGroupName string, automationAccountName string, moduleName string, typeName string) (result TypeFieldListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.ObjectDataTypesClient", "ListFieldsByModuleAndType", err.Error()) + } + + req, err := client.ListFieldsByModuleAndTypePreparer(ctx, resourceGroupName, automationAccountName, moduleName, typeName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ObjectDataTypesClient", "ListFieldsByModuleAndType", nil, "Failure preparing request") + return + } + + resp, err := client.ListFieldsByModuleAndTypeSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ObjectDataTypesClient", "ListFieldsByModuleAndType", resp, "Failure sending request") + return + } + + result, err = client.ListFieldsByModuleAndTypeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ObjectDataTypesClient", "ListFieldsByModuleAndType", resp, "Failure responding to request") + } + + return +} + +// ListFieldsByModuleAndTypePreparer prepares the ListFieldsByModuleAndType request. +func (client ObjectDataTypesClient) ListFieldsByModuleAndTypePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, moduleName string, typeName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "moduleName": autorest.Encode("path", moduleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "typeName": autorest.Encode("path", typeName), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/objectDataTypes/{typeName}/fields", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListFieldsByModuleAndTypeSender sends the ListFieldsByModuleAndType request. The method will close the +// http.Response Body if it receives an error. +func (client ObjectDataTypesClient) ListFieldsByModuleAndTypeSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListFieldsByModuleAndTypeResponder handles the response to the ListFieldsByModuleAndType request. The method always +// closes the http.Response Body. +func (client ObjectDataTypesClient) ListFieldsByModuleAndTypeResponder(resp *http.Response) (result TypeFieldListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListFieldsByType retrieve a list of fields of a given type across all accessible modules. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// typeName - the name of type. +func (client ObjectDataTypesClient) ListFieldsByType(ctx context.Context, resourceGroupName string, automationAccountName string, typeName string) (result TypeFieldListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.ObjectDataTypesClient", "ListFieldsByType", err.Error()) + } + + req, err := client.ListFieldsByTypePreparer(ctx, resourceGroupName, automationAccountName, typeName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ObjectDataTypesClient", "ListFieldsByType", nil, "Failure preparing request") + return + } + + resp, err := client.ListFieldsByTypeSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ObjectDataTypesClient", "ListFieldsByType", resp, "Failure sending request") + return + } + + result, err = client.ListFieldsByTypeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ObjectDataTypesClient", "ListFieldsByType", resp, "Failure responding to request") + } + + return +} + +// ListFieldsByTypePreparer prepares the ListFieldsByType request. +func (client ObjectDataTypesClient) ListFieldsByTypePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, typeName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "typeName": autorest.Encode("path", typeName), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/objectDataTypes/{typeName}/fields", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListFieldsByTypeSender sends the ListFieldsByType request. The method will close the +// http.Response Body if it receives an error. +func (client ObjectDataTypesClient) ListFieldsByTypeSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListFieldsByTypeResponder handles the response to the ListFieldsByType request. The method always +// closes the http.Response Body. +func (client ObjectDataTypesClient) ListFieldsByTypeResponder(resp *http.Response) (result TypeFieldListResult, 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/preview/automation/mgmt/2018-01-15-preview/automation/operations.go b/services/preview/automation/mgmt/2018-01-15-preview/automation/operations.go new file mode 100644 index 000000000000..4423e8db5daf --- /dev/null +++ b/services/preview/automation/mgmt/2018-01-15-preview/automation/operations.go @@ -0,0 +1,98 @@ +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" + "net/http" +) + +// OperationsClient is the automation Client +type OperationsClient struct { + BaseClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string, countType1 CountType) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client. +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// List lists all of the available Automation REST API operations. +func (client OperationsClient) List(ctx context.Context) (result OperationListResult, err error) { + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.OperationsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.OperationsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Automation/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, 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/preview/automation/mgmt/2018-01-15-preview/automation/runbook.go b/services/preview/automation/mgmt/2018-01-15-preview/automation/runbook.go new file mode 100644 index 000000000000..18d9f3f23014 --- /dev/null +++ b/services/preview/automation/mgmt/2018-01-15-preview/automation/runbook.go @@ -0,0 +1,551 @@ +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" +) + +// RunbookClient is the automation Client +type RunbookClient struct { + BaseClient +} + +// NewRunbookClient creates an instance of the RunbookClient client. +func NewRunbookClient(subscriptionID string, countType1 CountType) RunbookClient { + return NewRunbookClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewRunbookClientWithBaseURI creates an instance of the RunbookClient client. +func NewRunbookClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) RunbookClient { + return RunbookClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// CreateOrUpdate create the runbook identified by runbook name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// runbookName - the runbook name. +// parameters - the create or update parameters for runbook. Provide either content link for a published +// runbook or draft, not both. +func (client RunbookClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string, parameters RunbookCreateOrUpdateParameters) (result Runbook, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.RunbookCreateOrUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.RunbookCreateOrUpdateProperties.Draft", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.RunbookCreateOrUpdateProperties.Draft.DraftContentLink", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.RunbookCreateOrUpdateProperties.Draft.DraftContentLink.ContentHash", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.RunbookCreateOrUpdateProperties.Draft.DraftContentLink.ContentHash.Algorithm", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.RunbookCreateOrUpdateProperties.Draft.DraftContentLink.ContentHash.Value", Name: validation.Null, Rule: true, Chain: nil}, + }}, + }}, + }}, + {Target: "parameters.RunbookCreateOrUpdateProperties.PublishContentLink", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.RunbookCreateOrUpdateProperties.PublishContentLink.ContentHash", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.RunbookCreateOrUpdateProperties.PublishContentLink.ContentHash.Algorithm", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.RunbookCreateOrUpdateProperties.PublishContentLink.ContentHash.Value", Name: validation.Null, Rule: true, Chain: nil}, + }}, + }}, + }}}}}); err != nil { + return result, validation.NewError("automation.RunbookClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, automationAccountName, runbookName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client RunbookClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string, parameters RunbookCreateOrUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client RunbookClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client RunbookClient) CreateOrUpdateResponder(resp *http.Response) (result Runbook, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusBadRequest), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete the runbook by name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// runbookName - the runbook name. +func (client RunbookClient) Delete(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.RunbookClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, automationAccountName, runbookName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client RunbookClient) DeletePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client RunbookClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client RunbookClient) 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 retrieve the runbook identified by runbook name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// runbookName - the runbook name. +func (client RunbookClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string) (result Runbook, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.RunbookClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName, runbookName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client RunbookClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client RunbookClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client RunbookClient) GetResponder(resp *http.Response) (result Runbook, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetContent retrieve the content of runbook identified by runbook name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// runbookName - the runbook name. +func (client RunbookClient) GetContent(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string) (result ReadCloser, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.RunbookClient", "GetContent", err.Error()) + } + + req, err := client.GetContentPreparer(ctx, resourceGroupName, automationAccountName, runbookName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "GetContent", nil, "Failure preparing request") + return + } + + resp, err := client.GetContentSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "GetContent", resp, "Failure sending request") + return + } + + result, err = client.GetContentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "GetContent", resp, "Failure responding to request") + } + + return +} + +// GetContentPreparer prepares the GetContent request. +func (client RunbookClient) GetContentPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/content", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetContentSender sends the GetContent request. The method will close the +// http.Response Body if it receives an error. +func (client RunbookClient) GetContentSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetContentResponder handles the response to the GetContent request. The method always +// closes the http.Response Body. +func (client RunbookClient) GetContentResponder(resp *http.Response) (result ReadCloser, err error) { + result.Value = &resp.Body + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK)) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of runbooks. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +func (client RunbookClient) ListByAutomationAccount(ctx context.Context, resourceGroupName string, automationAccountName string) (result RunbookListResultPage, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.RunbookClient", "ListByAutomationAccount", err.Error()) + } + + result.fn = client.listByAutomationAccountNextResults + req, err := client.ListByAutomationAccountPreparer(ctx, resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.rlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result.rlr, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client RunbookClient) ListByAutomationAccountPreparer(ctx context.Context, resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks", 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 RunbookClient) 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 RunbookClient) ListByAutomationAccountResponder(resp *http.Response) (result RunbookListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByAutomationAccountNextResults retrieves the next set of results, if any. +func (client RunbookClient) listByAutomationAccountNextResults(lastResults RunbookListResult) (result RunbookListResult, err error) { + req, err := lastResults.runbookListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.RunbookClient", "listByAutomationAccountNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.RunbookClient", "listByAutomationAccountNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "listByAutomationAccountNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByAutomationAccountComplete enumerates all values, automatically crossing page boundaries as required. +func (client RunbookClient) ListByAutomationAccountComplete(ctx context.Context, resourceGroupName string, automationAccountName string) (result RunbookListResultIterator, err error) { + result.page, err = client.ListByAutomationAccount(ctx, resourceGroupName, automationAccountName) + return +} + +// Update update the runbook identified by runbook name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// runbookName - the runbook name. +// parameters - the update parameters for runbook. +func (client RunbookClient) Update(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string, parameters RunbookUpdateParameters) (result Runbook, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.RunbookClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, automationAccountName, runbookName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client RunbookClient) UpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string, parameters RunbookUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client RunbookClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client RunbookClient) UpdateResponder(resp *http.Response) (result Runbook, 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/preview/automation/mgmt/2018-01-15-preview/automation/runbookdraft.go b/services/preview/automation/mgmt/2018-01-15-preview/automation/runbookdraft.go new file mode 100644 index 000000000000..b7b8a43ff956 --- /dev/null +++ b/services/preview/automation/mgmt/2018-01-15-preview/automation/runbookdraft.go @@ -0,0 +1,436 @@ +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" + "io" + "net/http" +) + +// RunbookDraftClient is the automation Client +type RunbookDraftClient struct { + BaseClient +} + +// NewRunbookDraftClient creates an instance of the RunbookDraftClient client. +func NewRunbookDraftClient(subscriptionID string, countType1 CountType) RunbookDraftClient { + return NewRunbookDraftClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewRunbookDraftClientWithBaseURI creates an instance of the RunbookDraftClient client. +func NewRunbookDraftClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) RunbookDraftClient { + return RunbookDraftClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// Get retrieve the runbook draft identified by runbook name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// runbookName - the runbook name. +func (client RunbookDraftClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string) (result RunbookDraft, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.RunbookDraftClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName, runbookName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookDraftClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.RunbookDraftClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookDraftClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client RunbookDraftClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client RunbookDraftClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client RunbookDraftClient) GetResponder(resp *http.Response) (result RunbookDraft, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetContent retrieve the content of runbook draft identified by runbook name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// runbookName - the runbook name. +func (client RunbookDraftClient) GetContent(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string) (result ReadCloser, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.RunbookDraftClient", "GetContent", err.Error()) + } + + req, err := client.GetContentPreparer(ctx, resourceGroupName, automationAccountName, runbookName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookDraftClient", "GetContent", nil, "Failure preparing request") + return + } + + resp, err := client.GetContentSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.RunbookDraftClient", "GetContent", resp, "Failure sending request") + return + } + + result, err = client.GetContentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookDraftClient", "GetContent", resp, "Failure responding to request") + } + + return +} + +// GetContentPreparer prepares the GetContent request. +func (client RunbookDraftClient) GetContentPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/content", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetContentSender sends the GetContent request. The method will close the +// http.Response Body if it receives an error. +func (client RunbookDraftClient) GetContentSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetContentResponder handles the response to the GetContent request. The method always +// closes the http.Response Body. +func (client RunbookDraftClient) GetContentResponder(resp *http.Response) (result ReadCloser, err error) { + result.Value = &resp.Body + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK)) + result.Response = autorest.Response{Response: resp} + return +} + +// Publish publish runbook draft. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// runbookName - the parameters supplied to the publish runbook operation. +func (client RunbookDraftClient) Publish(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string) (result RunbookDraftPublishFuture, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.RunbookDraftClient", "Publish", err.Error()) + } + + req, err := client.PublishPreparer(ctx, resourceGroupName, automationAccountName, runbookName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookDraftClient", "Publish", nil, "Failure preparing request") + return + } + + result, err = client.PublishSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookDraftClient", "Publish", result.Response(), "Failure sending request") + return + } + + return +} + +// PublishPreparer prepares the Publish request. +func (client RunbookDraftClient) PublishPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "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}/runbooks/{runbookName}/draft/publish", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// PublishSender sends the Publish request. The method will close the +// http.Response Body if it receives an error. +func (client RunbookDraftClient) PublishSender(req *http.Request) (future RunbookDraftPublishFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// PublishResponder handles the response to the Publish request. The method always +// closes the http.Response Body. +func (client RunbookDraftClient) PublishResponder(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 +} + +// ReplaceContent replaces the runbook draft content. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// runbookName - the runbook name. +// runbookContent - the runbook draft content. +func (client RunbookDraftClient) ReplaceContent(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string, runbookContent io.ReadCloser) (result RunbookDraftReplaceContentFuture, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.RunbookDraftClient", "ReplaceContent", err.Error()) + } + + req, err := client.ReplaceContentPreparer(ctx, resourceGroupName, automationAccountName, runbookName, runbookContent) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookDraftClient", "ReplaceContent", nil, "Failure preparing request") + return + } + + result, err = client.ReplaceContentSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookDraftClient", "ReplaceContent", result.Response(), "Failure sending request") + return + } + + return +} + +// ReplaceContentPreparer prepares the ReplaceContent request. +func (client RunbookDraftClient) ReplaceContentPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string, runbookContent io.ReadCloser) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("text/powershell"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/content", pathParameters), + autorest.WithFile(runbookContent), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ReplaceContentSender sends the ReplaceContent request. The method will close the +// http.Response Body if it receives an error. +func (client RunbookDraftClient) ReplaceContentSender(req *http.Request) (future RunbookDraftReplaceContentFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// ReplaceContentResponder handles the response to the ReplaceContent request. The method always +// closes the http.Response Body. +func (client RunbookDraftClient) ReplaceContentResponder(resp *http.Response) (result ReadCloser, 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 +} + +// UndoEdit undo draft edit to last known published state identified by runbook name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// runbookName - the runbook name. +func (client RunbookDraftClient) UndoEdit(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string) (result RunbookDraftUndoEditResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.RunbookDraftClient", "UndoEdit", err.Error()) + } + + req, err := client.UndoEditPreparer(ctx, resourceGroupName, automationAccountName, runbookName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookDraftClient", "UndoEdit", nil, "Failure preparing request") + return + } + + resp, err := client.UndoEditSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.RunbookDraftClient", "UndoEdit", resp, "Failure sending request") + return + } + + result, err = client.UndoEditResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookDraftClient", "UndoEdit", resp, "Failure responding to request") + } + + return +} + +// UndoEditPreparer prepares the UndoEdit request. +func (client RunbookDraftClient) UndoEditPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "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}/runbooks/{runbookName}/draft/undoEdit", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UndoEditSender sends the UndoEdit request. The method will close the +// http.Response Body if it receives an error. +func (client RunbookDraftClient) UndoEditSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// UndoEditResponder handles the response to the UndoEdit request. The method always +// closes the http.Response Body. +func (client RunbookDraftClient) UndoEditResponder(resp *http.Response) (result RunbookDraftUndoEditResult, 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/preview/automation/mgmt/2018-01-15-preview/automation/schedule.go b/services/preview/automation/mgmt/2018-01-15-preview/automation/schedule.go new file mode 100644 index 000000000000..8856aaa45182 --- /dev/null +++ b/services/preview/automation/mgmt/2018-01-15-preview/automation/schedule.go @@ -0,0 +1,461 @@ +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" +) + +// ScheduleClient is the automation Client +type ScheduleClient struct { + BaseClient +} + +// NewScheduleClient creates an instance of the ScheduleClient client. +func NewScheduleClient(subscriptionID string, countType1 CountType) ScheduleClient { + return NewScheduleClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewScheduleClientWithBaseURI creates an instance of the ScheduleClient client. +func NewScheduleClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) ScheduleClient { + return ScheduleClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// CreateOrUpdate create a schedule. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// scheduleName - the schedule name. +// parameters - the parameters supplied to the create or update schedule operation. +func (client ScheduleClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, automationAccountName string, scheduleName string, parameters ScheduleCreateOrUpdateParameters) (result Schedule, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ScheduleCreateOrUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ScheduleCreateOrUpdateProperties.StartTime", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("automation.ScheduleClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, automationAccountName, scheduleName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ScheduleClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, scheduleName string, parameters ScheduleCreateOrUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scheduleName": autorest.Encode("path", scheduleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ScheduleClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ScheduleClient) CreateOrUpdateResponder(resp *http.Response) (result Schedule, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusConflict), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete the schedule identified by schedule name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// scheduleName - the schedule name. +func (client ScheduleClient) Delete(ctx context.Context, resourceGroupName string, automationAccountName string, scheduleName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.ScheduleClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, automationAccountName, scheduleName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ScheduleClient) DeletePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, scheduleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scheduleName": autorest.Encode("path", scheduleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ScheduleClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ScheduleClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get retrieve the schedule identified by schedule name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// scheduleName - the schedule name. +func (client ScheduleClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string, scheduleName string) (result Schedule, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.ScheduleClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName, scheduleName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ScheduleClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, scheduleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scheduleName": autorest.Encode("path", scheduleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ScheduleClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ScheduleClient) GetResponder(resp *http.Response) (result Schedule, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of schedules. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +func (client ScheduleClient) ListByAutomationAccount(ctx context.Context, resourceGroupName string, automationAccountName string) (result ScheduleListResultPage, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.ScheduleClient", "ListByAutomationAccount", err.Error()) + } + + result.fn = client.listByAutomationAccountNextResults + req, err := client.ListByAutomationAccountPreparer(ctx, resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.slr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result.slr, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client ScheduleClient) ListByAutomationAccountPreparer(ctx context.Context, resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules", 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 ScheduleClient) 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 ScheduleClient) ListByAutomationAccountResponder(resp *http.Response) (result ScheduleListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByAutomationAccountNextResults retrieves the next set of results, if any. +func (client ScheduleClient) listByAutomationAccountNextResults(lastResults ScheduleListResult) (result ScheduleListResult, err error) { + req, err := lastResults.scheduleListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.ScheduleClient", "listByAutomationAccountNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.ScheduleClient", "listByAutomationAccountNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "listByAutomationAccountNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByAutomationAccountComplete enumerates all values, automatically crossing page boundaries as required. +func (client ScheduleClient) ListByAutomationAccountComplete(ctx context.Context, resourceGroupName string, automationAccountName string) (result ScheduleListResultIterator, err error) { + result.page, err = client.ListByAutomationAccount(ctx, resourceGroupName, automationAccountName) + return +} + +// Update update the schedule identified by schedule name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// scheduleName - the schedule name. +// parameters - the parameters supplied to the update schedule operation. +func (client ScheduleClient) Update(ctx context.Context, resourceGroupName string, automationAccountName string, scheduleName string, parameters ScheduleUpdateParameters) (result Schedule, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.ScheduleClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, automationAccountName, scheduleName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ScheduleClient) UpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, scheduleName string, parameters ScheduleUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scheduleName": autorest.Encode("path", scheduleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client ScheduleClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ScheduleClient) UpdateResponder(resp *http.Response) (result Schedule, 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/preview/automation/mgmt/2018-01-15-preview/automation/softwareupdateconfigurationmachineruns.go b/services/preview/automation/mgmt/2018-01-15-preview/automation/softwareupdateconfigurationmachineruns.go new file mode 100644 index 000000000000..b1ca235ebd3c --- /dev/null +++ b/services/preview/automation/mgmt/2018-01-15-preview/automation/softwareupdateconfigurationmachineruns.go @@ -0,0 +1,219 @@ +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" + "github.com/satori/go.uuid" + "net/http" +) + +// SoftwareUpdateConfigurationMachineRunsClient is the automation Client +type SoftwareUpdateConfigurationMachineRunsClient struct { + BaseClient +} + +// NewSoftwareUpdateConfigurationMachineRunsClient creates an instance of the +// SoftwareUpdateConfigurationMachineRunsClient client. +func NewSoftwareUpdateConfigurationMachineRunsClient(subscriptionID string, countType1 CountType) SoftwareUpdateConfigurationMachineRunsClient { + return NewSoftwareUpdateConfigurationMachineRunsClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewSoftwareUpdateConfigurationMachineRunsClientWithBaseURI creates an instance of the +// SoftwareUpdateConfigurationMachineRunsClient client. +func NewSoftwareUpdateConfigurationMachineRunsClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) SoftwareUpdateConfigurationMachineRunsClient { + return SoftwareUpdateConfigurationMachineRunsClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// GetByID get a single software update configuration machine run by Id. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// softwareUpdateConfigurationMachineRunID - the Id of the software update configuration machine run. +// clientRequestID - identifies this specific client request. +func (client SoftwareUpdateConfigurationMachineRunsClient) GetByID(ctx context.Context, resourceGroupName string, automationAccountName string, softwareUpdateConfigurationMachineRunID uuid.UUID, clientRequestID string) (result SoftwareUpdateConfigurationMachineRun, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.SoftwareUpdateConfigurationMachineRunsClient", "GetByID", err.Error()) + } + + req, err := client.GetByIDPreparer(ctx, resourceGroupName, automationAccountName, softwareUpdateConfigurationMachineRunID, clientRequestID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationMachineRunsClient", "GetByID", nil, "Failure preparing request") + return + } + + resp, err := client.GetByIDSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationMachineRunsClient", "GetByID", resp, "Failure sending request") + return + } + + result, err = client.GetByIDResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationMachineRunsClient", "GetByID", resp, "Failure responding to request") + } + + return +} + +// GetByIDPreparer prepares the GetByID request. +func (client SoftwareUpdateConfigurationMachineRunsClient) GetByIDPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, softwareUpdateConfigurationMachineRunID uuid.UUID, clientRequestID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "softwareUpdateConfigurationMachineRunId": autorest.Encode("path", softwareUpdateConfigurationMachineRunID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-05-15-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.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationMachineRuns/{softwareUpdateConfigurationMachineRunId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if len(clientRequestID) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("clientRequestId", autorest.String(clientRequestID))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetByIDSender sends the GetByID request. The method will close the +// http.Response Body if it receives an error. +func (client SoftwareUpdateConfigurationMachineRunsClient) GetByIDSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetByIDResponder handles the response to the GetByID request. The method always +// closes the http.Response Body. +func (client SoftwareUpdateConfigurationMachineRunsClient) GetByIDResponder(resp *http.Response) (result SoftwareUpdateConfigurationMachineRun, 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 return list of software update configuration machine runs +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// clientRequestID - identifies this specific client request. +// filter - the filter to apply on the operation. You can use the following filters: 'properties/osType', +// 'properties/status', 'properties/startTime', and 'properties/softwareUpdateConfiguration/name' +// skip - number of entries you skip before returning results +// top - maximum number of entries returned in the results collection +func (client SoftwareUpdateConfigurationMachineRunsClient) List(ctx context.Context, resourceGroupName string, automationAccountName string, clientRequestID string, filter string, skip string, top string) (result SoftwareUpdateConfigurationMachineRunListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.SoftwareUpdateConfigurationMachineRunsClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, resourceGroupName, automationAccountName, clientRequestID, filter, skip, top) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationMachineRunsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationMachineRunsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationMachineRunsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client SoftwareUpdateConfigurationMachineRunsClient) ListPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, clientRequestID string, filter string, skip string, top string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-05-15-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if len(skip) > 0 { + queryParameters["$skip"] = autorest.Encode("query", skip) + } + if len(top) > 0 { + queryParameters["$top"] = autorest.Encode("query", top) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationMachineRuns", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if len(clientRequestID) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("clientRequestId", autorest.String(clientRequestID))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client SoftwareUpdateConfigurationMachineRunsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client SoftwareUpdateConfigurationMachineRunsClient) ListResponder(resp *http.Response) (result SoftwareUpdateConfigurationMachineRunListResult, 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/preview/automation/mgmt/2018-01-15-preview/automation/softwareupdateconfigurationruns.go b/services/preview/automation/mgmt/2018-01-15-preview/automation/softwareupdateconfigurationruns.go new file mode 100644 index 000000000000..51734e1edbec --- /dev/null +++ b/services/preview/automation/mgmt/2018-01-15-preview/automation/softwareupdateconfigurationruns.go @@ -0,0 +1,218 @@ +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" + "github.com/satori/go.uuid" + "net/http" +) + +// SoftwareUpdateConfigurationRunsClient is the automation Client +type SoftwareUpdateConfigurationRunsClient struct { + BaseClient +} + +// NewSoftwareUpdateConfigurationRunsClient creates an instance of the SoftwareUpdateConfigurationRunsClient client. +func NewSoftwareUpdateConfigurationRunsClient(subscriptionID string, countType1 CountType) SoftwareUpdateConfigurationRunsClient { + return NewSoftwareUpdateConfigurationRunsClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewSoftwareUpdateConfigurationRunsClientWithBaseURI creates an instance of the SoftwareUpdateConfigurationRunsClient +// client. +func NewSoftwareUpdateConfigurationRunsClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) SoftwareUpdateConfigurationRunsClient { + return SoftwareUpdateConfigurationRunsClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// GetByID get a single software update configuration Run by Id. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// softwareUpdateConfigurationRunID - the Id of the software update configuration run. +// clientRequestID - identifies this specific client request. +func (client SoftwareUpdateConfigurationRunsClient) GetByID(ctx context.Context, resourceGroupName string, automationAccountName string, softwareUpdateConfigurationRunID uuid.UUID, clientRequestID string) (result SoftwareUpdateConfigurationRun, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.SoftwareUpdateConfigurationRunsClient", "GetByID", err.Error()) + } + + req, err := client.GetByIDPreparer(ctx, resourceGroupName, automationAccountName, softwareUpdateConfigurationRunID, clientRequestID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationRunsClient", "GetByID", nil, "Failure preparing request") + return + } + + resp, err := client.GetByIDSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationRunsClient", "GetByID", resp, "Failure sending request") + return + } + + result, err = client.GetByIDResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationRunsClient", "GetByID", resp, "Failure responding to request") + } + + return +} + +// GetByIDPreparer prepares the GetByID request. +func (client SoftwareUpdateConfigurationRunsClient) GetByIDPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, softwareUpdateConfigurationRunID uuid.UUID, clientRequestID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "softwareUpdateConfigurationRunId": autorest.Encode("path", softwareUpdateConfigurationRunID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-05-15-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.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationRuns/{softwareUpdateConfigurationRunId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if len(clientRequestID) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("clientRequestId", autorest.String(clientRequestID))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetByIDSender sends the GetByID request. The method will close the +// http.Response Body if it receives an error. +func (client SoftwareUpdateConfigurationRunsClient) GetByIDSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetByIDResponder handles the response to the GetByID request. The method always +// closes the http.Response Body. +func (client SoftwareUpdateConfigurationRunsClient) GetByIDResponder(resp *http.Response) (result SoftwareUpdateConfigurationRun, 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 return list of software update configuration runs +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// clientRequestID - identifies this specific client request. +// filter - the filter to apply on the operation. You can use the following filters: 'properties/osType', +// 'properties/status', 'properties/startTime', and 'properties/softwareUpdateConfiguration/name' +// skip - number of entries you skip before returning results +// top - maximum number of entries returned in the results collection +func (client SoftwareUpdateConfigurationRunsClient) List(ctx context.Context, resourceGroupName string, automationAccountName string, clientRequestID string, filter string, skip string, top string) (result SoftwareUpdateConfigurationRunListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.SoftwareUpdateConfigurationRunsClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, resourceGroupName, automationAccountName, clientRequestID, filter, skip, top) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationRunsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationRunsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationRunsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client SoftwareUpdateConfigurationRunsClient) ListPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, clientRequestID string, filter string, skip string, top string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-05-15-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if len(skip) > 0 { + queryParameters["$skip"] = autorest.Encode("query", skip) + } + if len(top) > 0 { + queryParameters["$top"] = autorest.Encode("query", top) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationRuns", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if len(clientRequestID) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("clientRequestId", autorest.String(clientRequestID))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client SoftwareUpdateConfigurationRunsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client SoftwareUpdateConfigurationRunsClient) ListResponder(resp *http.Response) (result SoftwareUpdateConfigurationRunListResult, 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/preview/automation/mgmt/2018-01-15-preview/automation/softwareupdateconfigurations.go b/services/preview/automation/mgmt/2018-01-15-preview/automation/softwareupdateconfigurations.go new file mode 100644 index 000000000000..02991a282782 --- /dev/null +++ b/services/preview/automation/mgmt/2018-01-15-preview/automation/softwareupdateconfigurations.go @@ -0,0 +1,379 @@ +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" +) + +// SoftwareUpdateConfigurationsClient is the automation Client +type SoftwareUpdateConfigurationsClient struct { + BaseClient +} + +// NewSoftwareUpdateConfigurationsClient creates an instance of the SoftwareUpdateConfigurationsClient client. +func NewSoftwareUpdateConfigurationsClient(subscriptionID string, countType1 CountType) SoftwareUpdateConfigurationsClient { + return NewSoftwareUpdateConfigurationsClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewSoftwareUpdateConfigurationsClientWithBaseURI creates an instance of the SoftwareUpdateConfigurationsClient +// client. +func NewSoftwareUpdateConfigurationsClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) SoftwareUpdateConfigurationsClient { + return SoftwareUpdateConfigurationsClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// Create create a new software update configuration with the name given in the URI. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// softwareUpdateConfigurationName - the name of the software update configuration to be created. +// parameters - request body. +// clientRequestID - identifies this specific client request. +func (client SoftwareUpdateConfigurationsClient) Create(ctx context.Context, resourceGroupName string, automationAccountName string, softwareUpdateConfigurationName string, parameters SoftwareUpdateConfiguration, clientRequestID string) (result SoftwareUpdateConfiguration, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.SoftwareUpdateConfigurationProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.SoftwareUpdateConfigurationProperties.UpdateConfiguration", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.SoftwareUpdateConfigurationProperties.ScheduleInfo", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("automation.SoftwareUpdateConfigurationsClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, automationAccountName, softwareUpdateConfigurationName, parameters, clientRequestID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationsClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationsClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationsClient", "Create", resp, "Failure responding to request") + } + + return +} + +// CreatePreparer prepares the Create request. +func (client SoftwareUpdateConfigurationsClient) CreatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, softwareUpdateConfigurationName string, parameters SoftwareUpdateConfiguration, clientRequestID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "softwareUpdateConfigurationName": autorest.Encode("path", softwareUpdateConfigurationName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-05-15-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations/{softwareUpdateConfigurationName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + if len(clientRequestID) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("clientRequestId", autorest.String(clientRequestID))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client SoftwareUpdateConfigurationsClient) CreateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client SoftwareUpdateConfigurationsClient) CreateResponder(resp *http.Response) (result SoftwareUpdateConfiguration, 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 delete a specific software update configuration. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// softwareUpdateConfigurationName - the name of the software update configuration to be created. +// clientRequestID - identifies this specific client request. +func (client SoftwareUpdateConfigurationsClient) Delete(ctx context.Context, resourceGroupName string, automationAccountName string, softwareUpdateConfigurationName string, clientRequestID string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.SoftwareUpdateConfigurationsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, automationAccountName, softwareUpdateConfigurationName, clientRequestID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationsClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client SoftwareUpdateConfigurationsClient) DeletePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, softwareUpdateConfigurationName string, clientRequestID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "softwareUpdateConfigurationName": autorest.Encode("path", softwareUpdateConfigurationName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-05-15-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.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations/{softwareUpdateConfigurationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if len(clientRequestID) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("clientRequestId", autorest.String(clientRequestID))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client SoftwareUpdateConfigurationsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client SoftwareUpdateConfigurationsClient) 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 +} + +// GetByName get a single software update configuration by name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// softwareUpdateConfigurationName - the name of the software update configuration to be created. +// clientRequestID - identifies this specific client request. +func (client SoftwareUpdateConfigurationsClient) GetByName(ctx context.Context, resourceGroupName string, automationAccountName string, softwareUpdateConfigurationName string, clientRequestID string) (result SoftwareUpdateConfiguration, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.SoftwareUpdateConfigurationsClient", "GetByName", err.Error()) + } + + req, err := client.GetByNamePreparer(ctx, resourceGroupName, automationAccountName, softwareUpdateConfigurationName, clientRequestID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationsClient", "GetByName", nil, "Failure preparing request") + return + } + + resp, err := client.GetByNameSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationsClient", "GetByName", resp, "Failure sending request") + return + } + + result, err = client.GetByNameResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationsClient", "GetByName", resp, "Failure responding to request") + } + + return +} + +// GetByNamePreparer prepares the GetByName request. +func (client SoftwareUpdateConfigurationsClient) GetByNamePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, softwareUpdateConfigurationName string, clientRequestID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "softwareUpdateConfigurationName": autorest.Encode("path", softwareUpdateConfigurationName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-05-15-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.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations/{softwareUpdateConfigurationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if len(clientRequestID) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("clientRequestId", autorest.String(clientRequestID))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetByNameSender sends the GetByName request. The method will close the +// http.Response Body if it receives an error. +func (client SoftwareUpdateConfigurationsClient) GetByNameSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetByNameResponder handles the response to the GetByName request. The method always +// closes the http.Response Body. +func (client SoftwareUpdateConfigurationsClient) GetByNameResponder(resp *http.Response) (result SoftwareUpdateConfiguration, 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 get all software update configurations for the account. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// clientRequestID - identifies this specific client request. +// filter - the filter to apply on the operation. +func (client SoftwareUpdateConfigurationsClient) List(ctx context.Context, resourceGroupName string, automationAccountName string, clientRequestID string, filter string) (result SoftwareUpdateConfigurationListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.SoftwareUpdateConfigurationsClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, resourceGroupName, automationAccountName, clientRequestID, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client SoftwareUpdateConfigurationsClient) ListPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, clientRequestID string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-05-15-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if len(clientRequestID) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("clientRequestId", autorest.String(clientRequestID))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client SoftwareUpdateConfigurationsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client SoftwareUpdateConfigurationsClient) ListResponder(resp *http.Response) (result SoftwareUpdateConfigurationListResult, 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/preview/automation/mgmt/2018-01-15-preview/automation/sourcecontrol.go b/services/preview/automation/mgmt/2018-01-15-preview/automation/sourcecontrol.go new file mode 100644 index 000000000000..2ae0b1d991a8 --- /dev/null +++ b/services/preview/automation/mgmt/2018-01-15-preview/automation/sourcecontrol.go @@ -0,0 +1,478 @@ +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" +) + +// SourceControlClient is the automation Client +type SourceControlClient struct { + BaseClient +} + +// NewSourceControlClient creates an instance of the SourceControlClient client. +func NewSourceControlClient(subscriptionID string, countType1 CountType) SourceControlClient { + return NewSourceControlClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewSourceControlClientWithBaseURI creates an instance of the SourceControlClient client. +func NewSourceControlClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) SourceControlClient { + return SourceControlClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// CreateOrUpdate create a source control. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// sourceControlName - the source control name. +// parameters - the parameters supplied to the create or update source control operation. +func (client SourceControlClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, automationAccountName string, sourceControlName string, parameters SourceControlCreateOrUpdateParameters) (result SourceControl, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.SourceControlCreateOrUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.SourceControlCreateOrUpdateProperties.RepoURL", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.SourceControlCreateOrUpdateProperties.RepoURL", Name: validation.MaxLength, Rule: 2000, Chain: nil}}}, + {Target: "parameters.SourceControlCreateOrUpdateProperties.Branch", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.SourceControlCreateOrUpdateProperties.Branch", Name: validation.MaxLength, Rule: 255, Chain: nil}}}, + {Target: "parameters.SourceControlCreateOrUpdateProperties.FolderPath", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.SourceControlCreateOrUpdateProperties.FolderPath", Name: validation.MaxLength, Rule: 255, Chain: nil}}}, + {Target: "parameters.SourceControlCreateOrUpdateProperties.SecurityToken", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.SourceControlCreateOrUpdateProperties.SecurityToken.AccessToken", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.SourceControlCreateOrUpdateProperties.SecurityToken.AccessToken", Name: validation.MaxLength, Rule: 1024, Chain: nil}}}, + {Target: "parameters.SourceControlCreateOrUpdateProperties.SecurityToken.RefreshToken", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.SourceControlCreateOrUpdateProperties.SecurityToken.RefreshToken", Name: validation.MaxLength, Rule: 1024, Chain: nil}}}, + }}, + {Target: "parameters.SourceControlCreateOrUpdateProperties.Description", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.SourceControlCreateOrUpdateProperties.Description", Name: validation.MaxLength, Rule: 512, Chain: nil}}}, + }}}}}); err != nil { + return result, validation.NewError("automation.SourceControlClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, automationAccountName, sourceControlName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SourceControlClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.SourceControlClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SourceControlClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client SourceControlClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, sourceControlName string, parameters SourceControlCreateOrUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "sourceControlName": autorest.Encode("path", sourceControlName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-05-15-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client SourceControlClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client SourceControlClient) CreateOrUpdateResponder(resp *http.Response) (result SourceControl, 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 delete the source control. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// sourceControlName - the name of source control. +func (client SourceControlClient) Delete(ctx context.Context, resourceGroupName string, automationAccountName string, sourceControlName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.SourceControlClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, automationAccountName, sourceControlName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SourceControlClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.SourceControlClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SourceControlClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client SourceControlClient) DeletePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, sourceControlName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "sourceControlName": autorest.Encode("path", sourceControlName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-05-15-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.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client SourceControlClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client SourceControlClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get retrieve the source control identified by source control name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// sourceControlName - the name of source control. +func (client SourceControlClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string, sourceControlName string) (result SourceControl, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.SourceControlClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName, sourceControlName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SourceControlClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.SourceControlClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SourceControlClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client SourceControlClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, sourceControlName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "sourceControlName": autorest.Encode("path", sourceControlName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-05-15-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.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client SourceControlClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client SourceControlClient) GetResponder(resp *http.Response) (result SourceControl, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of source controls. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// filter - the filter to apply on the operation. +func (client SourceControlClient) ListByAutomationAccount(ctx context.Context, resourceGroupName string, automationAccountName string, filter string) (result SourceControlListResultPage, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.SourceControlClient", "ListByAutomationAccount", err.Error()) + } + + result.fn = client.listByAutomationAccountNextResults + req, err := client.ListByAutomationAccountPreparer(ctx, resourceGroupName, automationAccountName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SourceControlClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.sclr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.SourceControlClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result.sclr, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SourceControlClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client SourceControlClient) ListByAutomationAccountPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-05-15-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls", 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 SourceControlClient) 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 SourceControlClient) ListByAutomationAccountResponder(resp *http.Response) (result SourceControlListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByAutomationAccountNextResults retrieves the next set of results, if any. +func (client SourceControlClient) listByAutomationAccountNextResults(lastResults SourceControlListResult) (result SourceControlListResult, err error) { + req, err := lastResults.sourceControlListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.SourceControlClient", "listByAutomationAccountNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.SourceControlClient", "listByAutomationAccountNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SourceControlClient", "listByAutomationAccountNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByAutomationAccountComplete enumerates all values, automatically crossing page boundaries as required. +func (client SourceControlClient) ListByAutomationAccountComplete(ctx context.Context, resourceGroupName string, automationAccountName string, filter string) (result SourceControlListResultIterator, err error) { + result.page, err = client.ListByAutomationAccount(ctx, resourceGroupName, automationAccountName, filter) + return +} + +// Update update a source control. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// sourceControlName - the source control name. +// parameters - the parameters supplied to the update source control operation. +func (client SourceControlClient) Update(ctx context.Context, resourceGroupName string, automationAccountName string, sourceControlName string, parameters SourceControlUpdateParameters) (result SourceControl, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.SourceControlClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, automationAccountName, sourceControlName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SourceControlClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.SourceControlClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SourceControlClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client SourceControlClient) UpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, sourceControlName string, parameters SourceControlUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "sourceControlName": autorest.Encode("path", sourceControlName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-05-15-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client SourceControlClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client SourceControlClient) UpdateResponder(resp *http.Response) (result SourceControl, 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/preview/automation/mgmt/2018-01-15-preview/automation/sourcecontrolsyncjob.go b/services/preview/automation/mgmt/2018-01-15-preview/automation/sourcecontrolsyncjob.go new file mode 100644 index 000000000000..2b54a270d937 --- /dev/null +++ b/services/preview/automation/mgmt/2018-01-15-preview/automation/sourcecontrolsyncjob.go @@ -0,0 +1,317 @@ +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" + "github.com/satori/go.uuid" + "net/http" +) + +// SourceControlSyncJobClient is the automation Client +type SourceControlSyncJobClient struct { + BaseClient +} + +// NewSourceControlSyncJobClient creates an instance of the SourceControlSyncJobClient client. +func NewSourceControlSyncJobClient(subscriptionID string, countType1 CountType) SourceControlSyncJobClient { + return NewSourceControlSyncJobClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewSourceControlSyncJobClientWithBaseURI creates an instance of the SourceControlSyncJobClient client. +func NewSourceControlSyncJobClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) SourceControlSyncJobClient { + return SourceControlSyncJobClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// Create creates the sync job for a source control. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// sourceControlName - the source control name. +// sourceControlSyncJobID - the source control sync job id. +// parameters - the parameters supplied to the create source control sync job operation. +func (client SourceControlSyncJobClient) Create(ctx context.Context, resourceGroupName string, automationAccountName string, sourceControlName string, sourceControlSyncJobID uuid.UUID, parameters SourceControlSyncJobCreateParameters) (result SourceControlSyncJob, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.SourceControlSyncJobCreateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.SourceControlSyncJobCreateProperties.CommitID", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.SourceControlSyncJobCreateProperties.CommitID", Name: validation.MinLength, Rule: 0, Chain: nil}}}, + }}}}}); err != nil { + return result, validation.NewError("automation.SourceControlSyncJobClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, automationAccountName, sourceControlName, sourceControlSyncJobID, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SourceControlSyncJobClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.SourceControlSyncJobClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SourceControlSyncJobClient", "Create", resp, "Failure responding to request") + } + + return +} + +// CreatePreparer prepares the Create request. +func (client SourceControlSyncJobClient) CreatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, sourceControlName string, sourceControlSyncJobID uuid.UUID, parameters SourceControlSyncJobCreateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "sourceControlName": autorest.Encode("path", sourceControlName), + "sourceControlSyncJobId": autorest.Encode("path", sourceControlSyncJobID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-05-15-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs/{sourceControlSyncJobId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client SourceControlSyncJobClient) CreateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client SourceControlSyncJobClient) CreateResponder(resp *http.Response) (result SourceControlSyncJob, 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 +} + +// Get retrieve the source control sync job identified by job id. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// sourceControlName - the source control name. +// sourceControlSyncJobID - the source control sync job id. +func (client SourceControlSyncJobClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string, sourceControlName string, sourceControlSyncJobID uuid.UUID) (result SourceControlSyncJobByID, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.SourceControlSyncJobClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName, sourceControlName, sourceControlSyncJobID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SourceControlSyncJobClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.SourceControlSyncJobClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SourceControlSyncJobClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client SourceControlSyncJobClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, sourceControlName string, sourceControlSyncJobID uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "sourceControlName": autorest.Encode("path", sourceControlName), + "sourceControlSyncJobId": autorest.Encode("path", sourceControlSyncJobID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-05-15-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.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs/{sourceControlSyncJobId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client SourceControlSyncJobClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client SourceControlSyncJobClient) GetResponder(resp *http.Response) (result SourceControlSyncJobByID, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of source control sync jobs. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// sourceControlName - the source control name. +// filter - the filter to apply on the operation. +func (client SourceControlSyncJobClient) ListByAutomationAccount(ctx context.Context, resourceGroupName string, automationAccountName string, sourceControlName string, filter string) (result SourceControlSyncJobListResultPage, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.SourceControlSyncJobClient", "ListByAutomationAccount", err.Error()) + } + + result.fn = client.listByAutomationAccountNextResults + req, err := client.ListByAutomationAccountPreparer(ctx, resourceGroupName, automationAccountName, sourceControlName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SourceControlSyncJobClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.scsjlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.SourceControlSyncJobClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result.scsjlr, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SourceControlSyncJobClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client SourceControlSyncJobClient) ListByAutomationAccountPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, sourceControlName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "sourceControlName": autorest.Encode("path", sourceControlName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-05-15-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs", 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 SourceControlSyncJobClient) 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 SourceControlSyncJobClient) ListByAutomationAccountResponder(resp *http.Response) (result SourceControlSyncJobListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByAutomationAccountNextResults retrieves the next set of results, if any. +func (client SourceControlSyncJobClient) listByAutomationAccountNextResults(lastResults SourceControlSyncJobListResult) (result SourceControlSyncJobListResult, err error) { + req, err := lastResults.sourceControlSyncJobListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.SourceControlSyncJobClient", "listByAutomationAccountNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.SourceControlSyncJobClient", "listByAutomationAccountNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SourceControlSyncJobClient", "listByAutomationAccountNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByAutomationAccountComplete enumerates all values, automatically crossing page boundaries as required. +func (client SourceControlSyncJobClient) ListByAutomationAccountComplete(ctx context.Context, resourceGroupName string, automationAccountName string, sourceControlName string, filter string) (result SourceControlSyncJobListResultIterator, err error) { + result.page, err = client.ListByAutomationAccount(ctx, resourceGroupName, automationAccountName, sourceControlName, filter) + return +} diff --git a/services/preview/automation/mgmt/2018-01-15-preview/automation/sourcecontrolsyncjobstreams.go b/services/preview/automation/mgmt/2018-01-15-preview/automation/sourcecontrolsyncjobstreams.go new file mode 100644 index 000000000000..0b3376722aaf --- /dev/null +++ b/services/preview/automation/mgmt/2018-01-15-preview/automation/sourcecontrolsyncjobstreams.go @@ -0,0 +1,234 @@ +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" + "github.com/satori/go.uuid" + "net/http" +) + +// SourceControlSyncJobStreamsClient is the automation Client +type SourceControlSyncJobStreamsClient struct { + BaseClient +} + +// NewSourceControlSyncJobStreamsClient creates an instance of the SourceControlSyncJobStreamsClient client. +func NewSourceControlSyncJobStreamsClient(subscriptionID string, countType1 CountType) SourceControlSyncJobStreamsClient { + return NewSourceControlSyncJobStreamsClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewSourceControlSyncJobStreamsClientWithBaseURI creates an instance of the SourceControlSyncJobStreamsClient client. +func NewSourceControlSyncJobStreamsClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) SourceControlSyncJobStreamsClient { + return SourceControlSyncJobStreamsClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// Get retrieve a sync job stream identified by stream id. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// sourceControlName - the source control name. +// sourceControlSyncJobID - the source control sync job id. +// streamID - the id of the sync job stream. +func (client SourceControlSyncJobStreamsClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string, sourceControlName string, sourceControlSyncJobID uuid.UUID, streamID string) (result SourceControlSyncJobStreamByID, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.SourceControlSyncJobStreamsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName, sourceControlName, sourceControlSyncJobID, streamID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SourceControlSyncJobStreamsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.SourceControlSyncJobStreamsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SourceControlSyncJobStreamsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client SourceControlSyncJobStreamsClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, sourceControlName string, sourceControlSyncJobID uuid.UUID, streamID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "sourceControlName": autorest.Encode("path", sourceControlName), + "sourceControlSyncJobId": autorest.Encode("path", sourceControlSyncJobID), + "streamId": autorest.Encode("path", streamID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-05-15-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.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs/{sourceControlSyncJobId}/streams/{streamId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client SourceControlSyncJobStreamsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client SourceControlSyncJobStreamsClient) GetResponder(resp *http.Response) (result SourceControlSyncJobStreamByID, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListBySyncJob retrieve a list of sync job streams identified by sync job id. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// sourceControlName - the source control name. +// sourceControlSyncJobID - the source control sync job id. +// filter - the filter to apply on the operation. +func (client SourceControlSyncJobStreamsClient) ListBySyncJob(ctx context.Context, resourceGroupName string, automationAccountName string, sourceControlName string, sourceControlSyncJobID uuid.UUID, filter string) (result SourceControlSyncJobStreamsListBySyncJobPage, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.SourceControlSyncJobStreamsClient", "ListBySyncJob", err.Error()) + } + + result.fn = client.listBySyncJobNextResults + req, err := client.ListBySyncJobPreparer(ctx, resourceGroupName, automationAccountName, sourceControlName, sourceControlSyncJobID, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SourceControlSyncJobStreamsClient", "ListBySyncJob", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySyncJobSender(req) + if err != nil { + result.scsjslbsj.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.SourceControlSyncJobStreamsClient", "ListBySyncJob", resp, "Failure sending request") + return + } + + result.scsjslbsj, err = client.ListBySyncJobResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SourceControlSyncJobStreamsClient", "ListBySyncJob", resp, "Failure responding to request") + } + + return +} + +// ListBySyncJobPreparer prepares the ListBySyncJob request. +func (client SourceControlSyncJobStreamsClient) ListBySyncJobPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, sourceControlName string, sourceControlSyncJobID uuid.UUID, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "sourceControlName": autorest.Encode("path", sourceControlName), + "sourceControlSyncJobId": autorest.Encode("path", sourceControlSyncJobID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-05-15-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs/{sourceControlSyncJobId}/streams", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySyncJobSender sends the ListBySyncJob request. The method will close the +// http.Response Body if it receives an error. +func (client SourceControlSyncJobStreamsClient) ListBySyncJobSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListBySyncJobResponder handles the response to the ListBySyncJob request. The method always +// closes the http.Response Body. +func (client SourceControlSyncJobStreamsClient) ListBySyncJobResponder(resp *http.Response) (result SourceControlSyncJobStreamsListBySyncJob, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listBySyncJobNextResults retrieves the next set of results, if any. +func (client SourceControlSyncJobStreamsClient) listBySyncJobNextResults(lastResults SourceControlSyncJobStreamsListBySyncJob) (result SourceControlSyncJobStreamsListBySyncJob, err error) { + req, err := lastResults.sourceControlSyncJobStreamsListBySyncJobPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.SourceControlSyncJobStreamsClient", "listBySyncJobNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListBySyncJobSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.SourceControlSyncJobStreamsClient", "listBySyncJobNextResults", resp, "Failure sending next results request") + } + result, err = client.ListBySyncJobResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SourceControlSyncJobStreamsClient", "listBySyncJobNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListBySyncJobComplete enumerates all values, automatically crossing page boundaries as required. +func (client SourceControlSyncJobStreamsClient) ListBySyncJobComplete(ctx context.Context, resourceGroupName string, automationAccountName string, sourceControlName string, sourceControlSyncJobID uuid.UUID, filter string) (result SourceControlSyncJobStreamsListBySyncJobIterator, err error) { + result.page, err = client.ListBySyncJob(ctx, resourceGroupName, automationAccountName, sourceControlName, sourceControlSyncJobID, filter) + return +} diff --git a/services/preview/automation/mgmt/2018-01-15-preview/automation/statistics.go b/services/preview/automation/mgmt/2018-01-15-preview/automation/statistics.go new file mode 100644 index 000000000000..a9c51ea07c08 --- /dev/null +++ b/services/preview/automation/mgmt/2018-01-15-preview/automation/statistics.go @@ -0,0 +1,120 @@ +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" +) + +// StatisticsClient is the automation Client +type StatisticsClient struct { + BaseClient +} + +// NewStatisticsClient creates an instance of the StatisticsClient client. +func NewStatisticsClient(subscriptionID string, countType1 CountType) StatisticsClient { + return NewStatisticsClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewStatisticsClientWithBaseURI creates an instance of the StatisticsClient client. +func NewStatisticsClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) StatisticsClient { + return StatisticsClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// ListByAutomationAccount retrieve the statistics for the account. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// filter - the filter to apply on the operation. +func (client StatisticsClient) ListByAutomationAccount(ctx context.Context, resourceGroupName string, automationAccountName string, filter string) (result StatisticsListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.StatisticsClient", "ListByAutomationAccount", err.Error()) + } + + req, err := client.ListByAutomationAccountPreparer(ctx, resourceGroupName, automationAccountName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.StatisticsClient", "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.StatisticsClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.StatisticsClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client StatisticsClient) ListByAutomationAccountPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/statistics", 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 StatisticsClient) 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 StatisticsClient) ListByAutomationAccountResponder(resp *http.Response) (result StatisticsListResult, 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/preview/automation/mgmt/2018-01-15-preview/automation/testjob.go b/services/preview/automation/mgmt/2018-01-15-preview/automation/testjob.go new file mode 100644 index 000000000000..2c09885d6e9c --- /dev/null +++ b/services/preview/automation/mgmt/2018-01-15-preview/automation/testjob.go @@ -0,0 +1,426 @@ +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" +) + +// TestJobClient is the automation Client +type TestJobClient struct { + BaseClient +} + +// NewTestJobClient creates an instance of the TestJobClient client. +func NewTestJobClient(subscriptionID string, countType1 CountType) TestJobClient { + return NewTestJobClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewTestJobClientWithBaseURI creates an instance of the TestJobClient client. +func NewTestJobClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) TestJobClient { + return TestJobClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// Create create a test job of the runbook. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// runbookName - the parameters supplied to the create test job operation. +// parameters - the parameters supplied to the create test job operation. +func (client TestJobClient) Create(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string, parameters TestJobCreateParameters) (result TestJob, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.TestJobClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, automationAccountName, runbookName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.TestJobClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobClient", "Create", resp, "Failure responding to request") + } + + return +} + +// CreatePreparer prepares the Create request. +func (client TestJobClient) CreatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string, parameters TestJobCreateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client TestJobClient) CreateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client TestJobClient) CreateResponder(resp *http.Response) (result TestJob, 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 +} + +// Get retrieve the test job for the specified runbook. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// runbookName - the runbook name. +func (client TestJobClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string) (result TestJob, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.TestJobClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName, runbookName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.TestJobClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client TestJobClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client TestJobClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client TestJobClient) GetResponder(resp *http.Response) (result TestJob, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Resume resume the test job. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// runbookName - the runbook name. +func (client TestJobClient) Resume(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.TestJobClient", "Resume", err.Error()) + } + + req, err := client.ResumePreparer(ctx, resourceGroupName, automationAccountName, runbookName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobClient", "Resume", nil, "Failure preparing request") + return + } + + resp, err := client.ResumeSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.TestJobClient", "Resume", resp, "Failure sending request") + return + } + + result, err = client.ResumeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobClient", "Resume", resp, "Failure responding to request") + } + + return +} + +// ResumePreparer prepares the Resume request. +func (client TestJobClient) ResumePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "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}/runbooks/{runbookName}/draft/testJob/resume", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ResumeSender sends the Resume request. The method will close the +// http.Response Body if it receives an error. +func (client TestJobClient) ResumeSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ResumeResponder handles the response to the Resume request. The method always +// closes the http.Response Body. +func (client TestJobClient) ResumeResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Stop stop the test job. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// runbookName - the runbook name. +func (client TestJobClient) Stop(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.TestJobClient", "Stop", err.Error()) + } + + req, err := client.StopPreparer(ctx, resourceGroupName, automationAccountName, runbookName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobClient", "Stop", nil, "Failure preparing request") + return + } + + resp, err := client.StopSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.TestJobClient", "Stop", resp, "Failure sending request") + return + } + + result, err = client.StopResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobClient", "Stop", resp, "Failure responding to request") + } + + return +} + +// StopPreparer prepares the Stop request. +func (client TestJobClient) StopPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "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}/runbooks/{runbookName}/draft/testJob/stop", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// StopSender sends the Stop request. The method will close the +// http.Response Body if it receives an error. +func (client TestJobClient) StopSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// StopResponder handles the response to the Stop request. The method always +// closes the http.Response Body. +func (client TestJobClient) StopResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Suspend suspend the test job. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// runbookName - the runbook name. +func (client TestJobClient) Suspend(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.TestJobClient", "Suspend", err.Error()) + } + + req, err := client.SuspendPreparer(ctx, resourceGroupName, automationAccountName, runbookName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobClient", "Suspend", nil, "Failure preparing request") + return + } + + resp, err := client.SuspendSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.TestJobClient", "Suspend", resp, "Failure sending request") + return + } + + result, err = client.SuspendResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobClient", "Suspend", resp, "Failure responding to request") + } + + return +} + +// SuspendPreparer prepares the Suspend request. +func (client TestJobClient) SuspendPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "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}/runbooks/{runbookName}/draft/testJob/suspend", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// SuspendSender sends the Suspend request. The method will close the +// http.Response Body if it receives an error. +func (client TestJobClient) SuspendSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// SuspendResponder handles the response to the Suspend request. The method always +// closes the http.Response Body. +func (client TestJobClient) SuspendResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/services/preview/automation/mgmt/2018-01-15-preview/automation/testjobstreams.go b/services/preview/automation/mgmt/2018-01-15-preview/automation/testjobstreams.go new file mode 100644 index 000000000000..df38ce829b32 --- /dev/null +++ b/services/preview/automation/mgmt/2018-01-15-preview/automation/testjobstreams.go @@ -0,0 +1,229 @@ +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" +) + +// TestJobStreamsClient is the automation Client +type TestJobStreamsClient struct { + BaseClient +} + +// NewTestJobStreamsClient creates an instance of the TestJobStreamsClient client. +func NewTestJobStreamsClient(subscriptionID string, countType1 CountType) TestJobStreamsClient { + return NewTestJobStreamsClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewTestJobStreamsClientWithBaseURI creates an instance of the TestJobStreamsClient client. +func NewTestJobStreamsClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) TestJobStreamsClient { + return TestJobStreamsClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// Get retrieve a test job stream of the test job identified by runbook name and stream id. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// runbookName - the runbook name. +// jobStreamID - the job stream id. +func (client TestJobStreamsClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string, jobStreamID string) (result JobStream, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.TestJobStreamsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName, runbookName, jobStreamID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobStreamsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.TestJobStreamsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobStreamsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client TestJobStreamsClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string, jobStreamID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "jobStreamId": autorest.Encode("path", jobStreamID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/streams/{jobStreamId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client TestJobStreamsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client TestJobStreamsClient) GetResponder(resp *http.Response) (result JobStream, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByTestJob retrieve a list of test job streams identified by runbook name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// runbookName - the runbook name. +// filter - the filter to apply on the operation. +func (client TestJobStreamsClient) ListByTestJob(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string, filter string) (result JobStreamListResultPage, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.TestJobStreamsClient", "ListByTestJob", err.Error()) + } + + result.fn = client.listByTestJobNextResults + req, err := client.ListByTestJobPreparer(ctx, resourceGroupName, automationAccountName, runbookName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobStreamsClient", "ListByTestJob", nil, "Failure preparing request") + return + } + + resp, err := client.ListByTestJobSender(req) + if err != nil { + result.jslr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.TestJobStreamsClient", "ListByTestJob", resp, "Failure sending request") + return + } + + result.jslr, err = client.ListByTestJobResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobStreamsClient", "ListByTestJob", resp, "Failure responding to request") + } + + return +} + +// ListByTestJobPreparer prepares the ListByTestJob request. +func (client TestJobStreamsClient) ListByTestJobPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/streams", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByTestJobSender sends the ListByTestJob request. The method will close the +// http.Response Body if it receives an error. +func (client TestJobStreamsClient) ListByTestJobSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByTestJobResponder handles the response to the ListByTestJob request. The method always +// closes the http.Response Body. +func (client TestJobStreamsClient) ListByTestJobResponder(resp *http.Response) (result JobStreamListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByTestJobNextResults retrieves the next set of results, if any. +func (client TestJobStreamsClient) listByTestJobNextResults(lastResults JobStreamListResult) (result JobStreamListResult, err error) { + req, err := lastResults.jobStreamListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.TestJobStreamsClient", "listByTestJobNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByTestJobSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.TestJobStreamsClient", "listByTestJobNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByTestJobResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobStreamsClient", "listByTestJobNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByTestJobComplete enumerates all values, automatically crossing page boundaries as required. +func (client TestJobStreamsClient) ListByTestJobComplete(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string, filter string) (result JobStreamListResultIterator, err error) { + result.page, err = client.ListByTestJob(ctx, resourceGroupName, automationAccountName, runbookName, filter) + return +} diff --git a/services/preview/automation/mgmt/2018-01-15-preview/automation/usages.go b/services/preview/automation/mgmt/2018-01-15-preview/automation/usages.go new file mode 100644 index 000000000000..265bfaba03b1 --- /dev/null +++ b/services/preview/automation/mgmt/2018-01-15-preview/automation/usages.go @@ -0,0 +1,116 @@ +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" +) + +// UsagesClient is the automation Client +type UsagesClient struct { + BaseClient +} + +// NewUsagesClient creates an instance of the UsagesClient client. +func NewUsagesClient(subscriptionID string, countType1 CountType) UsagesClient { + return NewUsagesClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewUsagesClientWithBaseURI creates an instance of the UsagesClient client. +func NewUsagesClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) UsagesClient { + return UsagesClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// ListByAutomationAccount retrieve the usage for the account id. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +func (client UsagesClient) ListByAutomationAccount(ctx context.Context, resourceGroupName string, automationAccountName string) (result UsageListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.UsagesClient", "ListByAutomationAccount", err.Error()) + } + + req, err := client.ListByAutomationAccountPreparer(ctx, resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.UsagesClient", "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.UsagesClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.UsagesClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client UsagesClient) ListByAutomationAccountPreparer(ctx context.Context, resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/usages", 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 UsagesClient) 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 UsagesClient) ListByAutomationAccountResponder(resp *http.Response) (result UsageListResult, 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/preview/automation/mgmt/2018-01-15-preview/automation/variable.go b/services/preview/automation/mgmt/2018-01-15-preview/automation/variable.go new file mode 100644 index 000000000000..be7b4b91c5d3 --- /dev/null +++ b/services/preview/automation/mgmt/2018-01-15-preview/automation/variable.go @@ -0,0 +1,460 @@ +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" +) + +// VariableClient is the automation Client +type VariableClient struct { + BaseClient +} + +// NewVariableClient creates an instance of the VariableClient client. +func NewVariableClient(subscriptionID string, countType1 CountType) VariableClient { + return NewVariableClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewVariableClientWithBaseURI creates an instance of the VariableClient client. +func NewVariableClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) VariableClient { + return VariableClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// CreateOrUpdate create a variable. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// variableName - the variable name. +// parameters - the parameters supplied to the create or update variable operation. +func (client VariableClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, automationAccountName string, variableName string, parameters VariableCreateOrUpdateParameters) (result Variable, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.VariableCreateOrUpdateProperties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.VariableClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, automationAccountName, variableName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.VariableClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.VariableClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.VariableClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client VariableClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, variableName string, parameters VariableCreateOrUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "variableName": autorest.Encode("path", variableName), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client VariableClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client VariableClient) CreateOrUpdateResponder(resp *http.Response) (result Variable, 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 delete the variable. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// variableName - the name of variable. +func (client VariableClient) Delete(ctx context.Context, resourceGroupName string, automationAccountName string, variableName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.VariableClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, automationAccountName, variableName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.VariableClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.VariableClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.VariableClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client VariableClient) DeletePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, variableName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "variableName": autorest.Encode("path", variableName), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client VariableClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client VariableClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get retrieve the variable identified by variable name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// variableName - the name of variable. +func (client VariableClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string, variableName string) (result Variable, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.VariableClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName, variableName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.VariableClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.VariableClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.VariableClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client VariableClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, variableName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "variableName": autorest.Encode("path", variableName), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client VariableClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client VariableClient) GetResponder(resp *http.Response) (result Variable, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of variables. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +func (client VariableClient) ListByAutomationAccount(ctx context.Context, resourceGroupName string, automationAccountName string) (result VariableListResultPage, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.VariableClient", "ListByAutomationAccount", err.Error()) + } + + result.fn = client.listByAutomationAccountNextResults + req, err := client.ListByAutomationAccountPreparer(ctx, resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.VariableClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.vlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.VariableClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result.vlr, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.VariableClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client VariableClient) ListByAutomationAccountPreparer(ctx context.Context, resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables", 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 VariableClient) 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 VariableClient) ListByAutomationAccountResponder(resp *http.Response) (result VariableListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByAutomationAccountNextResults retrieves the next set of results, if any. +func (client VariableClient) listByAutomationAccountNextResults(lastResults VariableListResult) (result VariableListResult, err error) { + req, err := lastResults.variableListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.VariableClient", "listByAutomationAccountNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.VariableClient", "listByAutomationAccountNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.VariableClient", "listByAutomationAccountNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByAutomationAccountComplete enumerates all values, automatically crossing page boundaries as required. +func (client VariableClient) ListByAutomationAccountComplete(ctx context.Context, resourceGroupName string, automationAccountName string) (result VariableListResultIterator, err error) { + result.page, err = client.ListByAutomationAccount(ctx, resourceGroupName, automationAccountName) + return +} + +// Update update a variable. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// variableName - the variable name. +// parameters - the parameters supplied to the update variable operation. +func (client VariableClient) Update(ctx context.Context, resourceGroupName string, automationAccountName string, variableName string, parameters VariableUpdateParameters) (result Variable, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.VariableClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, automationAccountName, variableName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.VariableClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.VariableClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.VariableClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client VariableClient) UpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, variableName string, parameters VariableUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "variableName": autorest.Encode("path", variableName), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client VariableClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client VariableClient) UpdateResponder(resp *http.Response) (result Variable, 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/preview/automation/mgmt/2018-01-15-preview/automation/version.go b/services/preview/automation/mgmt/2018-01-15-preview/automation/version.go new file mode 100644 index 000000000000..b2c33d1a8ffa --- /dev/null +++ b/services/preview/automation/mgmt/2018-01-15-preview/automation/version.go @@ -0,0 +1,30 @@ +package automation + +import "github.com/Azure/azure-sdk-for-go/version" + +// 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. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + version.Number + " automation/2018-01-15-preview" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +} diff --git a/services/preview/automation/mgmt/2018-01-15-preview/automation/watcher.go b/services/preview/automation/mgmt/2018-01-15-preview/automation/watcher.go new file mode 100644 index 000000000000..0039c8775aa2 --- /dev/null +++ b/services/preview/automation/mgmt/2018-01-15-preview/automation/watcher.go @@ -0,0 +1,613 @@ +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" +) + +// WatcherClient is the automation Client +type WatcherClient struct { + BaseClient +} + +// NewWatcherClient creates an instance of the WatcherClient client. +func NewWatcherClient(subscriptionID string, countType1 CountType) WatcherClient { + return NewWatcherClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewWatcherClientWithBaseURI creates an instance of the WatcherClient client. +func NewWatcherClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) WatcherClient { + return WatcherClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// CreateOrUpdate create the watcher identified by watcher name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// watcherName - the watcher name. +// parameters - the create or update parameters for watcher. +func (client WatcherClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, automationAccountName string, watcherName string, parameters Watcher) (result Watcher, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.WatcherClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, automationAccountName, watcherName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WatcherClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.WatcherClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WatcherClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client WatcherClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, watcherName string, parameters Watcher) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "watcherName": autorest.Encode("path", watcherName), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client WatcherClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client WatcherClient) CreateOrUpdateResponder(resp *http.Response) (result Watcher, 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 delete the watcher by name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// watcherName - the watcher name. +func (client WatcherClient) Delete(ctx context.Context, resourceGroupName string, automationAccountName string, watcherName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.WatcherClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, automationAccountName, watcherName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WatcherClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.WatcherClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WatcherClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client WatcherClient) DeletePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, watcherName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "watcherName": autorest.Encode("path", watcherName), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client WatcherClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client WatcherClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get retrieve the watcher identified by watcher name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// watcherName - the watcher name. +func (client WatcherClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string, watcherName string) (result Watcher, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.WatcherClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName, watcherName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WatcherClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.WatcherClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WatcherClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client WatcherClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, watcherName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "watcherName": autorest.Encode("path", watcherName), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client WatcherClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client WatcherClient) GetResponder(resp *http.Response) (result Watcher, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of watchers. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// filter - the filter to apply on the operation. +func (client WatcherClient) ListByAutomationAccount(ctx context.Context, resourceGroupName string, automationAccountName string, filter string) (result WatcherListResultPage, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.WatcherClient", "ListByAutomationAccount", err.Error()) + } + + result.fn = client.listByAutomationAccountNextResults + req, err := client.ListByAutomationAccountPreparer(ctx, resourceGroupName, automationAccountName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WatcherClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.wlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.WatcherClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result.wlr, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WatcherClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client WatcherClient) ListByAutomationAccountPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers", 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 WatcherClient) 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 WatcherClient) ListByAutomationAccountResponder(resp *http.Response) (result WatcherListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByAutomationAccountNextResults retrieves the next set of results, if any. +func (client WatcherClient) listByAutomationAccountNextResults(lastResults WatcherListResult) (result WatcherListResult, err error) { + req, err := lastResults.watcherListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.WatcherClient", "listByAutomationAccountNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.WatcherClient", "listByAutomationAccountNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WatcherClient", "listByAutomationAccountNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByAutomationAccountComplete enumerates all values, automatically crossing page boundaries as required. +func (client WatcherClient) ListByAutomationAccountComplete(ctx context.Context, resourceGroupName string, automationAccountName string, filter string) (result WatcherListResultIterator, err error) { + result.page, err = client.ListByAutomationAccount(ctx, resourceGroupName, automationAccountName, filter) + return +} + +// Start resume the watcher identified by watcher name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// watcherName - the watcher name. +func (client WatcherClient) Start(ctx context.Context, resourceGroupName string, automationAccountName string, watcherName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.WatcherClient", "Start", err.Error()) + } + + req, err := client.StartPreparer(ctx, resourceGroupName, automationAccountName, watcherName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WatcherClient", "Start", nil, "Failure preparing request") + return + } + + resp, err := client.StartSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.WatcherClient", "Start", resp, "Failure sending request") + return + } + + result, err = client.StartResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WatcherClient", "Start", resp, "Failure responding to request") + } + + return +} + +// StartPreparer prepares the Start request. +func (client WatcherClient) StartPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, watcherName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "watcherName": autorest.Encode("path", watcherName), + } + + 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}/watchers/{watcherName}/start", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// StartSender sends the Start request. The method will close the +// http.Response Body if it receives an error. +func (client WatcherClient) StartSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// StartResponder handles the response to the Start request. The method always +// closes the http.Response Body. +func (client WatcherClient) StartResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Stop resume the watcher identified by watcher name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// watcherName - the watcher name. +func (client WatcherClient) Stop(ctx context.Context, resourceGroupName string, automationAccountName string, watcherName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.WatcherClient", "Stop", err.Error()) + } + + req, err := client.StopPreparer(ctx, resourceGroupName, automationAccountName, watcherName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WatcherClient", "Stop", nil, "Failure preparing request") + return + } + + resp, err := client.StopSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.WatcherClient", "Stop", resp, "Failure sending request") + return + } + + result, err = client.StopResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WatcherClient", "Stop", resp, "Failure responding to request") + } + + return +} + +// StopPreparer prepares the Stop request. +func (client WatcherClient) StopPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, watcherName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "watcherName": autorest.Encode("path", watcherName), + } + + 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}/watchers/{watcherName}/stop", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// StopSender sends the Stop request. The method will close the +// http.Response Body if it receives an error. +func (client WatcherClient) StopSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// StopResponder handles the response to the Stop request. The method always +// closes the http.Response Body. +func (client WatcherClient) StopResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Update update the watcher identified by watcher name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// watcherName - the watcher name. +// parameters - the update parameters for watcher. +func (client WatcherClient) Update(ctx context.Context, resourceGroupName string, automationAccountName string, watcherName string, parameters WatcherUpdateParameters) (result Watcher, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.WatcherClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, automationAccountName, watcherName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WatcherClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.WatcherClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WatcherClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client WatcherClient) UpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, watcherName string, parameters WatcherUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "watcherName": autorest.Encode("path", watcherName), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client WatcherClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client WatcherClient) UpdateResponder(resp *http.Response) (result Watcher, 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/preview/automation/mgmt/2018-01-15-preview/automation/webhook.go b/services/preview/automation/mgmt/2018-01-15-preview/automation/webhook.go new file mode 100644 index 000000000000..989daa4c5e47 --- /dev/null +++ b/services/preview/automation/mgmt/2018-01-15-preview/automation/webhook.go @@ -0,0 +1,539 @@ +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" +) + +// WebhookClient is the automation Client +type WebhookClient struct { + BaseClient +} + +// NewWebhookClient creates an instance of the WebhookClient client. +func NewWebhookClient(subscriptionID string, countType1 CountType) WebhookClient { + return NewWebhookClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewWebhookClientWithBaseURI creates an instance of the WebhookClient client. +func NewWebhookClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) WebhookClient { + return WebhookClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// CreateOrUpdate create the webhook identified by webhook name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// webhookName - the webhook name. +// parameters - the create or update parameters for webhook. +func (client WebhookClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, automationAccountName string, webhookName string, parameters WebhookCreateOrUpdateParameters) (result Webhook, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.WebhookCreateOrUpdateProperties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.WebhookClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, automationAccountName, webhookName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client WebhookClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, webhookName string, parameters WebhookCreateOrUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "webhookName": autorest.Encode("path", webhookName), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client WebhookClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client WebhookClient) CreateOrUpdateResponder(resp *http.Response) (result Webhook, 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 delete the webhook by name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// webhookName - the webhook name. +func (client WebhookClient) Delete(ctx context.Context, resourceGroupName string, automationAccountName string, webhookName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.WebhookClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, automationAccountName, webhookName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client WebhookClient) DeletePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, webhookName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "webhookName": autorest.Encode("path", webhookName), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client WebhookClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client WebhookClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// GenerateURI generates a Uri for use in creating a webhook. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +func (client WebhookClient) GenerateURI(ctx context.Context, resourceGroupName string, automationAccountName string) (result String, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.WebhookClient", "GenerateURI", err.Error()) + } + + req, err := client.GenerateURIPreparer(ctx, resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "GenerateURI", nil, "Failure preparing request") + return + } + + resp, err := client.GenerateURISender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "GenerateURI", resp, "Failure sending request") + return + } + + result, err = client.GenerateURIResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "GenerateURI", resp, "Failure responding to request") + } + + return +} + +// GenerateURIPreparer prepares the GenerateURI request. +func (client WebhookClient) GenerateURIPreparer(ctx context.Context, resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", 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}/webhooks/generateUri", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GenerateURISender sends the GenerateURI request. The method will close the +// http.Response Body if it receives an error. +func (client WebhookClient) GenerateURISender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GenerateURIResponder handles the response to the GenerateURI request. The method always +// closes the http.Response Body. +func (client WebhookClient) GenerateURIResponder(resp *http.Response) (result String, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Value), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get retrieve the webhook identified by webhook name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// webhookName - the webhook name. +func (client WebhookClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string, webhookName string) (result Webhook, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.WebhookClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName, webhookName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client WebhookClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, webhookName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "webhookName": autorest.Encode("path", webhookName), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client WebhookClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client WebhookClient) GetResponder(resp *http.Response) (result Webhook, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of webhooks. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// filter - the filter to apply on the operation. +func (client WebhookClient) ListByAutomationAccount(ctx context.Context, resourceGroupName string, automationAccountName string, filter string) (result WebhookListResultPage, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.WebhookClient", "ListByAutomationAccount", err.Error()) + } + + result.fn = client.listByAutomationAccountNextResults + req, err := client.ListByAutomationAccountPreparer(ctx, resourceGroupName, automationAccountName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.wlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result.wlr, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client WebhookClient) ListByAutomationAccountPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks", 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 WebhookClient) 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 WebhookClient) ListByAutomationAccountResponder(resp *http.Response) (result WebhookListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByAutomationAccountNextResults retrieves the next set of results, if any. +func (client WebhookClient) listByAutomationAccountNextResults(lastResults WebhookListResult) (result WebhookListResult, err error) { + req, err := lastResults.webhookListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.WebhookClient", "listByAutomationAccountNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.WebhookClient", "listByAutomationAccountNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "listByAutomationAccountNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByAutomationAccountComplete enumerates all values, automatically crossing page boundaries as required. +func (client WebhookClient) ListByAutomationAccountComplete(ctx context.Context, resourceGroupName string, automationAccountName string, filter string) (result WebhookListResultIterator, err error) { + result.page, err = client.ListByAutomationAccount(ctx, resourceGroupName, automationAccountName, filter) + return +} + +// Update update the webhook identified by webhook name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// webhookName - the webhook name. +// parameters - the update parameters for webhook. +func (client WebhookClient) Update(ctx context.Context, resourceGroupName string, automationAccountName string, webhookName string, parameters WebhookUpdateParameters) (result Webhook, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.WebhookClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, automationAccountName, webhookName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client WebhookClient) UpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, webhookName string, parameters WebhookUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "webhookName": autorest.Encode("path", webhookName), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client WebhookClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client WebhookClient) UpdateResponder(resp *http.Response) (result Webhook, 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/preview/automation/mgmt/2018-06-30-preview/automation/account.go b/services/preview/automation/mgmt/2018-06-30-preview/automation/account.go new file mode 100644 index 000000000000..ca92a9118901 --- /dev/null +++ b/services/preview/automation/mgmt/2018-06-30-preview/automation/account.go @@ -0,0 +1,537 @@ +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" +) + +// AccountClient is the automation Client +type AccountClient struct { + BaseClient +} + +// NewAccountClient creates an instance of the AccountClient client. +func NewAccountClient(subscriptionID string, countType1 CountType) AccountClient { + return NewAccountClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewAccountClientWithBaseURI creates an instance of the AccountClient client. +func NewAccountClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) AccountClient { + return AccountClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// CreateOrUpdate create or update automation account. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// parameters - parameters supplied to the create or update automation account. +func (client AccountClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, automationAccountName string, parameters AccountCreateOrUpdateParameters) (result Account, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.AccountClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, automationAccountName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AccountClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.AccountClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AccountClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client AccountClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, parameters AccountCreateOrUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client AccountClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client AccountClient) CreateOrUpdateResponder(resp *http.Response) (result Account, 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 delete an automation account. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +func (client AccountClient) Delete(ctx context.Context, resourceGroupName string, automationAccountName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.AccountClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AccountClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.AccountClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AccountClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client AccountClient) DeletePreparer(ctx context.Context, resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client AccountClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client AccountClient) 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 get information about an Automation Account. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +func (client AccountClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string) (result Account, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.AccountClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AccountClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.AccountClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AccountClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client AccountClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client AccountClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client AccountClient) GetResponder(resp *http.Response) (result Account, 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 retrieve a list of accounts within a given subscription. +func (client AccountClient) List(ctx context.Context) (result AccountListResultPage, err error) { + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AccountClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.alr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.AccountClient", "List", resp, "Failure sending request") + return + } + + result.alr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AccountClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client AccountClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Automation/automationAccounts", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client AccountClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client AccountClient) ListResponder(resp *http.Response) (result AccountListResult, 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 AccountClient) listNextResults(lastResults AccountListResult) (result AccountListResult, err error) { + req, err := lastResults.accountListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.AccountClient", "listNextResults", 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, "automation.AccountClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AccountClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client AccountClient) ListComplete(ctx context.Context) (result AccountListResultIterator, err error) { + result.page, err = client.List(ctx) + return +} + +// ListByResourceGroup retrieve a list of accounts within a given resource group. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +func (client AccountClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result AccountListResultPage, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.AccountClient", "ListByResourceGroup", err.Error()) + } + + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AccountClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.alr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.AccountClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.alr, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AccountClient", "ListByResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client AccountClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client AccountClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client AccountClient) ListByResourceGroupResponder(resp *http.Response) (result AccountListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client AccountClient) listByResourceGroupNextResults(lastResults AccountListResult) (result AccountListResult, err error) { + req, err := lastResults.accountListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.AccountClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.AccountClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AccountClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client AccountClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result AccountListResultIterator, err error) { + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// Update update an automation account. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// parameters - parameters supplied to the update automation account. +func (client AccountClient) Update(ctx context.Context, resourceGroupName string, automationAccountName string, parameters AccountUpdateParameters) (result Account, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.AccountClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, automationAccountName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AccountClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.AccountClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AccountClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client AccountClient) UpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, parameters AccountUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client AccountClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client AccountClient) UpdateResponder(resp *http.Response) (result Account, 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/preview/automation/mgmt/2018-06-30-preview/automation/activity.go b/services/preview/automation/mgmt/2018-06-30-preview/automation/activity.go new file mode 100644 index 000000000000..e81a3d90118f --- /dev/null +++ b/services/preview/automation/mgmt/2018-06-30-preview/automation/activity.go @@ -0,0 +1,225 @@ +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" +) + +// ActivityClient is the automation Client +type ActivityClient struct { + BaseClient +} + +// NewActivityClient creates an instance of the ActivityClient client. +func NewActivityClient(subscriptionID string, countType1 CountType) ActivityClient { + return NewActivityClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewActivityClientWithBaseURI creates an instance of the ActivityClient client. +func NewActivityClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) ActivityClient { + return ActivityClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// Get retrieve the activity in the module identified by module name and activity name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// moduleName - the name of module. +// activityName - the name of activity. +func (client ActivityClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string, moduleName string, activityName string) (result Activity, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.ActivityClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName, moduleName, activityName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ActivityClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ActivityClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ActivityClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ActivityClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, moduleName string, activityName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "activityName": autorest.Encode("path", activityName), + "automationAccountName": autorest.Encode("path", automationAccountName), + "moduleName": autorest.Encode("path", moduleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/activities/{activityName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ActivityClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ActivityClient) GetResponder(resp *http.Response) (result Activity, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByModule retrieve a list of activities in the module identified by module name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// moduleName - the name of module. +func (client ActivityClient) ListByModule(ctx context.Context, resourceGroupName string, automationAccountName string, moduleName string) (result ActivityListResultPage, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.ActivityClient", "ListByModule", err.Error()) + } + + result.fn = client.listByModuleNextResults + req, err := client.ListByModulePreparer(ctx, resourceGroupName, automationAccountName, moduleName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ActivityClient", "ListByModule", nil, "Failure preparing request") + return + } + + resp, err := client.ListByModuleSender(req) + if err != nil { + result.alr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ActivityClient", "ListByModule", resp, "Failure sending request") + return + } + + result.alr, err = client.ListByModuleResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ActivityClient", "ListByModule", resp, "Failure responding to request") + } + + return +} + +// ListByModulePreparer prepares the ListByModule request. +func (client ActivityClient) ListByModulePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, moduleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "moduleName": autorest.Encode("path", moduleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/activities", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByModuleSender sends the ListByModule request. The method will close the +// http.Response Body if it receives an error. +func (client ActivityClient) ListByModuleSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByModuleResponder handles the response to the ListByModule request. The method always +// closes the http.Response Body. +func (client ActivityClient) ListByModuleResponder(resp *http.Response) (result ActivityListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByModuleNextResults retrieves the next set of results, if any. +func (client ActivityClient) listByModuleNextResults(lastResults ActivityListResult) (result ActivityListResult, err error) { + req, err := lastResults.activityListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.ActivityClient", "listByModuleNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByModuleSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.ActivityClient", "listByModuleNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByModuleResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ActivityClient", "listByModuleNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByModuleComplete enumerates all values, automatically crossing page boundaries as required. +func (client ActivityClient) ListByModuleComplete(ctx context.Context, resourceGroupName string, automationAccountName string, moduleName string) (result ActivityListResultIterator, err error) { + result.page, err = client.ListByModule(ctx, resourceGroupName, automationAccountName, moduleName) + return +} diff --git a/services/preview/automation/mgmt/2018-06-30-preview/automation/agentregistrationinformation.go b/services/preview/automation/mgmt/2018-06-30-preview/automation/agentregistrationinformation.go new file mode 100644 index 000000000000..02d73956c48d --- /dev/null +++ b/services/preview/automation/mgmt/2018-06-30-preview/automation/agentregistrationinformation.go @@ -0,0 +1,195 @@ +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" +) + +// AgentRegistrationInformationClient is the automation Client +type AgentRegistrationInformationClient struct { + BaseClient +} + +// NewAgentRegistrationInformationClient creates an instance of the AgentRegistrationInformationClient client. +func NewAgentRegistrationInformationClient(subscriptionID string, countType1 CountType) AgentRegistrationInformationClient { + return NewAgentRegistrationInformationClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewAgentRegistrationInformationClientWithBaseURI creates an instance of the AgentRegistrationInformationClient +// client. +func NewAgentRegistrationInformationClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) AgentRegistrationInformationClient { + return AgentRegistrationInformationClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// Get retrieve the automation agent registration information. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +func (client AgentRegistrationInformationClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string) (result AgentRegistration, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.AgentRegistrationInformationClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AgentRegistrationInformationClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.AgentRegistrationInformationClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AgentRegistrationInformationClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client AgentRegistrationInformationClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-01-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/agentRegistrationInformation", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client AgentRegistrationInformationClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client AgentRegistrationInformationClient) GetResponder(resp *http.Response) (result AgentRegistration, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// RegenerateKey regenerate a primary or secondary agent registration key +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// parameters - the name of the agent registration key to be regenerated +func (client AgentRegistrationInformationClient) RegenerateKey(ctx context.Context, resourceGroupName string, automationAccountName string, parameters AgentRegistrationRegenerateKeyParameter) (result AgentRegistration, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.AgentRegistrationInformationClient", "RegenerateKey", err.Error()) + } + + req, err := client.RegenerateKeyPreparer(ctx, resourceGroupName, automationAccountName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AgentRegistrationInformationClient", "RegenerateKey", nil, "Failure preparing request") + return + } + + resp, err := client.RegenerateKeySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.AgentRegistrationInformationClient", "RegenerateKey", resp, "Failure sending request") + return + } + + result, err = client.RegenerateKeyResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AgentRegistrationInformationClient", "RegenerateKey", resp, "Failure responding to request") + } + + return +} + +// RegenerateKeyPreparer prepares the RegenerateKey request. +func (client AgentRegistrationInformationClient) RegenerateKeyPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, parameters AgentRegistrationRegenerateKeyParameter) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-01-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/agentRegistrationInformation/regenerateKey", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// RegenerateKeySender sends the RegenerateKey request. The method will close the +// http.Response Body if it receives an error. +func (client AgentRegistrationInformationClient) RegenerateKeySender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// RegenerateKeyResponder handles the response to the RegenerateKey request. The method always +// closes the http.Response Body. +func (client AgentRegistrationInformationClient) RegenerateKeyResponder(resp *http.Response) (result AgentRegistration, 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/preview/automation/mgmt/2018-06-30-preview/automation/certificate.go b/services/preview/automation/mgmt/2018-06-30-preview/automation/certificate.go new file mode 100644 index 000000000000..d0124ad01d04 --- /dev/null +++ b/services/preview/automation/mgmt/2018-06-30-preview/automation/certificate.go @@ -0,0 +1,461 @@ +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" +) + +// CertificateClient is the automation Client +type CertificateClient struct { + BaseClient +} + +// NewCertificateClient creates an instance of the CertificateClient client. +func NewCertificateClient(subscriptionID string, countType1 CountType) CertificateClient { + return NewCertificateClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewCertificateClientWithBaseURI creates an instance of the CertificateClient client. +func NewCertificateClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) CertificateClient { + return CertificateClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// CreateOrUpdate create a certificate. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// certificateName - the parameters supplied to the create or update certificate operation. +// parameters - the parameters supplied to the create or update certificate operation. +func (client CertificateClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, automationAccountName string, certificateName string, parameters CertificateCreateOrUpdateParameters) (result Certificate, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.CertificateCreateOrUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.CertificateCreateOrUpdateProperties.Base64Value", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("automation.CertificateClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, automationAccountName, certificateName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client CertificateClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, certificateName string, parameters CertificateCreateOrUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "certificateName": autorest.Encode("path", certificateName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client CertificateClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client CertificateClient) CreateOrUpdateResponder(resp *http.Response) (result Certificate, 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 delete the certificate. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// certificateName - the name of certificate. +func (client CertificateClient) Delete(ctx context.Context, resourceGroupName string, automationAccountName string, certificateName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.CertificateClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, automationAccountName, certificateName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client CertificateClient) DeletePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, certificateName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "certificateName": autorest.Encode("path", certificateName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client CertificateClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client CertificateClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get retrieve the certificate identified by certificate name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// certificateName - the name of certificate. +func (client CertificateClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string, certificateName string) (result Certificate, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.CertificateClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName, certificateName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client CertificateClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, certificateName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "certificateName": autorest.Encode("path", certificateName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client CertificateClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client CertificateClient) GetResponder(resp *http.Response) (result Certificate, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of certificates. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +func (client CertificateClient) ListByAutomationAccount(ctx context.Context, resourceGroupName string, automationAccountName string) (result CertificateListResultPage, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.CertificateClient", "ListByAutomationAccount", err.Error()) + } + + result.fn = client.listByAutomationAccountNextResults + req, err := client.ListByAutomationAccountPreparer(ctx, resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.clr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result.clr, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client CertificateClient) ListByAutomationAccountPreparer(ctx context.Context, resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates", 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 CertificateClient) 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 CertificateClient) ListByAutomationAccountResponder(resp *http.Response) (result CertificateListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByAutomationAccountNextResults retrieves the next set of results, if any. +func (client CertificateClient) listByAutomationAccountNextResults(lastResults CertificateListResult) (result CertificateListResult, err error) { + req, err := lastResults.certificateListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.CertificateClient", "listByAutomationAccountNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.CertificateClient", "listByAutomationAccountNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "listByAutomationAccountNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByAutomationAccountComplete enumerates all values, automatically crossing page boundaries as required. +func (client CertificateClient) ListByAutomationAccountComplete(ctx context.Context, resourceGroupName string, automationAccountName string) (result CertificateListResultIterator, err error) { + result.page, err = client.ListByAutomationAccount(ctx, resourceGroupName, automationAccountName) + return +} + +// Update update a certificate. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// certificateName - the parameters supplied to the update certificate operation. +// parameters - the parameters supplied to the update certificate operation. +func (client CertificateClient) Update(ctx context.Context, resourceGroupName string, automationAccountName string, certificateName string, parameters CertificateUpdateParameters) (result Certificate, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.CertificateClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, automationAccountName, certificateName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client CertificateClient) UpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, certificateName string, parameters CertificateUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "certificateName": autorest.Encode("path", certificateName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client CertificateClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client CertificateClient) UpdateResponder(resp *http.Response) (result Certificate, 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/preview/automation/mgmt/2018-06-30-preview/automation/client.go b/services/preview/automation/mgmt/2018-06-30-preview/automation/client.go new file mode 100644 index 000000000000..35ec8db368d7 --- /dev/null +++ b/services/preview/automation/mgmt/2018-06-30-preview/automation/client.go @@ -0,0 +1,53 @@ +// Package automation implements the Azure ARM Automation service API version . +// +// Automation Client +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 ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Automation + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Automation. +type BaseClient struct { + autorest.Client + BaseURI string + SubscriptionID string + CountType1 CountType +} + +// New creates an instance of the BaseClient client. +func New(subscriptionID string, countType1 CountType) BaseClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewWithBaseURI creates an instance of the BaseClient client. +func NewWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + CountType1: countType1, + } +} diff --git a/services/preview/automation/mgmt/2018-06-30-preview/automation/connection.go b/services/preview/automation/mgmt/2018-06-30-preview/automation/connection.go new file mode 100644 index 000000000000..34ebae556858 --- /dev/null +++ b/services/preview/automation/mgmt/2018-06-30-preview/automation/connection.go @@ -0,0 +1,462 @@ +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" +) + +// ConnectionClient is the automation Client +type ConnectionClient struct { + BaseClient +} + +// NewConnectionClient creates an instance of the ConnectionClient client. +func NewConnectionClient(subscriptionID string, countType1 CountType) ConnectionClient { + return NewConnectionClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewConnectionClientWithBaseURI creates an instance of the ConnectionClient client. +func NewConnectionClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) ConnectionClient { + return ConnectionClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// CreateOrUpdate create or update a connection. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// connectionName - the parameters supplied to the create or update connection operation. +// parameters - the parameters supplied to the create or update connection operation. +func (client ConnectionClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, automationAccountName string, connectionName string, parameters ConnectionCreateOrUpdateParameters) (result Connection, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ConnectionCreateOrUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ConnectionCreateOrUpdateProperties.ConnectionType", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("automation.ConnectionClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, automationAccountName, connectionName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ConnectionClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, connectionName string, parameters ConnectionCreateOrUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "connectionName": autorest.Encode("path", connectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ConnectionClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ConnectionClient) CreateOrUpdateResponder(resp *http.Response) (result Connection, 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 delete the connection. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// connectionName - the name of connection. +func (client ConnectionClient) Delete(ctx context.Context, resourceGroupName string, automationAccountName string, connectionName string) (result Connection, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.ConnectionClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, automationAccountName, connectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ConnectionClient) DeletePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, connectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "connectionName": autorest.Encode("path", connectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ConnectionClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ConnectionClient) DeleteResponder(resp *http.Response) (result Connection, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get retrieve the connection identified by connection name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// connectionName - the name of connection. +func (client ConnectionClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string, connectionName string) (result Connection, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.ConnectionClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName, connectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ConnectionClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, connectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "connectionName": autorest.Encode("path", connectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ConnectionClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ConnectionClient) GetResponder(resp *http.Response) (result Connection, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of connections. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +func (client ConnectionClient) ListByAutomationAccount(ctx context.Context, resourceGroupName string, automationAccountName string) (result ConnectionListResultPage, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.ConnectionClient", "ListByAutomationAccount", err.Error()) + } + + result.fn = client.listByAutomationAccountNextResults + req, err := client.ListByAutomationAccountPreparer(ctx, resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.clr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result.clr, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client ConnectionClient) ListByAutomationAccountPreparer(ctx context.Context, resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections", 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 ConnectionClient) 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 ConnectionClient) ListByAutomationAccountResponder(resp *http.Response) (result ConnectionListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByAutomationAccountNextResults retrieves the next set of results, if any. +func (client ConnectionClient) listByAutomationAccountNextResults(lastResults ConnectionListResult) (result ConnectionListResult, err error) { + req, err := lastResults.connectionListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.ConnectionClient", "listByAutomationAccountNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.ConnectionClient", "listByAutomationAccountNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "listByAutomationAccountNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByAutomationAccountComplete enumerates all values, automatically crossing page boundaries as required. +func (client ConnectionClient) ListByAutomationAccountComplete(ctx context.Context, resourceGroupName string, automationAccountName string) (result ConnectionListResultIterator, err error) { + result.page, err = client.ListByAutomationAccount(ctx, resourceGroupName, automationAccountName) + return +} + +// Update update a connection. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// connectionName - the parameters supplied to the update a connection operation. +// parameters - the parameters supplied to the update a connection operation. +func (client ConnectionClient) Update(ctx context.Context, resourceGroupName string, automationAccountName string, connectionName string, parameters ConnectionUpdateParameters) (result Connection, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.ConnectionClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, automationAccountName, connectionName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ConnectionClient) UpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, connectionName string, parameters ConnectionUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "connectionName": autorest.Encode("path", connectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client ConnectionClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ConnectionClient) UpdateResponder(resp *http.Response) (result Connection, 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/preview/automation/mgmt/2018-06-30-preview/automation/connectiontype.go b/services/preview/automation/mgmt/2018-06-30-preview/automation/connectiontype.go new file mode 100644 index 000000000000..d4277e164145 --- /dev/null +++ b/services/preview/automation/mgmt/2018-06-30-preview/automation/connectiontype.go @@ -0,0 +1,381 @@ +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" +) + +// ConnectionTypeClient is the automation Client +type ConnectionTypeClient struct { + BaseClient +} + +// NewConnectionTypeClient creates an instance of the ConnectionTypeClient client. +func NewConnectionTypeClient(subscriptionID string, countType1 CountType) ConnectionTypeClient { + return NewConnectionTypeClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewConnectionTypeClientWithBaseURI creates an instance of the ConnectionTypeClient client. +func NewConnectionTypeClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) ConnectionTypeClient { + return ConnectionTypeClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// CreateOrUpdate create a connectiontype. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// connectionTypeName - the parameters supplied to the create or update connectiontype operation. +// parameters - the parameters supplied to the create or update connectiontype operation. +func (client ConnectionTypeClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, automationAccountName string, connectionTypeName string, parameters ConnectionTypeCreateOrUpdateParameters) (result ConnectionType, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ConnectionTypeCreateOrUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ConnectionTypeCreateOrUpdateProperties.FieldDefinitions", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("automation.ConnectionTypeClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, automationAccountName, connectionTypeName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ConnectionTypeClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, connectionTypeName string, parameters ConnectionTypeCreateOrUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "connectionTypeName": autorest.Encode("path", connectionTypeName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes/{connectionTypeName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ConnectionTypeClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ConnectionTypeClient) CreateOrUpdateResponder(resp *http.Response) (result ConnectionType, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusConflict), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete the connectiontype. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// connectionTypeName - the name of connectiontype. +func (client ConnectionTypeClient) Delete(ctx context.Context, resourceGroupName string, automationAccountName string, connectionTypeName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.ConnectionTypeClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, automationAccountName, connectionTypeName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ConnectionTypeClient) DeletePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, connectionTypeName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "connectionTypeName": autorest.Encode("path", connectionTypeName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes/{connectionTypeName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ConnectionTypeClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ConnectionTypeClient) 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 retrieve the connectiontype identified by connectiontype name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// connectionTypeName - the name of connectiontype. +func (client ConnectionTypeClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string, connectionTypeName string) (result ConnectionType, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.ConnectionTypeClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName, connectionTypeName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ConnectionTypeClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, connectionTypeName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "connectionTypeName": autorest.Encode("path", connectionTypeName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes/{connectionTypeName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ConnectionTypeClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ConnectionTypeClient) GetResponder(resp *http.Response) (result ConnectionType, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of connectiontypes. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +func (client ConnectionTypeClient) ListByAutomationAccount(ctx context.Context, resourceGroupName string, automationAccountName string) (result ConnectionTypeListResultPage, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.ConnectionTypeClient", "ListByAutomationAccount", err.Error()) + } + + result.fn = client.listByAutomationAccountNextResults + req, err := client.ListByAutomationAccountPreparer(ctx, resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.ctlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result.ctlr, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client ConnectionTypeClient) ListByAutomationAccountPreparer(ctx context.Context, resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes", 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 ConnectionTypeClient) 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 ConnectionTypeClient) ListByAutomationAccountResponder(resp *http.Response) (result ConnectionTypeListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByAutomationAccountNextResults retrieves the next set of results, if any. +func (client ConnectionTypeClient) listByAutomationAccountNextResults(lastResults ConnectionTypeListResult) (result ConnectionTypeListResult, err error) { + req, err := lastResults.connectionTypeListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "listByAutomationAccountNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "listByAutomationAccountNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "listByAutomationAccountNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByAutomationAccountComplete enumerates all values, automatically crossing page boundaries as required. +func (client ConnectionTypeClient) ListByAutomationAccountComplete(ctx context.Context, resourceGroupName string, automationAccountName string) (result ConnectionTypeListResultIterator, err error) { + result.page, err = client.ListByAutomationAccount(ctx, resourceGroupName, automationAccountName) + return +} diff --git a/services/preview/automation/mgmt/2018-06-30-preview/automation/credential.go b/services/preview/automation/mgmt/2018-06-30-preview/automation/credential.go new file mode 100644 index 000000000000..ae5410ab911e --- /dev/null +++ b/services/preview/automation/mgmt/2018-06-30-preview/automation/credential.go @@ -0,0 +1,463 @@ +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" +) + +// CredentialClient is the automation Client +type CredentialClient struct { + BaseClient +} + +// NewCredentialClient creates an instance of the CredentialClient client. +func NewCredentialClient(subscriptionID string, countType1 CountType) CredentialClient { + return NewCredentialClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewCredentialClientWithBaseURI creates an instance of the CredentialClient client. +func NewCredentialClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) CredentialClient { + return CredentialClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// CreateOrUpdate create a credential. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// credentialName - the parameters supplied to the create or update credential operation. +// parameters - the parameters supplied to the create or update credential operation. +func (client CredentialClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, automationAccountName string, credentialName string, parameters CredentialCreateOrUpdateParameters) (result Credential, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.CredentialCreateOrUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.CredentialCreateOrUpdateProperties.UserName", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.CredentialCreateOrUpdateProperties.Password", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("automation.CredentialClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, automationAccountName, credentialName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client CredentialClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, credentialName string, parameters CredentialCreateOrUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "credentialName": autorest.Encode("path", credentialName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client CredentialClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client CredentialClient) CreateOrUpdateResponder(resp *http.Response) (result Credential, 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 delete the credential. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// credentialName - the name of credential. +func (client CredentialClient) Delete(ctx context.Context, resourceGroupName string, automationAccountName string, credentialName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.CredentialClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, automationAccountName, credentialName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client CredentialClient) DeletePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, credentialName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "credentialName": autorest.Encode("path", credentialName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client CredentialClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client CredentialClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get retrieve the credential identified by credential name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// credentialName - the name of credential. +func (client CredentialClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string, credentialName string) (result Credential, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.CredentialClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName, credentialName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client CredentialClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, credentialName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "credentialName": autorest.Encode("path", credentialName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client CredentialClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client CredentialClient) GetResponder(resp *http.Response) (result Credential, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of credentials. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +func (client CredentialClient) ListByAutomationAccount(ctx context.Context, resourceGroupName string, automationAccountName string) (result CredentialListResultPage, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.CredentialClient", "ListByAutomationAccount", err.Error()) + } + + result.fn = client.listByAutomationAccountNextResults + req, err := client.ListByAutomationAccountPreparer(ctx, resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.clr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result.clr, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client CredentialClient) ListByAutomationAccountPreparer(ctx context.Context, resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials", 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 CredentialClient) 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 CredentialClient) ListByAutomationAccountResponder(resp *http.Response) (result CredentialListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByAutomationAccountNextResults retrieves the next set of results, if any. +func (client CredentialClient) listByAutomationAccountNextResults(lastResults CredentialListResult) (result CredentialListResult, err error) { + req, err := lastResults.credentialListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.CredentialClient", "listByAutomationAccountNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.CredentialClient", "listByAutomationAccountNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "listByAutomationAccountNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByAutomationAccountComplete enumerates all values, automatically crossing page boundaries as required. +func (client CredentialClient) ListByAutomationAccountComplete(ctx context.Context, resourceGroupName string, automationAccountName string) (result CredentialListResultIterator, err error) { + result.page, err = client.ListByAutomationAccount(ctx, resourceGroupName, automationAccountName) + return +} + +// Update update a credential. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// credentialName - the parameters supplied to the Update credential operation. +// parameters - the parameters supplied to the Update credential operation. +func (client CredentialClient) Update(ctx context.Context, resourceGroupName string, automationAccountName string, credentialName string, parameters CredentialUpdateParameters) (result Credential, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.CredentialClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, automationAccountName, credentialName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client CredentialClient) UpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, credentialName string, parameters CredentialUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "credentialName": autorest.Encode("path", credentialName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client CredentialClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client CredentialClient) UpdateResponder(resp *http.Response) (result Credential, 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/preview/automation/mgmt/2018-06-30-preview/automation/dsccompilationjob.go b/services/preview/automation/mgmt/2018-06-30-preview/automation/dsccompilationjob.go new file mode 100644 index 000000000000..673577eaafd8 --- /dev/null +++ b/services/preview/automation/mgmt/2018-06-30-preview/automation/dsccompilationjob.go @@ -0,0 +1,392 @@ +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" + "github.com/satori/go.uuid" + "net/http" +) + +// DscCompilationJobClient is the automation Client +type DscCompilationJobClient struct { + BaseClient +} + +// NewDscCompilationJobClient creates an instance of the DscCompilationJobClient client. +func NewDscCompilationJobClient(subscriptionID string, countType1 CountType) DscCompilationJobClient { + return NewDscCompilationJobClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewDscCompilationJobClientWithBaseURI creates an instance of the DscCompilationJobClient client. +func NewDscCompilationJobClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) DscCompilationJobClient { + return DscCompilationJobClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// Create creates the Dsc compilation job of the configuration. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// compilationJobName - the the DSC configuration Id. +// parameters - the parameters supplied to the create compilation job operation. +func (client DscCompilationJobClient) Create(ctx context.Context, resourceGroupName string, automationAccountName string, compilationJobName string, parameters DscCompilationJobCreateParameters) (result DscCompilationJobCreateFuture, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.DscCompilationJobCreateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.DscCompilationJobCreateProperties.Configuration", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("automation.DscCompilationJobClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, automationAccountName, compilationJobName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobClient", "Create", nil, "Failure preparing request") + return + } + + result, err = client.CreateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobClient", "Create", result.Response(), "Failure sending request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client DscCompilationJobClient) CreatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, compilationJobName string, parameters DscCompilationJobCreateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "compilationJobName": autorest.Encode("path", compilationJobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-01-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{compilationJobName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client DscCompilationJobClient) CreateSender(req *http.Request) (future DscCompilationJobCreateFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client DscCompilationJobClient) CreateResponder(resp *http.Response) (result DscCompilationJob, 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 +} + +// Get retrieve the Dsc configuration compilation job identified by job id. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// compilationJobName - the the DSC configuration Id. +func (client DscCompilationJobClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string, compilationJobName string) (result DscCompilationJob, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.DscCompilationJobClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName, compilationJobName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client DscCompilationJobClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, compilationJobName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "compilationJobName": autorest.Encode("path", compilationJobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-01-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{compilationJobName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client DscCompilationJobClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DscCompilationJobClient) GetResponder(resp *http.Response) (result DscCompilationJob, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetStream retrieve the job stream identified by job stream id. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// jobID - the job id. +// jobStreamID - the job stream id. +func (client DscCompilationJobClient) GetStream(ctx context.Context, resourceGroupName string, automationAccountName string, jobID uuid.UUID, jobStreamID string) (result JobStream, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.DscCompilationJobClient", "GetStream", err.Error()) + } + + req, err := client.GetStreamPreparer(ctx, resourceGroupName, automationAccountName, jobID, jobStreamID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobClient", "GetStream", nil, "Failure preparing request") + return + } + + resp, err := client.GetStreamSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobClient", "GetStream", resp, "Failure sending request") + return + } + + result, err = client.GetStreamResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobClient", "GetStream", resp, "Failure responding to request") + } + + return +} + +// GetStreamPreparer prepares the GetStream request. +func (client DscCompilationJobClient) GetStreamPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, jobID uuid.UUID, jobStreamID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "jobId": autorest.Encode("path", jobID), + "jobStreamId": autorest.Encode("path", jobStreamID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-01-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{jobId}/streams/{jobStreamId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetStreamSender sends the GetStream request. The method will close the +// http.Response Body if it receives an error. +func (client DscCompilationJobClient) GetStreamSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetStreamResponder handles the response to the GetStream request. The method always +// closes the http.Response Body. +func (client DscCompilationJobClient) GetStreamResponder(resp *http.Response) (result JobStream, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of dsc compilation jobs. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// filter - the filter to apply on the operation. +func (client DscCompilationJobClient) ListByAutomationAccount(ctx context.Context, resourceGroupName string, automationAccountName string, filter string) (result DscCompilationJobListResultPage, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.DscCompilationJobClient", "ListByAutomationAccount", err.Error()) + } + + result.fn = client.listByAutomationAccountNextResults + req, err := client.ListByAutomationAccountPreparer(ctx, resourceGroupName, automationAccountName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.dcjlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result.dcjlr, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client DscCompilationJobClient) ListByAutomationAccountPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-01-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs", 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 DscCompilationJobClient) 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 DscCompilationJobClient) ListByAutomationAccountResponder(resp *http.Response) (result DscCompilationJobListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByAutomationAccountNextResults retrieves the next set of results, if any. +func (client DscCompilationJobClient) listByAutomationAccountNextResults(lastResults DscCompilationJobListResult) (result DscCompilationJobListResult, err error) { + req, err := lastResults.dscCompilationJobListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.DscCompilationJobClient", "listByAutomationAccountNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.DscCompilationJobClient", "listByAutomationAccountNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobClient", "listByAutomationAccountNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByAutomationAccountComplete enumerates all values, automatically crossing page boundaries as required. +func (client DscCompilationJobClient) ListByAutomationAccountComplete(ctx context.Context, resourceGroupName string, automationAccountName string, filter string) (result DscCompilationJobListResultIterator, err error) { + result.page, err = client.ListByAutomationAccount(ctx, resourceGroupName, automationAccountName, filter) + return +} diff --git a/services/preview/automation/mgmt/2018-06-30-preview/automation/dsccompilationjobstream.go b/services/preview/automation/mgmt/2018-06-30-preview/automation/dsccompilationjobstream.go new file mode 100644 index 000000000000..19ecbc9d0fab --- /dev/null +++ b/services/preview/automation/mgmt/2018-06-30-preview/automation/dsccompilationjobstream.go @@ -0,0 +1,119 @@ +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" + "github.com/satori/go.uuid" + "net/http" +) + +// DscCompilationJobStreamClient is the automation Client +type DscCompilationJobStreamClient struct { + BaseClient +} + +// NewDscCompilationJobStreamClient creates an instance of the DscCompilationJobStreamClient client. +func NewDscCompilationJobStreamClient(subscriptionID string, countType1 CountType) DscCompilationJobStreamClient { + return NewDscCompilationJobStreamClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewDscCompilationJobStreamClientWithBaseURI creates an instance of the DscCompilationJobStreamClient client. +func NewDscCompilationJobStreamClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) DscCompilationJobStreamClient { + return DscCompilationJobStreamClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// ListByJob retrieve all the job streams for the compilation Job. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// jobID - the job id. +func (client DscCompilationJobStreamClient) ListByJob(ctx context.Context, resourceGroupName string, automationAccountName string, jobID uuid.UUID) (result JobStreamListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.DscCompilationJobStreamClient", "ListByJob", err.Error()) + } + + req, err := client.ListByJobPreparer(ctx, resourceGroupName, automationAccountName, jobID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobStreamClient", "ListByJob", nil, "Failure preparing request") + return + } + + resp, err := client.ListByJobSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobStreamClient", "ListByJob", resp, "Failure sending request") + return + } + + result, err = client.ListByJobResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobStreamClient", "ListByJob", resp, "Failure responding to request") + } + + return +} + +// ListByJobPreparer prepares the ListByJob request. +func (client DscCompilationJobStreamClient) ListByJobPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, jobID uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "jobId": autorest.Encode("path", jobID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-01-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{jobId}/streams", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByJobSender sends the ListByJob request. The method will close the +// http.Response Body if it receives an error. +func (client DscCompilationJobStreamClient) ListByJobSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByJobResponder handles the response to the ListByJob request. The method always +// closes the http.Response Body. +func (client DscCompilationJobStreamClient) ListByJobResponder(resp *http.Response) (result JobStreamListResult, 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/preview/automation/mgmt/2018-06-30-preview/automation/dscconfiguration.go b/services/preview/automation/mgmt/2018-06-30-preview/automation/dscconfiguration.go new file mode 100644 index 000000000000..bf7c044b9ad5 --- /dev/null +++ b/services/preview/automation/mgmt/2018-06-30-preview/automation/dscconfiguration.go @@ -0,0 +1,561 @@ +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" +) + +// DscConfigurationClient is the automation Client +type DscConfigurationClient struct { + BaseClient +} + +// NewDscConfigurationClient creates an instance of the DscConfigurationClient client. +func NewDscConfigurationClient(subscriptionID string, countType1 CountType) DscConfigurationClient { + return NewDscConfigurationClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewDscConfigurationClientWithBaseURI creates an instance of the DscConfigurationClient client. +func NewDscConfigurationClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) DscConfigurationClient { + return DscConfigurationClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// CreateOrUpdate create the configuration identified by configuration name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// configurationName - the create or update parameters for configuration. +// parameters - the create or update parameters for configuration. +func (client DscConfigurationClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, automationAccountName string, configurationName string, parameters DscConfigurationCreateOrUpdateParameters) (result DscConfiguration, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.DscConfigurationCreateOrUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.DscConfigurationCreateOrUpdateProperties.Source", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.DscConfigurationCreateOrUpdateProperties.Source.Hash", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.DscConfigurationCreateOrUpdateProperties.Source.Hash.Algorithm", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.DscConfigurationCreateOrUpdateProperties.Source.Hash.Value", Name: validation.Null, Rule: true, Chain: nil}, + }}, + }}, + }}}}}); err != nil { + return result, validation.NewError("automation.DscConfigurationClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, automationAccountName, configurationName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client DscConfigurationClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, configurationName string, parameters DscConfigurationCreateOrUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "configurationName": autorest.Encode("path", configurationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client DscConfigurationClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client DscConfigurationClient) CreateOrUpdateResponder(resp *http.Response) (result DscConfiguration, 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 delete the dsc configuration identified by configuration name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// configurationName - the configuration name. +func (client DscConfigurationClient) Delete(ctx context.Context, resourceGroupName string, automationAccountName string, configurationName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.DscConfigurationClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, automationAccountName, configurationName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client DscConfigurationClient) DeletePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, configurationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "configurationName": autorest.Encode("path", configurationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client DscConfigurationClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client DscConfigurationClient) 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 retrieve the configuration identified by configuration name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// configurationName - the configuration name. +func (client DscConfigurationClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string, configurationName string) (result DscConfiguration, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.DscConfigurationClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName, configurationName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client DscConfigurationClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, configurationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "configurationName": autorest.Encode("path", configurationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client DscConfigurationClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DscConfigurationClient) GetResponder(resp *http.Response) (result DscConfiguration, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetContent retrieve the configuration script identified by configuration name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// configurationName - the configuration name. +func (client DscConfigurationClient) GetContent(ctx context.Context, resourceGroupName string, automationAccountName string, configurationName string) (result ReadCloser, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.DscConfigurationClient", "GetContent", err.Error()) + } + + req, err := client.GetContentPreparer(ctx, resourceGroupName, automationAccountName, configurationName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "GetContent", nil, "Failure preparing request") + return + } + + resp, err := client.GetContentSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "GetContent", resp, "Failure sending request") + return + } + + result, err = client.GetContentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "GetContent", resp, "Failure responding to request") + } + + return +} + +// GetContentPreparer prepares the GetContent request. +func (client DscConfigurationClient) GetContentPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, configurationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "configurationName": autorest.Encode("path", configurationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}/content", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetContentSender sends the GetContent request. The method will close the +// http.Response Body if it receives an error. +func (client DscConfigurationClient) GetContentSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetContentResponder handles the response to the GetContent request. The method always +// closes the http.Response Body. +func (client DscConfigurationClient) GetContentResponder(resp *http.Response) (result ReadCloser, err error) { + result.Value = &resp.Body + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK)) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of configurations. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// filter - the filter to apply on the operation. +// skip - the number of rows to skip. +// top - the the number of rows to take. +// inlinecount - return total rows. +func (client DscConfigurationClient) ListByAutomationAccount(ctx context.Context, resourceGroupName string, automationAccountName string, filter string, skip *int32, top *int32, inlinecount string) (result DscConfigurationListResultPage, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.DscConfigurationClient", "ListByAutomationAccount", err.Error()) + } + + result.fn = client.listByAutomationAccountNextResults + req, err := client.ListByAutomationAccountPreparer(ctx, resourceGroupName, automationAccountName, filter, skip, top, inlinecount) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.dclr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result.dclr, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client DscConfigurationClient) ListByAutomationAccountPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, filter string, skip *int32, top *int32, inlinecount string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if len(inlinecount) > 0 { + queryParameters["$inlinecount"] = autorest.Encode("query", inlinecount) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations", 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 DscConfigurationClient) 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 DscConfigurationClient) ListByAutomationAccountResponder(resp *http.Response) (result DscConfigurationListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByAutomationAccountNextResults retrieves the next set of results, if any. +func (client DscConfigurationClient) listByAutomationAccountNextResults(lastResults DscConfigurationListResult) (result DscConfigurationListResult, err error) { + req, err := lastResults.dscConfigurationListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "listByAutomationAccountNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "listByAutomationAccountNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "listByAutomationAccountNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByAutomationAccountComplete enumerates all values, automatically crossing page boundaries as required. +func (client DscConfigurationClient) ListByAutomationAccountComplete(ctx context.Context, resourceGroupName string, automationAccountName string, filter string, skip *int32, top *int32, inlinecount string) (result DscConfigurationListResultIterator, err error) { + result.page, err = client.ListByAutomationAccount(ctx, resourceGroupName, automationAccountName, filter, skip, top, inlinecount) + return +} + +// Update create the configuration identified by configuration name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// configurationName - the create or update parameters for configuration. +// parameters - the create or update parameters for configuration. +func (client DscConfigurationClient) Update(ctx context.Context, resourceGroupName string, automationAccountName string, configurationName string, parameters *DscConfigurationUpdateParameters) (result DscConfiguration, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.DscConfigurationClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, automationAccountName, configurationName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client DscConfigurationClient) UpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, configurationName string, parameters *DscConfigurationUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "configurationName": autorest.Encode("path", configurationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if parameters != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(parameters)) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client DscConfigurationClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client DscConfigurationClient) UpdateResponder(resp *http.Response) (result DscConfiguration, 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/preview/automation/mgmt/2018-06-30-preview/automation/dscnode.go b/services/preview/automation/mgmt/2018-06-30-preview/automation/dscnode.go new file mode 100644 index 000000000000..c850d333e6d1 --- /dev/null +++ b/services/preview/automation/mgmt/2018-06-30-preview/automation/dscnode.go @@ -0,0 +1,394 @@ +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" +) + +// DscNodeClient is the automation Client +type DscNodeClient struct { + BaseClient +} + +// NewDscNodeClient creates an instance of the DscNodeClient client. +func NewDscNodeClient(subscriptionID string, countType1 CountType) DscNodeClient { + return NewDscNodeClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewDscNodeClientWithBaseURI creates an instance of the DscNodeClient client. +func NewDscNodeClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) DscNodeClient { + return DscNodeClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// Delete delete the dsc node identified by node id. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// nodeID - the node id. +func (client DscNodeClient) Delete(ctx context.Context, resourceGroupName string, automationAccountName string, nodeID string) (result DscNode, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.DscNodeClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, automationAccountName, nodeID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscNodeClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client DscNodeClient) DeletePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, nodeID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "nodeId": autorest.Encode("path", nodeID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-01-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client DscNodeClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client DscNodeClient) DeleteResponder(resp *http.Response) (result DscNode, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get retrieve the dsc node identified by node id. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// nodeID - the node id. +func (client DscNodeClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string, nodeID string) (result DscNode, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.DscNodeClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName, nodeID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscNodeClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client DscNodeClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, nodeID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "nodeId": autorest.Encode("path", nodeID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-01-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client DscNodeClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DscNodeClient) GetResponder(resp *http.Response) (result DscNode, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of dsc nodes. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// filter - the filter to apply on the operation. +// skip - the number of rows to skip. +// top - the the number of rows to take. +// inlinecount - return total rows. +func (client DscNodeClient) ListByAutomationAccount(ctx context.Context, resourceGroupName string, automationAccountName string, filter string, skip *int32, top *int32, inlinecount string) (result DscNodeListResultPage, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.DscNodeClient", "ListByAutomationAccount", err.Error()) + } + + result.fn = client.listByAutomationAccountNextResults + req, err := client.ListByAutomationAccountPreparer(ctx, resourceGroupName, automationAccountName, filter, skip, top, inlinecount) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.dnlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscNodeClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result.dnlr, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client DscNodeClient) ListByAutomationAccountPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, filter string, skip *int32, top *int32, inlinecount string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-01-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if len(inlinecount) > 0 { + queryParameters["$inlinecount"] = autorest.Encode("query", inlinecount) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes", 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 DscNodeClient) 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 DscNodeClient) ListByAutomationAccountResponder(resp *http.Response) (result DscNodeListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByAutomationAccountNextResults retrieves the next set of results, if any. +func (client DscNodeClient) listByAutomationAccountNextResults(lastResults DscNodeListResult) (result DscNodeListResult, err error) { + req, err := lastResults.dscNodeListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.DscNodeClient", "listByAutomationAccountNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.DscNodeClient", "listByAutomationAccountNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeClient", "listByAutomationAccountNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByAutomationAccountComplete enumerates all values, automatically crossing page boundaries as required. +func (client DscNodeClient) ListByAutomationAccountComplete(ctx context.Context, resourceGroupName string, automationAccountName string, filter string, skip *int32, top *int32, inlinecount string) (result DscNodeListResultIterator, err error) { + result.page, err = client.ListByAutomationAccount(ctx, resourceGroupName, automationAccountName, filter, skip, top, inlinecount) + return +} + +// Update update the dsc node. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// nodeID - parameters supplied to the update dsc node. +// dscNodeUpdateParameters - parameters supplied to the update dsc node. +func (client DscNodeClient) Update(ctx context.Context, resourceGroupName string, automationAccountName string, nodeID string, dscNodeUpdateParameters DscNodeUpdateParameters) (result DscNode, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.DscNodeClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, automationAccountName, nodeID, dscNodeUpdateParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscNodeClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client DscNodeClient) UpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, nodeID string, dscNodeUpdateParameters DscNodeUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "nodeId": autorest.Encode("path", nodeID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-01-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}", pathParameters), + autorest.WithJSON(dscNodeUpdateParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client DscNodeClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client DscNodeClient) UpdateResponder(resp *http.Response) (result DscNode, 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/preview/automation/mgmt/2018-06-30-preview/automation/dscnodeconfiguration.go b/services/preview/automation/mgmt/2018-06-30-preview/automation/dscnodeconfiguration.go new file mode 100644 index 000000000000..673ece89dfda --- /dev/null +++ b/services/preview/automation/mgmt/2018-06-30-preview/automation/dscnodeconfiguration.go @@ -0,0 +1,407 @@ +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" +) + +// DscNodeConfigurationClient is the automation Client +type DscNodeConfigurationClient struct { + BaseClient +} + +// NewDscNodeConfigurationClient creates an instance of the DscNodeConfigurationClient client. +func NewDscNodeConfigurationClient(subscriptionID string, countType1 CountType) DscNodeConfigurationClient { + return NewDscNodeConfigurationClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewDscNodeConfigurationClientWithBaseURI creates an instance of the DscNodeConfigurationClient client. +func NewDscNodeConfigurationClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) DscNodeConfigurationClient { + return DscNodeConfigurationClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// CreateOrUpdate create the node configuration identified by node configuration name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// nodeConfigurationName - the Dsc node configuration name. +// parameters - the create or update parameters for configuration. +func (client DscNodeConfigurationClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, automationAccountName string, nodeConfigurationName string, parameters DscNodeConfigurationCreateOrUpdateParameters) (result DscNodeConfigurationCreateOrUpdateFuture, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.DscNodeConfigurationCreateOrUpdateParametersProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.DscNodeConfigurationCreateOrUpdateParametersProperties.Source", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.DscNodeConfigurationCreateOrUpdateParametersProperties.Source.Hash", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.DscNodeConfigurationCreateOrUpdateParametersProperties.Source.Hash.Algorithm", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.DscNodeConfigurationCreateOrUpdateParametersProperties.Source.Hash.Value", Name: validation.Null, Rule: true, Chain: nil}, + }}, + }}, + {Target: "parameters.DscNodeConfigurationCreateOrUpdateParametersProperties.Configuration", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("automation.DscNodeConfigurationClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, automationAccountName, nodeConfigurationName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeConfigurationClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeConfigurationClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client DscNodeConfigurationClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, nodeConfigurationName string, parameters DscNodeConfigurationCreateOrUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "nodeConfigurationName": autorest.Encode("path", nodeConfigurationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-01-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations/{nodeConfigurationName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client DscNodeConfigurationClient) CreateOrUpdateSender(req *http.Request) (future DscNodeConfigurationCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client DscNodeConfigurationClient) CreateOrUpdateResponder(resp *http.Response) (result DscNodeConfiguration, 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 delete the Dsc node configurations by node configuration. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// nodeConfigurationName - the Dsc node configuration name. +func (client DscNodeConfigurationClient) Delete(ctx context.Context, resourceGroupName string, automationAccountName string, nodeConfigurationName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.DscNodeConfigurationClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, automationAccountName, nodeConfigurationName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeConfigurationClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.DscNodeConfigurationClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeConfigurationClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client DscNodeConfigurationClient) DeletePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, nodeConfigurationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "nodeConfigurationName": autorest.Encode("path", nodeConfigurationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-01-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations/{nodeConfigurationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client DscNodeConfigurationClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client DscNodeConfigurationClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get retrieve the Dsc node configurations by node configuration. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// nodeConfigurationName - the Dsc node configuration name. +func (client DscNodeConfigurationClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string, nodeConfigurationName string) (result DscNodeConfiguration, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.DscNodeConfigurationClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName, nodeConfigurationName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeConfigurationClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscNodeConfigurationClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeConfigurationClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client DscNodeConfigurationClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, nodeConfigurationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "nodeConfigurationName": autorest.Encode("path", nodeConfigurationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-01-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations/{nodeConfigurationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client DscNodeConfigurationClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DscNodeConfigurationClient) GetResponder(resp *http.Response) (result DscNodeConfiguration, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of dsc node configurations. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// filter - the filter to apply on the operation. +// skip - the number of rows to skip. +// top - the the number of rows to take. +// inlinecount - return total rows. +func (client DscNodeConfigurationClient) ListByAutomationAccount(ctx context.Context, resourceGroupName string, automationAccountName string, filter string, skip *int32, top *int32, inlinecount string) (result DscNodeConfigurationListResultPage, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.DscNodeConfigurationClient", "ListByAutomationAccount", err.Error()) + } + + result.fn = client.listByAutomationAccountNextResults + req, err := client.ListByAutomationAccountPreparer(ctx, resourceGroupName, automationAccountName, filter, skip, top, inlinecount) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeConfigurationClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.dnclr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscNodeConfigurationClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result.dnclr, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeConfigurationClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client DscNodeConfigurationClient) ListByAutomationAccountPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, filter string, skip *int32, top *int32, inlinecount string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-01-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if len(inlinecount) > 0 { + queryParameters["$inlinecount"] = autorest.Encode("query", inlinecount) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations", 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 DscNodeConfigurationClient) 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 DscNodeConfigurationClient) ListByAutomationAccountResponder(resp *http.Response) (result DscNodeConfigurationListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByAutomationAccountNextResults retrieves the next set of results, if any. +func (client DscNodeConfigurationClient) listByAutomationAccountNextResults(lastResults DscNodeConfigurationListResult) (result DscNodeConfigurationListResult, err error) { + req, err := lastResults.dscNodeConfigurationListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.DscNodeConfigurationClient", "listByAutomationAccountNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.DscNodeConfigurationClient", "listByAutomationAccountNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeConfigurationClient", "listByAutomationAccountNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByAutomationAccountComplete enumerates all values, automatically crossing page boundaries as required. +func (client DscNodeConfigurationClient) ListByAutomationAccountComplete(ctx context.Context, resourceGroupName string, automationAccountName string, filter string, skip *int32, top *int32, inlinecount string) (result DscNodeConfigurationListResultIterator, err error) { + result.page, err = client.ListByAutomationAccount(ctx, resourceGroupName, automationAccountName, filter, skip, top, inlinecount) + return +} diff --git a/services/preview/automation/mgmt/2018-06-30-preview/automation/fields.go b/services/preview/automation/mgmt/2018-06-30-preview/automation/fields.go new file mode 100644 index 000000000000..60ec0e5e6daf --- /dev/null +++ b/services/preview/automation/mgmt/2018-06-30-preview/automation/fields.go @@ -0,0 +1,120 @@ +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" +) + +// FieldsClient is the automation Client +type FieldsClient struct { + BaseClient +} + +// NewFieldsClient creates an instance of the FieldsClient client. +func NewFieldsClient(subscriptionID string, countType1 CountType) FieldsClient { + return NewFieldsClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewFieldsClientWithBaseURI creates an instance of the FieldsClient client. +func NewFieldsClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) FieldsClient { + return FieldsClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// ListByType retrieve a list of fields of a given type identified by module name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// moduleName - the name of module. +// typeName - the name of type. +func (client FieldsClient) ListByType(ctx context.Context, resourceGroupName string, automationAccountName string, moduleName string, typeName string) (result TypeFieldListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.FieldsClient", "ListByType", err.Error()) + } + + req, err := client.ListByTypePreparer(ctx, resourceGroupName, automationAccountName, moduleName, typeName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.FieldsClient", "ListByType", nil, "Failure preparing request") + return + } + + resp, err := client.ListByTypeSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.FieldsClient", "ListByType", resp, "Failure sending request") + return + } + + result, err = client.ListByTypeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.FieldsClient", "ListByType", resp, "Failure responding to request") + } + + return +} + +// ListByTypePreparer prepares the ListByType request. +func (client FieldsClient) ListByTypePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, moduleName string, typeName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "moduleName": autorest.Encode("path", moduleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "typeName": autorest.Encode("path", typeName), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/types/{typeName}/fields", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByTypeSender sends the ListByType request. The method will close the +// http.Response Body if it receives an error. +func (client FieldsClient) ListByTypeSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByTypeResponder handles the response to the ListByType request. The method always +// closes the http.Response Body. +func (client FieldsClient) ListByTypeResponder(resp *http.Response) (result TypeFieldListResult, 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/preview/automation/mgmt/2018-06-30-preview/automation/hybridrunbookworkergroup.go b/services/preview/automation/mgmt/2018-06-30-preview/automation/hybridrunbookworkergroup.go new file mode 100644 index 000000000000..35b70b811b0b --- /dev/null +++ b/services/preview/automation/mgmt/2018-06-30-preview/automation/hybridrunbookworkergroup.go @@ -0,0 +1,381 @@ +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" +) + +// HybridRunbookWorkerGroupClient is the automation Client +type HybridRunbookWorkerGroupClient struct { + BaseClient +} + +// NewHybridRunbookWorkerGroupClient creates an instance of the HybridRunbookWorkerGroupClient client. +func NewHybridRunbookWorkerGroupClient(subscriptionID string, countType1 CountType) HybridRunbookWorkerGroupClient { + return NewHybridRunbookWorkerGroupClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewHybridRunbookWorkerGroupClientWithBaseURI creates an instance of the HybridRunbookWorkerGroupClient client. +func NewHybridRunbookWorkerGroupClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) HybridRunbookWorkerGroupClient { + return HybridRunbookWorkerGroupClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// Delete delete a hybrid runbook worker group. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// hybridRunbookWorkerGroupName - the hybrid runbook worker group name +func (client HybridRunbookWorkerGroupClient) Delete(ctx context.Context, resourceGroupName string, automationAccountName string, hybridRunbookWorkerGroupName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.HybridRunbookWorkerGroupClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, automationAccountName, hybridRunbookWorkerGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client HybridRunbookWorkerGroupClient) DeletePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, hybridRunbookWorkerGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "hybridRunbookWorkerGroupName": autorest.Encode("path", hybridRunbookWorkerGroupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client HybridRunbookWorkerGroupClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client HybridRunbookWorkerGroupClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get retrieve a hybrid runbook worker group. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// hybridRunbookWorkerGroupName - the hybrid runbook worker group name +func (client HybridRunbookWorkerGroupClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string, hybridRunbookWorkerGroupName string) (result HybridRunbookWorkerGroup, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.HybridRunbookWorkerGroupClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName, hybridRunbookWorkerGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client HybridRunbookWorkerGroupClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, hybridRunbookWorkerGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "hybridRunbookWorkerGroupName": autorest.Encode("path", hybridRunbookWorkerGroupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client HybridRunbookWorkerGroupClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client HybridRunbookWorkerGroupClient) GetResponder(resp *http.Response) (result HybridRunbookWorkerGroup, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of hybrid runbook worker groups. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// filter - the filter to apply on the operation. +func (client HybridRunbookWorkerGroupClient) ListByAutomationAccount(ctx context.Context, resourceGroupName string, automationAccountName string, filter string) (result HybridRunbookWorkerGroupsListResultPage, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.HybridRunbookWorkerGroupClient", "ListByAutomationAccount", err.Error()) + } + + result.fn = client.listByAutomationAccountNextResults + req, err := client.ListByAutomationAccountPreparer(ctx, resourceGroupName, automationAccountName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.hrwglr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result.hrwglr, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client HybridRunbookWorkerGroupClient) ListByAutomationAccountPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups", 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 HybridRunbookWorkerGroupClient) 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 HybridRunbookWorkerGroupClient) ListByAutomationAccountResponder(resp *http.Response) (result HybridRunbookWorkerGroupsListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByAutomationAccountNextResults retrieves the next set of results, if any. +func (client HybridRunbookWorkerGroupClient) listByAutomationAccountNextResults(lastResults HybridRunbookWorkerGroupsListResult) (result HybridRunbookWorkerGroupsListResult, err error) { + req, err := lastResults.hybridRunbookWorkerGroupsListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "listByAutomationAccountNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "listByAutomationAccountNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "listByAutomationAccountNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByAutomationAccountComplete enumerates all values, automatically crossing page boundaries as required. +func (client HybridRunbookWorkerGroupClient) ListByAutomationAccountComplete(ctx context.Context, resourceGroupName string, automationAccountName string, filter string) (result HybridRunbookWorkerGroupsListResultIterator, err error) { + result.page, err = client.ListByAutomationAccount(ctx, resourceGroupName, automationAccountName, filter) + return +} + +// Update update a hybrid runbook worker group. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// hybridRunbookWorkerGroupName - the hybrid runbook worker group name +// parameters - the hybrid runbook worker group +func (client HybridRunbookWorkerGroupClient) Update(ctx context.Context, resourceGroupName string, automationAccountName string, hybridRunbookWorkerGroupName string, parameters HybridRunbookWorkerGroupUpdateParameters) (result HybridRunbookWorkerGroup, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.HybridRunbookWorkerGroupClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, automationAccountName, hybridRunbookWorkerGroupName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client HybridRunbookWorkerGroupClient) UpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, hybridRunbookWorkerGroupName string, parameters HybridRunbookWorkerGroupUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "hybridRunbookWorkerGroupName": autorest.Encode("path", hybridRunbookWorkerGroupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client HybridRunbookWorkerGroupClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client HybridRunbookWorkerGroupClient) UpdateResponder(resp *http.Response) (result HybridRunbookWorkerGroup, 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/preview/automation/mgmt/2018-06-30-preview/automation/job.go b/services/preview/automation/mgmt/2018-06-30-preview/automation/job.go new file mode 100644 index 000000000000..bf97a45f3be4 --- /dev/null +++ b/services/preview/automation/mgmt/2018-06-30-preview/automation/job.go @@ -0,0 +1,727 @@ +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" +) + +// JobClient is the automation Client +type JobClient struct { + BaseClient +} + +// NewJobClient creates an instance of the JobClient client. +func NewJobClient(subscriptionID string, countType1 CountType) JobClient { + return NewJobClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewJobClientWithBaseURI creates an instance of the JobClient client. +func NewJobClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) JobClient { + return JobClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// Create create a job of the runbook. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// jobName - the job name. +// parameters - the parameters supplied to the create job operation. +// clientRequestID - identifies this specific client request. +func (client JobClient) Create(ctx context.Context, resourceGroupName string, automationAccountName string, jobName string, parameters JobCreateParameters, clientRequestID string) (result Job, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.JobCreateProperties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.JobClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, automationAccountName, jobName, parameters, clientRequestID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.JobClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "Create", resp, "Failure responding to request") + } + + return +} + +// CreatePreparer prepares the Create request. +func (client JobClient) CreatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, jobName string, parameters JobCreateParameters, clientRequestID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-05-15-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + if len(clientRequestID) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("clientRequestId", autorest.String(clientRequestID))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client JobClient) CreateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client JobClient) CreateResponder(resp *http.Response) (result Job, 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 +} + +// Get retrieve the job identified by job name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// jobName - the job name. +// clientRequestID - identifies this specific client request. +func (client JobClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string, jobName string, clientRequestID string) (result Job, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.JobClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName, jobName, clientRequestID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.JobClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client JobClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, jobName string, clientRequestID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-05-15-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.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if len(clientRequestID) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("clientRequestId", autorest.String(clientRequestID))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client JobClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client JobClient) GetResponder(resp *http.Response) (result Job, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetOutput retrieve the job output identified by job name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// jobName - the name of the job to be created. +// clientRequestID - identifies this specific client request. +func (client JobClient) GetOutput(ctx context.Context, resourceGroupName string, automationAccountName string, jobName string, clientRequestID string) (result ReadCloser, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.JobClient", "GetOutput", err.Error()) + } + + req, err := client.GetOutputPreparer(ctx, resourceGroupName, automationAccountName, jobName, clientRequestID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "GetOutput", nil, "Failure preparing request") + return + } + + resp, err := client.GetOutputSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.JobClient", "GetOutput", resp, "Failure sending request") + return + } + + result, err = client.GetOutputResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "GetOutput", resp, "Failure responding to request") + } + + return +} + +// GetOutputPreparer prepares the GetOutput request. +func (client JobClient) GetOutputPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, jobName string, clientRequestID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-05-15-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.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/output", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if len(clientRequestID) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("clientRequestId", autorest.String(clientRequestID))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetOutputSender sends the GetOutput request. The method will close the +// http.Response Body if it receives an error. +func (client JobClient) GetOutputSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetOutputResponder handles the response to the GetOutput request. The method always +// closes the http.Response Body. +func (client JobClient) GetOutputResponder(resp *http.Response) (result ReadCloser, err error) { + result.Value = &resp.Body + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK)) + result.Response = autorest.Response{Response: resp} + return +} + +// GetRunbookContent retrieve the runbook content of the job identified by job name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// jobName - the job name. +// clientRequestID - identifies this specific client request. +func (client JobClient) GetRunbookContent(ctx context.Context, resourceGroupName string, automationAccountName string, jobName string, clientRequestID string) (result ReadCloser, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.JobClient", "GetRunbookContent", err.Error()) + } + + req, err := client.GetRunbookContentPreparer(ctx, resourceGroupName, automationAccountName, jobName, clientRequestID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "GetRunbookContent", nil, "Failure preparing request") + return + } + + resp, err := client.GetRunbookContentSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.JobClient", "GetRunbookContent", resp, "Failure sending request") + return + } + + result, err = client.GetRunbookContentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "GetRunbookContent", resp, "Failure responding to request") + } + + return +} + +// GetRunbookContentPreparer prepares the GetRunbookContent request. +func (client JobClient) GetRunbookContentPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, jobName string, clientRequestID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-05-15-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.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/runbookContent", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if len(clientRequestID) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("clientRequestId", autorest.String(clientRequestID))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetRunbookContentSender sends the GetRunbookContent request. The method will close the +// http.Response Body if it receives an error. +func (client JobClient) GetRunbookContentSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetRunbookContentResponder handles the response to the GetRunbookContent request. The method always +// closes the http.Response Body. +func (client JobClient) GetRunbookContentResponder(resp *http.Response) (result ReadCloser, err error) { + result.Value = &resp.Body + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK)) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of jobs. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// filter - the filter to apply on the operation. +// clientRequestID - identifies this specific client request. +func (client JobClient) ListByAutomationAccount(ctx context.Context, resourceGroupName string, automationAccountName string, filter string, clientRequestID string) (result JobListResultV2Page, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.JobClient", "ListByAutomationAccount", err.Error()) + } + + result.fn = client.listByAutomationAccountNextResults + req, err := client.ListByAutomationAccountPreparer(ctx, resourceGroupName, automationAccountName, filter, clientRequestID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.jlrv.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.JobClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result.jlrv, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client JobClient) ListByAutomationAccountPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, filter string, clientRequestID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-05-15-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if len(clientRequestID) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("clientRequestId", autorest.String(clientRequestID))) + } + 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 JobClient) 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 JobClient) ListByAutomationAccountResponder(resp *http.Response) (result JobListResultV2, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByAutomationAccountNextResults retrieves the next set of results, if any. +func (client JobClient) listByAutomationAccountNextResults(lastResults JobListResultV2) (result JobListResultV2, err error) { + req, err := lastResults.jobListResultV2Preparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.JobClient", "listByAutomationAccountNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.JobClient", "listByAutomationAccountNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "listByAutomationAccountNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByAutomationAccountComplete enumerates all values, automatically crossing page boundaries as required. +func (client JobClient) ListByAutomationAccountComplete(ctx context.Context, resourceGroupName string, automationAccountName string, filter string, clientRequestID string) (result JobListResultV2Iterator, err error) { + result.page, err = client.ListByAutomationAccount(ctx, resourceGroupName, automationAccountName, filter, clientRequestID) + return +} + +// Resume resume the job identified by jobName. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// jobName - the job name. +// clientRequestID - identifies this specific client request. +func (client JobClient) Resume(ctx context.Context, resourceGroupName string, automationAccountName string, jobName string, clientRequestID string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.JobClient", "Resume", err.Error()) + } + + req, err := client.ResumePreparer(ctx, resourceGroupName, automationAccountName, jobName, clientRequestID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "Resume", nil, "Failure preparing request") + return + } + + resp, err := client.ResumeSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.JobClient", "Resume", resp, "Failure sending request") + return + } + + result, err = client.ResumeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "Resume", resp, "Failure responding to request") + } + + return +} + +// ResumePreparer prepares the Resume request. +func (client JobClient) ResumePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, jobName string, clientRequestID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-05-15-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.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/resume", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if len(clientRequestID) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("clientRequestId", autorest.String(clientRequestID))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ResumeSender sends the Resume request. The method will close the +// http.Response Body if it receives an error. +func (client JobClient) ResumeSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ResumeResponder handles the response to the Resume request. The method always +// closes the http.Response Body. +func (client JobClient) ResumeResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Stop stop the job identified by jobName. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// jobName - the job name. +// clientRequestID - identifies this specific client request. +func (client JobClient) Stop(ctx context.Context, resourceGroupName string, automationAccountName string, jobName string, clientRequestID string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.JobClient", "Stop", err.Error()) + } + + req, err := client.StopPreparer(ctx, resourceGroupName, automationAccountName, jobName, clientRequestID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "Stop", nil, "Failure preparing request") + return + } + + resp, err := client.StopSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.JobClient", "Stop", resp, "Failure sending request") + return + } + + result, err = client.StopResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "Stop", resp, "Failure responding to request") + } + + return +} + +// StopPreparer prepares the Stop request. +func (client JobClient) StopPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, jobName string, clientRequestID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-05-15-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.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/stop", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if len(clientRequestID) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("clientRequestId", autorest.String(clientRequestID))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// StopSender sends the Stop request. The method will close the +// http.Response Body if it receives an error. +func (client JobClient) StopSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// StopResponder handles the response to the Stop request. The method always +// closes the http.Response Body. +func (client JobClient) StopResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Suspend suspend the job identified by job name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// jobName - the job name. +// clientRequestID - identifies this specific client request. +func (client JobClient) Suspend(ctx context.Context, resourceGroupName string, automationAccountName string, jobName string, clientRequestID string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.JobClient", "Suspend", err.Error()) + } + + req, err := client.SuspendPreparer(ctx, resourceGroupName, automationAccountName, jobName, clientRequestID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "Suspend", nil, "Failure preparing request") + return + } + + resp, err := client.SuspendSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.JobClient", "Suspend", resp, "Failure sending request") + return + } + + result, err = client.SuspendResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "Suspend", resp, "Failure responding to request") + } + + return +} + +// SuspendPreparer prepares the Suspend request. +func (client JobClient) SuspendPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, jobName string, clientRequestID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-05-15-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.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/suspend", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if len(clientRequestID) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("clientRequestId", autorest.String(clientRequestID))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// SuspendSender sends the Suspend request. The method will close the +// http.Response Body if it receives an error. +func (client JobClient) SuspendSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// SuspendResponder handles the response to the Suspend request. The method always +// closes the http.Response Body. +func (client JobClient) SuspendResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/services/preview/automation/mgmt/2018-06-30-preview/automation/jobschedule.go b/services/preview/automation/mgmt/2018-06-30-preview/automation/jobschedule.go new file mode 100644 index 000000000000..2d9c35c03ddf --- /dev/null +++ b/services/preview/automation/mgmt/2018-06-30-preview/automation/jobschedule.go @@ -0,0 +1,387 @@ +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" + "github.com/satori/go.uuid" + "net/http" +) + +// JobScheduleClient is the automation Client +type JobScheduleClient struct { + BaseClient +} + +// NewJobScheduleClient creates an instance of the JobScheduleClient client. +func NewJobScheduleClient(subscriptionID string, countType1 CountType) JobScheduleClient { + return NewJobScheduleClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewJobScheduleClientWithBaseURI creates an instance of the JobScheduleClient client. +func NewJobScheduleClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) JobScheduleClient { + return JobScheduleClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// Create create a job schedule. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// jobScheduleID - the job schedule name. +// parameters - the parameters supplied to the create job schedule operation. +func (client JobScheduleClient) Create(ctx context.Context, resourceGroupName string, automationAccountName string, jobScheduleID uuid.UUID, parameters JobScheduleCreateParameters) (result JobSchedule, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.JobScheduleCreateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.JobScheduleCreateProperties.Schedule", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.JobScheduleCreateProperties.Runbook", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("automation.JobScheduleClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, automationAccountName, jobScheduleID, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobScheduleClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.JobScheduleClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobScheduleClient", "Create", resp, "Failure responding to request") + } + + return +} + +// CreatePreparer prepares the Create request. +func (client JobScheduleClient) CreatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, jobScheduleID uuid.UUID, parameters JobScheduleCreateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "jobScheduleId": autorest.Encode("path", jobScheduleID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules/{jobScheduleId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client JobScheduleClient) CreateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client JobScheduleClient) CreateResponder(resp *http.Response) (result JobSchedule, 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 delete the job schedule identified by job schedule name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// jobScheduleID - the job schedule name. +func (client JobScheduleClient) Delete(ctx context.Context, resourceGroupName string, automationAccountName string, jobScheduleID uuid.UUID) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.JobScheduleClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, automationAccountName, jobScheduleID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobScheduleClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.JobScheduleClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobScheduleClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client JobScheduleClient) DeletePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, jobScheduleID uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "jobScheduleId": autorest.Encode("path", jobScheduleID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules/{jobScheduleId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client JobScheduleClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client JobScheduleClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get retrieve the job schedule identified by job schedule name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// jobScheduleID - the job schedule name. +func (client JobScheduleClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string, jobScheduleID uuid.UUID) (result JobSchedule, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.JobScheduleClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName, jobScheduleID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobScheduleClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.JobScheduleClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobScheduleClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client JobScheduleClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, jobScheduleID uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "jobScheduleId": autorest.Encode("path", jobScheduleID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules/{jobScheduleId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client JobScheduleClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client JobScheduleClient) GetResponder(resp *http.Response) (result JobSchedule, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of job schedules. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// filter - the filter to apply on the operation. +func (client JobScheduleClient) ListByAutomationAccount(ctx context.Context, resourceGroupName string, automationAccountName string, filter string) (result JobScheduleListResultPage, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.JobScheduleClient", "ListByAutomationAccount", err.Error()) + } + + result.fn = client.listByAutomationAccountNextResults + req, err := client.ListByAutomationAccountPreparer(ctx, resourceGroupName, automationAccountName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobScheduleClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.jslr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.JobScheduleClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result.jslr, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobScheduleClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client JobScheduleClient) ListByAutomationAccountPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules", 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 JobScheduleClient) 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 JobScheduleClient) ListByAutomationAccountResponder(resp *http.Response) (result JobScheduleListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByAutomationAccountNextResults retrieves the next set of results, if any. +func (client JobScheduleClient) listByAutomationAccountNextResults(lastResults JobScheduleListResult) (result JobScheduleListResult, err error) { + req, err := lastResults.jobScheduleListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.JobScheduleClient", "listByAutomationAccountNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.JobScheduleClient", "listByAutomationAccountNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobScheduleClient", "listByAutomationAccountNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByAutomationAccountComplete enumerates all values, automatically crossing page boundaries as required. +func (client JobScheduleClient) ListByAutomationAccountComplete(ctx context.Context, resourceGroupName string, automationAccountName string, filter string) (result JobScheduleListResultIterator, err error) { + result.page, err = client.ListByAutomationAccount(ctx, resourceGroupName, automationAccountName, filter) + return +} diff --git a/services/preview/automation/mgmt/2018-06-30-preview/automation/jobstream.go b/services/preview/automation/mgmt/2018-06-30-preview/automation/jobstream.go new file mode 100644 index 000000000000..441700fcafe1 --- /dev/null +++ b/services/preview/automation/mgmt/2018-06-30-preview/automation/jobstream.go @@ -0,0 +1,239 @@ +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" +) + +// JobStreamClient is the automation Client +type JobStreamClient struct { + BaseClient +} + +// NewJobStreamClient creates an instance of the JobStreamClient client. +func NewJobStreamClient(subscriptionID string, countType1 CountType) JobStreamClient { + return NewJobStreamClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewJobStreamClientWithBaseURI creates an instance of the JobStreamClient client. +func NewJobStreamClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) JobStreamClient { + return JobStreamClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// Get retrieve the job stream identified by job stream id. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// jobName - the job name. +// jobStreamID - the job stream id. +// clientRequestID - identifies this specific client request. +func (client JobStreamClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string, jobName string, jobStreamID string, clientRequestID string) (result JobStream, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.JobStreamClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName, jobName, jobStreamID, clientRequestID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobStreamClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.JobStreamClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobStreamClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client JobStreamClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, jobName string, jobStreamID string, clientRequestID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "jobName": autorest.Encode("path", jobName), + "jobStreamId": autorest.Encode("path", jobStreamID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-05-15-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.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/streams/{jobStreamId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if len(clientRequestID) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("clientRequestId", autorest.String(clientRequestID))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client JobStreamClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client JobStreamClient) GetResponder(resp *http.Response) (result JobStream, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByJob retrieve a list of jobs streams identified by job name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// jobName - the job name. +// filter - the filter to apply on the operation. +// clientRequestID - identifies this specific client request. +func (client JobStreamClient) ListByJob(ctx context.Context, resourceGroupName string, automationAccountName string, jobName string, filter string, clientRequestID string) (result JobStreamListResultPage, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.JobStreamClient", "ListByJob", err.Error()) + } + + result.fn = client.listByJobNextResults + req, err := client.ListByJobPreparer(ctx, resourceGroupName, automationAccountName, jobName, filter, clientRequestID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobStreamClient", "ListByJob", nil, "Failure preparing request") + return + } + + resp, err := client.ListByJobSender(req) + if err != nil { + result.jslr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.JobStreamClient", "ListByJob", resp, "Failure sending request") + return + } + + result.jslr, err = client.ListByJobResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobStreamClient", "ListByJob", resp, "Failure responding to request") + } + + return +} + +// ListByJobPreparer prepares the ListByJob request. +func (client JobStreamClient) ListByJobPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, jobName string, filter string, clientRequestID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-05-15-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/streams", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if len(clientRequestID) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("clientRequestId", autorest.String(clientRequestID))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByJobSender sends the ListByJob request. The method will close the +// http.Response Body if it receives an error. +func (client JobStreamClient) ListByJobSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByJobResponder handles the response to the ListByJob request. The method always +// closes the http.Response Body. +func (client JobStreamClient) ListByJobResponder(resp *http.Response) (result JobStreamListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByJobNextResults retrieves the next set of results, if any. +func (client JobStreamClient) listByJobNextResults(lastResults JobStreamListResult) (result JobStreamListResult, err error) { + req, err := lastResults.jobStreamListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.JobStreamClient", "listByJobNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByJobSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.JobStreamClient", "listByJobNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByJobResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobStreamClient", "listByJobNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByJobComplete enumerates all values, automatically crossing page boundaries as required. +func (client JobStreamClient) ListByJobComplete(ctx context.Context, resourceGroupName string, automationAccountName string, jobName string, filter string, clientRequestID string) (result JobStreamListResultIterator, err error) { + result.page, err = client.ListByJob(ctx, resourceGroupName, automationAccountName, jobName, filter, clientRequestID) + return +} diff --git a/services/preview/automation/mgmt/2018-06-30-preview/automation/keys.go b/services/preview/automation/mgmt/2018-06-30-preview/automation/keys.go new file mode 100644 index 000000000000..8d53d162cabc --- /dev/null +++ b/services/preview/automation/mgmt/2018-06-30-preview/automation/keys.go @@ -0,0 +1,116 @@ +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, countType1 CountType) KeysClient { + return NewKeysClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewKeysClientWithBaseURI creates an instance of the KeysClient client. +func NewKeysClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) KeysClient { + return KeysClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// ListByAutomationAccount retrieve the automation keys for an account. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +func (client KeysClient) ListByAutomationAccount(ctx context.Context, resourceGroupName string, automationAccountName string) (result KeyListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.KeysClient", "ListByAutomationAccount", err.Error()) + } + + req, err := client.ListByAutomationAccountPreparer(ctx, resourceGroupName, 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, resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", 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/preview/automation/mgmt/2018-06-30-preview/automation/linkedworkspace.go b/services/preview/automation/mgmt/2018-06-30-preview/automation/linkedworkspace.go new file mode 100644 index 000000000000..5385fb666937 --- /dev/null +++ b/services/preview/automation/mgmt/2018-06-30-preview/automation/linkedworkspace.go @@ -0,0 +1,116 @@ +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" +) + +// LinkedWorkspaceClient is the automation Client +type LinkedWorkspaceClient struct { + BaseClient +} + +// NewLinkedWorkspaceClient creates an instance of the LinkedWorkspaceClient client. +func NewLinkedWorkspaceClient(subscriptionID string, countType1 CountType) LinkedWorkspaceClient { + return NewLinkedWorkspaceClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewLinkedWorkspaceClientWithBaseURI creates an instance of the LinkedWorkspaceClient client. +func NewLinkedWorkspaceClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) LinkedWorkspaceClient { + return LinkedWorkspaceClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// Get retrieve the linked workspace for the account id. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +func (client LinkedWorkspaceClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string) (result LinkedWorkspace, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.LinkedWorkspaceClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.LinkedWorkspaceClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.LinkedWorkspaceClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.LinkedWorkspaceClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client LinkedWorkspaceClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/linkedWorkspace", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client LinkedWorkspaceClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client LinkedWorkspaceClient) GetResponder(resp *http.Response) (result LinkedWorkspace, 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/preview/automation/mgmt/2018-06-30-preview/automation/models.go b/services/preview/automation/mgmt/2018-06-30-preview/automation/models.go new file mode 100644 index 000000000000..2e233306a1f1 --- /dev/null +++ b/services/preview/automation/mgmt/2018-06-30-preview/automation/models.go @@ -0,0 +1,9916 @@ +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 ( + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "github.com/satori/go.uuid" + "io" + "net/http" +) + +// AccountState enumerates the values for account state. +type AccountState string + +const ( + // Ok ... + Ok AccountState = "Ok" + // Suspended ... + Suspended AccountState = "Suspended" + // Unavailable ... + Unavailable AccountState = "Unavailable" +) + +// PossibleAccountStateValues returns an array of possible values for the AccountState const type. +func PossibleAccountStateValues() []AccountState { + return []AccountState{Ok, Suspended, Unavailable} +} + +// AgentRegistrationKeyName enumerates the values for agent registration key name. +type AgentRegistrationKeyName string + +const ( + // Primary ... + Primary AgentRegistrationKeyName = "primary" + // Secondary ... + Secondary AgentRegistrationKeyName = "secondary" +) + +// PossibleAgentRegistrationKeyNameValues returns an array of possible values for the AgentRegistrationKeyName const type. +func PossibleAgentRegistrationKeyNameValues() []AgentRegistrationKeyName { + return []AgentRegistrationKeyName{Primary, Secondary} +} + +// ContentSourceType enumerates the values for content source type. +type ContentSourceType string + +const ( + // EmbeddedContent ... + EmbeddedContent ContentSourceType = "embeddedContent" + // URI ... + URI ContentSourceType = "uri" +) + +// PossibleContentSourceTypeValues returns an array of possible values for the ContentSourceType const type. +func PossibleContentSourceTypeValues() []ContentSourceType { + return []ContentSourceType{EmbeddedContent, URI} +} + +// CountType enumerates the values for count type. +type CountType string + +const ( + // Nodeconfiguration ... + Nodeconfiguration CountType = "nodeconfiguration" + // Status ... + Status CountType = "status" +) + +// PossibleCountTypeValues returns an array of possible values for the CountType const type. +func PossibleCountTypeValues() []CountType { + return []CountType{Nodeconfiguration, Status} +} + +// DscConfigurationProvisioningState enumerates the values for dsc configuration provisioning state. +type DscConfigurationProvisioningState string + +const ( + // Succeeded ... + Succeeded DscConfigurationProvisioningState = "Succeeded" +) + +// PossibleDscConfigurationProvisioningStateValues returns an array of possible values for the DscConfigurationProvisioningState const type. +func PossibleDscConfigurationProvisioningStateValues() []DscConfigurationProvisioningState { + return []DscConfigurationProvisioningState{Succeeded} +} + +// DscConfigurationState enumerates the values for dsc configuration state. +type DscConfigurationState string + +const ( + // DscConfigurationStateEdit ... + DscConfigurationStateEdit DscConfigurationState = "Edit" + // DscConfigurationStateNew ... + DscConfigurationStateNew DscConfigurationState = "New" + // DscConfigurationStatePublished ... + DscConfigurationStatePublished DscConfigurationState = "Published" +) + +// PossibleDscConfigurationStateValues returns an array of possible values for the DscConfigurationState const type. +func PossibleDscConfigurationStateValues() []DscConfigurationState { + return []DscConfigurationState{DscConfigurationStateEdit, DscConfigurationStateNew, DscConfigurationStatePublished} +} + +// GroupTypeEnum enumerates the values for group type enum. +type GroupTypeEnum string + +const ( + // System ... + System GroupTypeEnum = "System" + // User ... + User GroupTypeEnum = "User" +) + +// PossibleGroupTypeEnumValues returns an array of possible values for the GroupTypeEnum const type. +func PossibleGroupTypeEnumValues() []GroupTypeEnum { + return []GroupTypeEnum{System, User} +} + +// HTTPStatusCode enumerates the values for http status code. +type HTTPStatusCode string + +const ( + // Accepted ... + Accepted HTTPStatusCode = "Accepted" + // Ambiguous ... + Ambiguous HTTPStatusCode = "Ambiguous" + // BadGateway ... + BadGateway HTTPStatusCode = "BadGateway" + // BadRequest ... + BadRequest HTTPStatusCode = "BadRequest" + // Conflict ... + Conflict HTTPStatusCode = "Conflict" + // Continue ... + Continue HTTPStatusCode = "Continue" + // Created ... + Created HTTPStatusCode = "Created" + // ExpectationFailed ... + ExpectationFailed HTTPStatusCode = "ExpectationFailed" + // Forbidden ... + Forbidden HTTPStatusCode = "Forbidden" + // Found ... + Found HTTPStatusCode = "Found" + // GatewayTimeout ... + GatewayTimeout HTTPStatusCode = "GatewayTimeout" + // Gone ... + Gone HTTPStatusCode = "Gone" + // HTTPVersionNotSupported ... + HTTPVersionNotSupported HTTPStatusCode = "HttpVersionNotSupported" + // InternalServerError ... + InternalServerError HTTPStatusCode = "InternalServerError" + // LengthRequired ... + LengthRequired HTTPStatusCode = "LengthRequired" + // MethodNotAllowed ... + MethodNotAllowed HTTPStatusCode = "MethodNotAllowed" + // Moved ... + Moved HTTPStatusCode = "Moved" + // MovedPermanently ... + MovedPermanently HTTPStatusCode = "MovedPermanently" + // MultipleChoices ... + MultipleChoices HTTPStatusCode = "MultipleChoices" + // NoContent ... + NoContent HTTPStatusCode = "NoContent" + // NonAuthoritativeInformation ... + NonAuthoritativeInformation HTTPStatusCode = "NonAuthoritativeInformation" + // NotAcceptable ... + NotAcceptable HTTPStatusCode = "NotAcceptable" + // NotFound ... + NotFound HTTPStatusCode = "NotFound" + // NotImplemented ... + NotImplemented HTTPStatusCode = "NotImplemented" + // NotModified ... + NotModified HTTPStatusCode = "NotModified" + // OK ... + OK HTTPStatusCode = "OK" + // PartialContent ... + PartialContent HTTPStatusCode = "PartialContent" + // PaymentRequired ... + PaymentRequired HTTPStatusCode = "PaymentRequired" + // PreconditionFailed ... + PreconditionFailed HTTPStatusCode = "PreconditionFailed" + // ProxyAuthenticationRequired ... + ProxyAuthenticationRequired HTTPStatusCode = "ProxyAuthenticationRequired" + // Redirect ... + Redirect HTTPStatusCode = "Redirect" + // RedirectKeepVerb ... + RedirectKeepVerb HTTPStatusCode = "RedirectKeepVerb" + // RedirectMethod ... + RedirectMethod HTTPStatusCode = "RedirectMethod" + // RequestedRangeNotSatisfiable ... + RequestedRangeNotSatisfiable HTTPStatusCode = "RequestedRangeNotSatisfiable" + // RequestEntityTooLarge ... + RequestEntityTooLarge HTTPStatusCode = "RequestEntityTooLarge" + // RequestTimeout ... + RequestTimeout HTTPStatusCode = "RequestTimeout" + // RequestURITooLong ... + RequestURITooLong HTTPStatusCode = "RequestUriTooLong" + // ResetContent ... + ResetContent HTTPStatusCode = "ResetContent" + // SeeOther ... + SeeOther HTTPStatusCode = "SeeOther" + // ServiceUnavailable ... + ServiceUnavailable HTTPStatusCode = "ServiceUnavailable" + // SwitchingProtocols ... + SwitchingProtocols HTTPStatusCode = "SwitchingProtocols" + // TemporaryRedirect ... + TemporaryRedirect HTTPStatusCode = "TemporaryRedirect" + // Unauthorized ... + Unauthorized HTTPStatusCode = "Unauthorized" + // UnsupportedMediaType ... + UnsupportedMediaType HTTPStatusCode = "UnsupportedMediaType" + // Unused ... + Unused HTTPStatusCode = "Unused" + // UpgradeRequired ... + UpgradeRequired HTTPStatusCode = "UpgradeRequired" + // UseProxy ... + UseProxy HTTPStatusCode = "UseProxy" +) + +// PossibleHTTPStatusCodeValues returns an array of possible values for the HTTPStatusCode const type. +func PossibleHTTPStatusCodeValues() []HTTPStatusCode { + return []HTTPStatusCode{Accepted, Ambiguous, BadGateway, BadRequest, Conflict, Continue, Created, ExpectationFailed, Forbidden, Found, GatewayTimeout, Gone, HTTPVersionNotSupported, InternalServerError, LengthRequired, MethodNotAllowed, Moved, MovedPermanently, MultipleChoices, NoContent, NonAuthoritativeInformation, NotAcceptable, NotFound, NotImplemented, NotModified, OK, PartialContent, PaymentRequired, PreconditionFailed, ProxyAuthenticationRequired, Redirect, RedirectKeepVerb, RedirectMethod, RequestedRangeNotSatisfiable, RequestEntityTooLarge, RequestTimeout, RequestURITooLong, ResetContent, SeeOther, ServiceUnavailable, SwitchingProtocols, TemporaryRedirect, Unauthorized, UnsupportedMediaType, Unused, UpgradeRequired, UseProxy} +} + +// JobProvisioningState enumerates the values for job provisioning state. +type JobProvisioningState string + +const ( + // JobProvisioningStateFailed ... + JobProvisioningStateFailed JobProvisioningState = "Failed" + // JobProvisioningStateProcessing ... + JobProvisioningStateProcessing JobProvisioningState = "Processing" + // JobProvisioningStateSucceeded ... + JobProvisioningStateSucceeded JobProvisioningState = "Succeeded" + // JobProvisioningStateSuspended ... + JobProvisioningStateSuspended JobProvisioningState = "Suspended" +) + +// PossibleJobProvisioningStateValues returns an array of possible values for the JobProvisioningState const type. +func PossibleJobProvisioningStateValues() []JobProvisioningState { + return []JobProvisioningState{JobProvisioningStateFailed, JobProvisioningStateProcessing, JobProvisioningStateSucceeded, JobProvisioningStateSuspended} +} + +// JobStatus enumerates the values for job status. +type JobStatus string + +const ( + // JobStatusActivating ... + JobStatusActivating JobStatus = "Activating" + // JobStatusBlocked ... + JobStatusBlocked JobStatus = "Blocked" + // JobStatusCompleted ... + JobStatusCompleted JobStatus = "Completed" + // JobStatusDisconnected ... + JobStatusDisconnected JobStatus = "Disconnected" + // JobStatusFailed ... + JobStatusFailed JobStatus = "Failed" + // JobStatusNew ... + JobStatusNew JobStatus = "New" + // JobStatusRemoving ... + JobStatusRemoving JobStatus = "Removing" + // JobStatusResuming ... + JobStatusResuming JobStatus = "Resuming" + // JobStatusRunning ... + JobStatusRunning JobStatus = "Running" + // JobStatusStopped ... + JobStatusStopped JobStatus = "Stopped" + // JobStatusStopping ... + JobStatusStopping JobStatus = "Stopping" + // JobStatusSuspended ... + JobStatusSuspended JobStatus = "Suspended" + // JobStatusSuspending ... + JobStatusSuspending JobStatus = "Suspending" +) + +// PossibleJobStatusValues returns an array of possible values for the JobStatus const type. +func PossibleJobStatusValues() []JobStatus { + return []JobStatus{JobStatusActivating, JobStatusBlocked, JobStatusCompleted, JobStatusDisconnected, JobStatusFailed, JobStatusNew, JobStatusRemoving, JobStatusResuming, JobStatusRunning, JobStatusStopped, JobStatusStopping, JobStatusSuspended, JobStatusSuspending} +} + +// JobStreamType enumerates the values for job stream type. +type JobStreamType string + +const ( + // Any ... + Any JobStreamType = "Any" + // Debug ... + Debug JobStreamType = "Debug" + // Error ... + Error JobStreamType = "Error" + // Output ... + Output JobStreamType = "Output" + // Progress ... + Progress JobStreamType = "Progress" + // Verbose ... + Verbose JobStreamType = "Verbose" + // Warning ... + Warning JobStreamType = "Warning" +) + +// PossibleJobStreamTypeValues returns an array of possible values for the JobStreamType const type. +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" + // Read ... + Read KeyPermissions = "Read" +) + +// PossibleKeyPermissionsValues returns an array of possible values for the KeyPermissions const type. +func PossibleKeyPermissionsValues() []KeyPermissions { + return []KeyPermissions{Full, Read} +} + +// LinuxUpdateClasses enumerates the values for linux update classes. +type LinuxUpdateClasses string + +const ( + // Critical ... + Critical LinuxUpdateClasses = "Critical" + // Other ... + Other LinuxUpdateClasses = "Other" + // Security ... + Security LinuxUpdateClasses = "Security" + // Unclassified ... + Unclassified LinuxUpdateClasses = "Unclassified" +) + +// PossibleLinuxUpdateClassesValues returns an array of possible values for the LinuxUpdateClasses const type. +func PossibleLinuxUpdateClassesValues() []LinuxUpdateClasses { + return []LinuxUpdateClasses{Critical, Other, Security, Unclassified} +} + +// ModuleProvisioningState enumerates the values for module provisioning state. +type ModuleProvisioningState string + +const ( + // ModuleProvisioningStateActivitiesStored ... + ModuleProvisioningStateActivitiesStored ModuleProvisioningState = "ActivitiesStored" + // ModuleProvisioningStateCancelled ... + ModuleProvisioningStateCancelled ModuleProvisioningState = "Cancelled" + // ModuleProvisioningStateConnectionTypeImported ... + ModuleProvisioningStateConnectionTypeImported ModuleProvisioningState = "ConnectionTypeImported" + // ModuleProvisioningStateContentDownloaded ... + ModuleProvisioningStateContentDownloaded ModuleProvisioningState = "ContentDownloaded" + // ModuleProvisioningStateContentRetrieved ... + ModuleProvisioningStateContentRetrieved ModuleProvisioningState = "ContentRetrieved" + // ModuleProvisioningStateContentStored ... + ModuleProvisioningStateContentStored ModuleProvisioningState = "ContentStored" + // ModuleProvisioningStateContentValidated ... + ModuleProvisioningStateContentValidated ModuleProvisioningState = "ContentValidated" + // ModuleProvisioningStateCreated ... + ModuleProvisioningStateCreated ModuleProvisioningState = "Created" + // ModuleProvisioningStateCreating ... + ModuleProvisioningStateCreating ModuleProvisioningState = "Creating" + // ModuleProvisioningStateFailed ... + ModuleProvisioningStateFailed ModuleProvisioningState = "Failed" + // ModuleProvisioningStateModuleDataStored ... + ModuleProvisioningStateModuleDataStored ModuleProvisioningState = "ModuleDataStored" + // ModuleProvisioningStateModuleImportRunbookComplete ... + ModuleProvisioningStateModuleImportRunbookComplete ModuleProvisioningState = "ModuleImportRunbookComplete" + // ModuleProvisioningStateRunningImportModuleRunbook ... + ModuleProvisioningStateRunningImportModuleRunbook ModuleProvisioningState = "RunningImportModuleRunbook" + // ModuleProvisioningStateStartingImportModuleRunbook ... + ModuleProvisioningStateStartingImportModuleRunbook ModuleProvisioningState = "StartingImportModuleRunbook" + // ModuleProvisioningStateSucceeded ... + ModuleProvisioningStateSucceeded ModuleProvisioningState = "Succeeded" + // ModuleProvisioningStateUpdating ... + ModuleProvisioningStateUpdating ModuleProvisioningState = "Updating" +) + +// PossibleModuleProvisioningStateValues returns an array of possible values for the ModuleProvisioningState const type. +func PossibleModuleProvisioningStateValues() []ModuleProvisioningState { + return []ModuleProvisioningState{ModuleProvisioningStateActivitiesStored, ModuleProvisioningStateCancelled, ModuleProvisioningStateConnectionTypeImported, ModuleProvisioningStateContentDownloaded, ModuleProvisioningStateContentRetrieved, ModuleProvisioningStateContentStored, ModuleProvisioningStateContentValidated, ModuleProvisioningStateCreated, ModuleProvisioningStateCreating, ModuleProvisioningStateFailed, ModuleProvisioningStateModuleDataStored, ModuleProvisioningStateModuleImportRunbookComplete, ModuleProvisioningStateRunningImportModuleRunbook, ModuleProvisioningStateStartingImportModuleRunbook, ModuleProvisioningStateSucceeded, ModuleProvisioningStateUpdating} +} + +// OperatingSystemType enumerates the values for operating system type. +type OperatingSystemType string + +const ( + // Linux ... + Linux OperatingSystemType = "Linux" + // Windows ... + Windows OperatingSystemType = "Windows" +) + +// PossibleOperatingSystemTypeValues returns an array of possible values for the OperatingSystemType const type. +func PossibleOperatingSystemTypeValues() []OperatingSystemType { + return []OperatingSystemType{Linux, Windows} +} + +// ProvisioningState enumerates the values for provisioning state. +type ProvisioningState string + +const ( + // Completed ... + Completed ProvisioningState = "Completed" + // Failed ... + Failed ProvisioningState = "Failed" + // Running ... + Running ProvisioningState = "Running" +) + +// PossibleProvisioningStateValues returns an array of possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{Completed, Failed, Running} +} + +// RunbookProvisioningState enumerates the values for runbook provisioning state. +type RunbookProvisioningState string + +const ( + // RunbookProvisioningStateSucceeded ... + RunbookProvisioningStateSucceeded RunbookProvisioningState = "Succeeded" +) + +// PossibleRunbookProvisioningStateValues returns an array of possible values for the RunbookProvisioningState const type. +func PossibleRunbookProvisioningStateValues() []RunbookProvisioningState { + return []RunbookProvisioningState{RunbookProvisioningStateSucceeded} +} + +// RunbookState enumerates the values for runbook state. +type RunbookState string + +const ( + // RunbookStateEdit ... + RunbookStateEdit RunbookState = "Edit" + // RunbookStateNew ... + RunbookStateNew RunbookState = "New" + // RunbookStatePublished ... + RunbookStatePublished RunbookState = "Published" +) + +// PossibleRunbookStateValues returns an array of possible values for the RunbookState const type. +func PossibleRunbookStateValues() []RunbookState { + return []RunbookState{RunbookStateEdit, RunbookStateNew, RunbookStatePublished} +} + +// RunbookTypeEnum enumerates the values for runbook type enum. +type RunbookTypeEnum string + +const ( + // Graph ... + Graph RunbookTypeEnum = "Graph" + // GraphPowerShell ... + GraphPowerShell RunbookTypeEnum = "GraphPowerShell" + // GraphPowerShellWorkflow ... + GraphPowerShellWorkflow RunbookTypeEnum = "GraphPowerShellWorkflow" + // PowerShell ... + PowerShell RunbookTypeEnum = "PowerShell" + // PowerShellWorkflow ... + PowerShellWorkflow RunbookTypeEnum = "PowerShellWorkflow" + // Script ... + Script RunbookTypeEnum = "Script" +) + +// PossibleRunbookTypeEnumValues returns an array of possible values for the RunbookTypeEnum const type. +func PossibleRunbookTypeEnumValues() []RunbookTypeEnum { + return []RunbookTypeEnum{Graph, GraphPowerShell, GraphPowerShellWorkflow, PowerShell, PowerShellWorkflow, Script} +} + +// ScheduleDay enumerates the values for schedule day. +type ScheduleDay string + +const ( + // Friday ... + Friday ScheduleDay = "Friday" + // Monday ... + Monday ScheduleDay = "Monday" + // Saturday ... + Saturday ScheduleDay = "Saturday" + // Sunday ... + Sunday ScheduleDay = "Sunday" + // Thursday ... + Thursday ScheduleDay = "Thursday" + // Tuesday ... + Tuesday ScheduleDay = "Tuesday" + // Wednesday ... + Wednesday ScheduleDay = "Wednesday" +) + +// PossibleScheduleDayValues returns an array of possible values for the ScheduleDay const type. +func PossibleScheduleDayValues() []ScheduleDay { + return []ScheduleDay{Friday, Monday, Saturday, Sunday, Thursday, Tuesday, Wednesday} +} + +// ScheduleFrequency enumerates the values for schedule frequency. +type ScheduleFrequency string + +const ( + // Day ... + Day ScheduleFrequency = "Day" + // Hour ... + Hour ScheduleFrequency = "Hour" + // Month ... + Month ScheduleFrequency = "Month" + // OneTime ... + OneTime ScheduleFrequency = "OneTime" + // Week ... + Week ScheduleFrequency = "Week" +) + +// PossibleScheduleFrequencyValues returns an array of possible values for the ScheduleFrequency const type. +func PossibleScheduleFrequencyValues() []ScheduleFrequency { + return []ScheduleFrequency{Day, Hour, Month, OneTime, Week} +} + +// SkuNameEnum enumerates the values for sku name enum. +type SkuNameEnum string + +const ( + // Basic ... + Basic SkuNameEnum = "Basic" + // Free ... + Free SkuNameEnum = "Free" +) + +// PossibleSkuNameEnumValues returns an array of possible values for the SkuNameEnum const type. +func PossibleSkuNameEnumValues() []SkuNameEnum { + return []SkuNameEnum{Basic, Free} +} + +// SourceType enumerates the values for source type. +type SourceType string + +const ( + // GitHub ... + GitHub SourceType = "GitHub" + // VsoGit ... + VsoGit SourceType = "VsoGit" + // VsoTfvc ... + VsoTfvc SourceType = "VsoTfvc" +) + +// PossibleSourceTypeValues returns an array of possible values for the SourceType const type. +func PossibleSourceTypeValues() []SourceType { + return []SourceType{GitHub, VsoGit, VsoTfvc} +} + +// StreamType enumerates the values for stream type. +type StreamType string + +const ( + // StreamTypeError ... + StreamTypeError StreamType = "Error" + // StreamTypeOutput ... + StreamTypeOutput StreamType = "Output" +) + +// PossibleStreamTypeValues returns an array of possible values for the StreamType const type. +func PossibleStreamTypeValues() []StreamType { + return []StreamType{StreamTypeError, StreamTypeOutput} +} + +// SyncType enumerates the values for sync type. +type SyncType string + +const ( + // FullSync ... + FullSync SyncType = "FullSync" + // PartialSync ... + PartialSync SyncType = "PartialSync" +) + +// PossibleSyncTypeValues returns an array of possible values for the SyncType const type. +func PossibleSyncTypeValues() []SyncType { + return []SyncType{FullSync, PartialSync} +} + +// TagOperators enumerates the values for tag operators. +type TagOperators string + +const ( + // TagOperatorsAll ... + TagOperatorsAll TagOperators = "All" + // TagOperatorsAny ... + TagOperatorsAny TagOperators = "Any" +) + +// PossibleTagOperatorsValues returns an array of possible values for the TagOperators const type. +func PossibleTagOperatorsValues() []TagOperators { + return []TagOperators{TagOperatorsAll, TagOperatorsAny} +} + +// TokenType enumerates the values for token type. +type TokenType string + +const ( + // Oauth ... + Oauth TokenType = "Oauth" + // PersonalAccessToken ... + PersonalAccessToken TokenType = "PersonalAccessToken" +) + +// PossibleTokenTypeValues returns an array of possible values for the TokenType const type. +func PossibleTokenTypeValues() []TokenType { + return []TokenType{Oauth, PersonalAccessToken} +} + +// WindowsUpdateClasses enumerates the values for windows update classes. +type WindowsUpdateClasses string + +const ( + // WindowsUpdateClassesCritical ... + WindowsUpdateClassesCritical WindowsUpdateClasses = "Critical" + // WindowsUpdateClassesDefinition ... + WindowsUpdateClassesDefinition WindowsUpdateClasses = "Definition" + // WindowsUpdateClassesFeaturePack ... + WindowsUpdateClassesFeaturePack WindowsUpdateClasses = "FeaturePack" + // WindowsUpdateClassesSecurity ... + WindowsUpdateClassesSecurity WindowsUpdateClasses = "Security" + // WindowsUpdateClassesServicePack ... + WindowsUpdateClassesServicePack WindowsUpdateClasses = "ServicePack" + // WindowsUpdateClassesTools ... + WindowsUpdateClassesTools WindowsUpdateClasses = "Tools" + // WindowsUpdateClassesUnclassified ... + WindowsUpdateClassesUnclassified WindowsUpdateClasses = "Unclassified" + // WindowsUpdateClassesUpdateRollup ... + WindowsUpdateClassesUpdateRollup WindowsUpdateClasses = "UpdateRollup" + // WindowsUpdateClassesUpdates ... + WindowsUpdateClassesUpdates WindowsUpdateClasses = "Updates" +) + +// PossibleWindowsUpdateClassesValues returns an array of possible values for the WindowsUpdateClasses const type. +func PossibleWindowsUpdateClassesValues() []WindowsUpdateClasses { + return []WindowsUpdateClasses{WindowsUpdateClassesCritical, WindowsUpdateClassesDefinition, WindowsUpdateClassesFeaturePack, WindowsUpdateClassesSecurity, WindowsUpdateClassesServicePack, WindowsUpdateClassesTools, WindowsUpdateClassesUnclassified, WindowsUpdateClassesUpdateRollup, WindowsUpdateClassesUpdates} +} + +// Account definition of the automation account type. +type Account struct { + autorest.Response `json:"-"` + // AccountProperties - Gets or sets the automation account properties. + *AccountProperties `json:"properties,omitempty"` + // Etag - Gets or sets the etag of the resource. + Etag *string `json:"etag,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The Azure Region where the resource lives + Location *string `json:"location,omitempty"` + // ID - Fully qualified resource Id for the resource + ID *string `json:"id,omitempty"` + // Name - The name of the resource + Name *string `json:"name,omitempty"` + // Type - The type of the resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Account. +func (a Account) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if a.AccountProperties != nil { + objectMap["properties"] = a.AccountProperties + } + if a.Etag != nil { + objectMap["etag"] = a.Etag + } + if a.Tags != nil { + objectMap["tags"] = a.Tags + } + if a.Location != nil { + objectMap["location"] = a.Location + } + if a.ID != nil { + objectMap["id"] = a.ID + } + if a.Name != nil { + objectMap["name"] = a.Name + } + if a.Type != nil { + objectMap["type"] = a.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Account struct. +func (a *Account) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var accountProperties AccountProperties + err = json.Unmarshal(*v, &accountProperties) + if err != nil { + return err + } + a.AccountProperties = &accountProperties + } + case "etag": + if v != nil { + var etag string + err = json.Unmarshal(*v, &etag) + if err != nil { + return err + } + a.Etag = &etag + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + a.Tags = tags + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + a.Location = &location + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + a.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + a.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + a.Type = &typeVar + } + } + } + + return nil +} + +// AccountCreateOrUpdateParameters the parameters supplied to the create or update automation account operation. +type AccountCreateOrUpdateParameters struct { + // AccountCreateOrUpdateProperties - Gets or sets account create or update properties. + *AccountCreateOrUpdateProperties `json:"properties,omitempty"` + // Name - Gets or sets name of the resource. + Name *string `json:"name,omitempty"` + // Location - Gets or sets the location of the resource. + Location *string `json:"location,omitempty"` + // Tags - Gets or sets the tags attached to the resource. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for AccountCreateOrUpdateParameters. +func (acoup AccountCreateOrUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if acoup.AccountCreateOrUpdateProperties != nil { + objectMap["properties"] = acoup.AccountCreateOrUpdateProperties + } + if acoup.Name != nil { + objectMap["name"] = acoup.Name + } + if acoup.Location != nil { + objectMap["location"] = acoup.Location + } + if acoup.Tags != nil { + objectMap["tags"] = acoup.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for AccountCreateOrUpdateParameters struct. +func (acoup *AccountCreateOrUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var accountCreateOrUpdateProperties AccountCreateOrUpdateProperties + err = json.Unmarshal(*v, &accountCreateOrUpdateProperties) + if err != nil { + return err + } + acoup.AccountCreateOrUpdateProperties = &accountCreateOrUpdateProperties + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + acoup.Name = &name + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + acoup.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + acoup.Tags = tags + } + } + } + + return nil +} + +// AccountCreateOrUpdateProperties the parameters supplied to the create or update account properties. +type AccountCreateOrUpdateProperties struct { + // Sku - Gets or sets account SKU. + Sku *Sku `json:"sku,omitempty"` +} + +// AccountListResult the response model for the list account operation. +type AccountListResult struct { + autorest.Response `json:"-"` + // Value - Gets or sets list of accounts. + Value *[]Account `json:"value,omitempty"` + // NextLink - Gets or sets the next link. + NextLink *string `json:"nextLink,omitempty"` +} + +// AccountListResultIterator provides access to a complete listing of Account values. +type AccountListResultIterator struct { + i int + page AccountListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *AccountListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter AccountListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter AccountListResultIterator) Response() AccountListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter AccountListResultIterator) Value() Account { + if !iter.page.NotDone() { + return Account{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (alr AccountListResult) IsEmpty() bool { + return alr.Value == nil || len(*alr.Value) == 0 +} + +// accountListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (alr AccountListResult) accountListResultPreparer() (*http.Request, error) { + if alr.NextLink == nil || len(to.String(alr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(alr.NextLink))) +} + +// AccountListResultPage contains a page of Account values. +type AccountListResultPage struct { + fn func(AccountListResult) (AccountListResult, error) + alr AccountListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *AccountListResultPage) Next() error { + next, err := page.fn(page.alr) + if err != nil { + return err + } + page.alr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page AccountListResultPage) NotDone() bool { + return !page.alr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page AccountListResultPage) Response() AccountListResult { + return page.alr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page AccountListResultPage) Values() []Account { + if page.alr.IsEmpty() { + return nil + } + return *page.alr.Value +} + +// AccountProperties definition of the account property. +type AccountProperties struct { + // Sku - Gets or sets the SKU of account. + Sku *Sku `json:"sku,omitempty"` + // LastModifiedBy - Gets or sets the last modified by. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + // State - Gets status of account. Possible values include: 'Ok', 'Unavailable', 'Suspended' + State AccountState `json:"state,omitempty"` + // CreationTime - Gets the creation time. + CreationTime *date.Time `json:"creationTime,omitempty"` + // LastModifiedTime - Gets the last modified time. + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + // Description - Gets or sets the description. + Description *string `json:"description,omitempty"` +} + +// AccountUpdateParameters the parameters supplied to the update automation account operation. +type AccountUpdateParameters struct { + // AccountUpdateProperties - Gets or sets account update properties. + *AccountUpdateProperties `json:"properties,omitempty"` + // Name - Gets or sets the name of the resource. + Name *string `json:"name,omitempty"` + // Location - Gets or sets the location of the resource. + Location *string `json:"location,omitempty"` + // Tags - Gets or sets the tags attached to the resource. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for AccountUpdateParameters. +func (aup AccountUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if aup.AccountUpdateProperties != nil { + objectMap["properties"] = aup.AccountUpdateProperties + } + if aup.Name != nil { + objectMap["name"] = aup.Name + } + if aup.Location != nil { + objectMap["location"] = aup.Location + } + if aup.Tags != nil { + objectMap["tags"] = aup.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for AccountUpdateParameters struct. +func (aup *AccountUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var accountUpdateProperties AccountUpdateProperties + err = json.Unmarshal(*v, &accountUpdateProperties) + if err != nil { + return err + } + aup.AccountUpdateProperties = &accountUpdateProperties + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + aup.Name = &name + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + aup.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + aup.Tags = tags + } + } + } + + return nil +} + +// AccountUpdateProperties the parameters supplied to the update account properties. +type AccountUpdateProperties struct { + // Sku - Gets or sets account SKU. + Sku *Sku `json:"sku,omitempty"` +} + +// Activity definition of the activity. +type Activity struct { + autorest.Response `json:"-"` + // ID - Gets or sets the id of the resource. + ID *string `json:"id,omitempty"` + // Name - Gets the name of the activity. + Name *string `json:"name,omitempty"` + // ActivityProperties - Gets or sets the properties of the activity. + *ActivityProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for Activity. +func (a Activity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if a.ID != nil { + objectMap["id"] = a.ID + } + if a.Name != nil { + objectMap["name"] = a.Name + } + if a.ActivityProperties != nil { + objectMap["properties"] = a.ActivityProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Activity struct. +func (a *Activity) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + a.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + a.Name = &name + } + case "properties": + if v != nil { + var activityProperties ActivityProperties + err = json.Unmarshal(*v, &activityProperties) + if err != nil { + return err + } + a.ActivityProperties = &activityProperties + } + } + } + + return nil +} + +// ActivityListResult the response model for the list activity operation. +type ActivityListResult struct { + autorest.Response `json:"-"` + // Value - Gets or sets a list of activities. + Value *[]Activity `json:"value,omitempty"` + // NextLink - Gets or sets the next link. + NextLink *string `json:"nextLink,omitempty"` +} + +// ActivityListResultIterator provides access to a complete listing of Activity values. +type ActivityListResultIterator struct { + i int + page ActivityListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ActivityListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ActivityListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ActivityListResultIterator) Response() ActivityListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ActivityListResultIterator) Value() Activity { + if !iter.page.NotDone() { + return Activity{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (alr ActivityListResult) IsEmpty() bool { + return alr.Value == nil || len(*alr.Value) == 0 +} + +// activityListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (alr ActivityListResult) activityListResultPreparer() (*http.Request, error) { + if alr.NextLink == nil || len(to.String(alr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(alr.NextLink))) +} + +// ActivityListResultPage contains a page of Activity values. +type ActivityListResultPage struct { + fn func(ActivityListResult) (ActivityListResult, error) + alr ActivityListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ActivityListResultPage) Next() error { + next, err := page.fn(page.alr) + if err != nil { + return err + } + page.alr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ActivityListResultPage) NotDone() bool { + return !page.alr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ActivityListResultPage) Response() ActivityListResult { + return page.alr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ActivityListResultPage) Values() []Activity { + if page.alr.IsEmpty() { + return nil + } + return *page.alr.Value +} + +// ActivityOutputType definition of the activity output type. +type ActivityOutputType struct { + // Name - Gets or sets the name of the activity output type. + Name *string `json:"name,omitempty"` + // Type - Gets or sets the type of the activity output type. + Type *string `json:"type,omitempty"` +} + +// ActivityParameter definition of the activity parameter. +type ActivityParameter struct { + // Name - Gets or sets the name of the activity parameter. + Name *string `json:"name,omitempty"` + // Type - Gets or sets the type of the activity parameter. + Type *string `json:"type,omitempty"` + // IsMandatory - Gets or sets a Boolean value that indicates true if the parameter is required. If the value is false, the parameter is optional. + IsMandatory *bool `json:"isMandatory,omitempty"` + // IsDynamic - Gets or sets a Boolean value that indicates true if the parameter is dynamic. + IsDynamic *bool `json:"isDynamic,omitempty"` + // Position - Gets or sets the position of the activity parameter. + Position *int64 `json:"position,omitempty"` + // ValueFromPipeline - Gets or sets a Boolean value that indicates true if the parameter can take values from the incoming pipeline objects. This setting is used if the cmdlet must access the complete input object. false indicates that the parameter cannot take values from the complete input object. + ValueFromPipeline *bool `json:"valueFromPipeline,omitempty"` + // ValueFromPipelineByPropertyName - Gets or sets a Boolean value that indicates true if the parameter can be filled from a property of the incoming pipeline object that has the same name as this parameter. false indicates that the parameter cannot be filled from the incoming pipeline object property with the same name. + ValueFromPipelineByPropertyName *bool `json:"valueFromPipelineByPropertyName,omitempty"` + // ValueFromRemainingArguments - Gets or sets a Boolean value that indicates true if the cmdlet parameter accepts all the remaining command-line arguments that are associated with this parameter in the form of an array. false if the cmdlet parameter does not accept all the remaining argument values. + ValueFromRemainingArguments *bool `json:"valueFromRemainingArguments,omitempty"` + // Description - Gets or sets the description of the activity parameter. + Description *string `json:"description,omitempty"` + // ValidationSet - Gets or sets the validation set of activity parameter. + ValidationSet *[]ActivityParameterValidationSet `json:"validationSet,omitempty"` +} + +// ActivityParameterSet definition of the activity parameter set. +type ActivityParameterSet struct { + // Name - Gets or sets the name of the activity parameter set. + Name *string `json:"name,omitempty"` + // Parameters - Gets or sets the parameters of the activity parameter set. + Parameters *[]ActivityParameter `json:"parameters,omitempty"` +} + +// ActivityParameterValidationSet definition of the activity parameter validation set. +type ActivityParameterValidationSet struct { + // MemberValue - Gets or sets the name of the activity parameter validation set member. + MemberValue *string `json:"memberValue,omitempty"` +} + +// ActivityProperties properties of the activity. +type ActivityProperties struct { + // Definition - Gets or sets the user name of the activity. + Definition *string `json:"definition,omitempty"` + // ParameterSets - Gets or sets the parameter sets of the activity. + ParameterSets *[]ActivityParameterSet `json:"parameterSets,omitempty"` + // OutputTypes - Gets or sets the output types of the activity. + OutputTypes *[]ActivityOutputType `json:"outputTypes,omitempty"` + // CreationTime - Gets or sets the creation time. + CreationTime *date.Time `json:"creationTime,omitempty"` + // LastModifiedTime - Gets or sets the last modified time. + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + // Description - Gets or sets the description. + Description *string `json:"description,omitempty"` +} + +// AdvancedSchedule the properties of the create Advanced Schedule. +type AdvancedSchedule struct { + // WeekDays - Days of the week that the job should execute on. + WeekDays *[]string `json:"weekDays,omitempty"` + // MonthDays - Days of the month that the job should execute on. Must be between 1 and 31. + MonthDays *[]int32 `json:"monthDays,omitempty"` + // MonthlyOccurrences - Occurrences of days within a month. + MonthlyOccurrences *[]AdvancedScheduleMonthlyOccurrence `json:"monthlyOccurrences,omitempty"` +} + +// AdvancedScheduleMonthlyOccurrence the properties of the create advanced schedule monthly occurrence. +type AdvancedScheduleMonthlyOccurrence struct { + // Occurrence - Occurrence of the week within the month. Must be between 1 and 5 + Occurrence *int32 `json:"occurrence,omitempty"` + // Day - Day of the occurrence. Must be one of monday, tuesday, wednesday, thursday, friday, saturday, sunday. Possible values include: 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday' + Day ScheduleDay `json:"day,omitempty"` +} + +// AgentRegistration definition of the agent registration infomration type. +type AgentRegistration struct { + autorest.Response `json:"-"` + // DscMetaConfiguration - Gets or sets the dsc meta configuration. + DscMetaConfiguration *string `json:"dscMetaConfiguration,omitempty"` + // Endpoint - Gets or sets the dsc server endpoint. + Endpoint *string `json:"endpoint,omitempty"` + // Keys - Gets or sets the agent registration keys. + Keys *AgentRegistrationKeys `json:"keys,omitempty"` + // ID - Gets or sets the id. + ID *string `json:"id,omitempty"` +} + +// AgentRegistrationKeys definition of the agent registration keys. +type AgentRegistrationKeys struct { + // Primary - Gets or sets the primary key. + Primary *string `json:"primary,omitempty"` + // Secondary - Gets or sets the secondary key. + Secondary *string `json:"secondary,omitempty"` +} + +// AgentRegistrationRegenerateKeyParameter the parameters supplied to the regenerate keys operation. +type AgentRegistrationRegenerateKeyParameter struct { + // KeyName - Gets or sets the agent registration key name - primary or secondary. Possible values include: 'Primary', 'Secondary' + KeyName AgentRegistrationKeyName `json:"keyName,omitempty"` +} + +// AzureQueryProperties azure query for the update configuration. +type AzureQueryProperties struct { + // Scope - List of Subscription or Resource Group ARM Ids. + Scope *[]string `json:"scope,omitempty"` + // Location - List of locations to scope the query to. + Location *[]string `json:"location,omitempty"` + // TagSettings - Tag settings for the VM. + TagSettings *TagSettingsProperties `json:"tagSettings,omitempty"` +} + +// Certificate definition of the certificate. +type Certificate struct { + autorest.Response `json:"-"` + // CertificateProperties - Gets or sets the properties of the certificate. + *CertificateProperties `json:"properties,omitempty"` + // ID - Fully qualified resource Id for the resource + ID *string `json:"id,omitempty"` + // Name - The name of the resource + Name *string `json:"name,omitempty"` + // Type - The type of the resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Certificate. +func (c Certificate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if c.CertificateProperties != nil { + objectMap["properties"] = c.CertificateProperties + } + if c.ID != nil { + objectMap["id"] = c.ID + } + if c.Name != nil { + objectMap["name"] = c.Name + } + if c.Type != nil { + objectMap["type"] = c.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Certificate struct. +func (c *Certificate) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var certificateProperties CertificateProperties + err = json.Unmarshal(*v, &certificateProperties) + if err != nil { + return err + } + c.CertificateProperties = &certificateProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + c.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + c.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + c.Type = &typeVar + } + } + } + + return nil +} + +// CertificateCreateOrUpdateParameters the parameters supplied to the create or update or replace certificate +// operation. +type CertificateCreateOrUpdateParameters struct { + // Name - Gets or sets the name of the certificate. + Name *string `json:"name,omitempty"` + // CertificateCreateOrUpdateProperties - Gets or sets the properties of the certificate. + *CertificateCreateOrUpdateProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for CertificateCreateOrUpdateParameters. +func (ccoup CertificateCreateOrUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ccoup.Name != nil { + objectMap["name"] = ccoup.Name + } + if ccoup.CertificateCreateOrUpdateProperties != nil { + objectMap["properties"] = ccoup.CertificateCreateOrUpdateProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for CertificateCreateOrUpdateParameters struct. +func (ccoup *CertificateCreateOrUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ccoup.Name = &name + } + case "properties": + if v != nil { + var certificateCreateOrUpdateProperties CertificateCreateOrUpdateProperties + err = json.Unmarshal(*v, &certificateCreateOrUpdateProperties) + if err != nil { + return err + } + ccoup.CertificateCreateOrUpdateProperties = &certificateCreateOrUpdateProperties + } + } + } + + return nil +} + +// CertificateCreateOrUpdateProperties the properties of the create certificate operation. +type CertificateCreateOrUpdateProperties struct { + // Base64Value - Gets or sets the base64 encoded value of the certificate. + Base64Value *string `json:"base64Value,omitempty"` + // Description - Gets or sets the description of the certificate. + Description *string `json:"description,omitempty"` + // Thumbprint - Gets or sets the thumbprint of the certificate. + Thumbprint *string `json:"thumbprint,omitempty"` + // IsExportable - Gets or sets the is exportable flag of the certificate. + IsExportable *bool `json:"isExportable,omitempty"` +} + +// CertificateListResult the response model for the list certificate operation. +type CertificateListResult struct { + autorest.Response `json:"-"` + // Value - Gets or sets a list of certificates. + Value *[]Certificate `json:"value,omitempty"` + // NextLink - Gets or sets the next link. + NextLink *string `json:"nextLink,omitempty"` +} + +// CertificateListResultIterator provides access to a complete listing of Certificate values. +type CertificateListResultIterator struct { + i int + page CertificateListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *CertificateListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter CertificateListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter CertificateListResultIterator) Response() CertificateListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter CertificateListResultIterator) Value() Certificate { + if !iter.page.NotDone() { + return Certificate{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (clr CertificateListResult) IsEmpty() bool { + return clr.Value == nil || len(*clr.Value) == 0 +} + +// certificateListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (clr CertificateListResult) certificateListResultPreparer() (*http.Request, error) { + if clr.NextLink == nil || len(to.String(clr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(clr.NextLink))) +} + +// CertificateListResultPage contains a page of Certificate values. +type CertificateListResultPage struct { + fn func(CertificateListResult) (CertificateListResult, error) + clr CertificateListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *CertificateListResultPage) Next() error { + next, err := page.fn(page.clr) + if err != nil { + return err + } + page.clr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page CertificateListResultPage) NotDone() bool { + return !page.clr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page CertificateListResultPage) Response() CertificateListResult { + return page.clr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page CertificateListResultPage) Values() []Certificate { + if page.clr.IsEmpty() { + return nil + } + return *page.clr.Value +} + +// CertificateProperties properties of the certificate. +type CertificateProperties struct { + // Thumbprint - Gets the thumbprint of the certificate. + Thumbprint *string `json:"thumbprint,omitempty"` + // ExpiryTime - Gets the expiry time of the certificate. + ExpiryTime *date.Time `json:"expiryTime,omitempty"` + // IsExportable - Gets the is exportable flag of the certificate. + IsExportable *bool `json:"isExportable,omitempty"` + // CreationTime - Gets the creation time. + CreationTime *date.Time `json:"creationTime,omitempty"` + // LastModifiedTime - Gets the last modified time. + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + // Description - Gets or sets the description. + Description *string `json:"description,omitempty"` +} + +// CertificateUpdateParameters the parameters supplied to the update certificate operation. +type CertificateUpdateParameters struct { + // Name - Gets or sets the name of the certificate. + Name *string `json:"name,omitempty"` + // CertificateUpdateProperties - Gets or sets the properties of the certificate. + *CertificateUpdateProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for CertificateUpdateParameters. +func (cup CertificateUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cup.Name != nil { + objectMap["name"] = cup.Name + } + if cup.CertificateUpdateProperties != nil { + objectMap["properties"] = cup.CertificateUpdateProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for CertificateUpdateParameters struct. +func (cup *CertificateUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + cup.Name = &name + } + case "properties": + if v != nil { + var certificateUpdateProperties CertificateUpdateProperties + err = json.Unmarshal(*v, &certificateUpdateProperties) + if err != nil { + return err + } + cup.CertificateUpdateProperties = &certificateUpdateProperties + } + } + } + + return nil +} + +// CertificateUpdateProperties the properties of the update certificate operation +type CertificateUpdateProperties struct { + // Description - Gets or sets the description of the certificate. + Description *string `json:"description,omitempty"` +} + +// CollectionItemUpdateConfiguration object returned when requesting a collection of software update configuration +type CollectionItemUpdateConfiguration struct { + // AzureVirtualMachines - List of azure resource Ids for azure virtual machines targeted by the software update configuration. + AzureVirtualMachines *[]string `json:"azureVirtualMachines,omitempty"` + // Duration - Maximum time allowed for the software update configuration run. Duration needs to be specified using the format PT[n]H[n]M[n]S as per ISO8601 + Duration *string `json:"duration,omitempty"` +} + +// Connection definition of the connection. +type Connection struct { + autorest.Response `json:"-"` + // ConnectionProperties - Gets or sets the properties of the connection. + *ConnectionProperties `json:"properties,omitempty"` + // ID - Fully qualified resource Id for the resource + ID *string `json:"id,omitempty"` + // Name - The name of the resource + Name *string `json:"name,omitempty"` + // Type - The type of the resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Connection. +func (c Connection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if c.ConnectionProperties != nil { + objectMap["properties"] = c.ConnectionProperties + } + if c.ID != nil { + objectMap["id"] = c.ID + } + if c.Name != nil { + objectMap["name"] = c.Name + } + if c.Type != nil { + objectMap["type"] = c.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Connection struct. +func (c *Connection) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var connectionProperties ConnectionProperties + err = json.Unmarshal(*v, &connectionProperties) + if err != nil { + return err + } + c.ConnectionProperties = &connectionProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + c.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + c.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + c.Type = &typeVar + } + } + } + + return nil +} + +// ConnectionCreateOrUpdateParameters the parameters supplied to the create or update connection operation. +type ConnectionCreateOrUpdateParameters struct { + // Name - Gets or sets the name of the connection. + Name *string `json:"name,omitempty"` + // ConnectionCreateOrUpdateProperties - Gets or sets the properties of the connection. + *ConnectionCreateOrUpdateProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for ConnectionCreateOrUpdateParameters. +func (ccoup ConnectionCreateOrUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ccoup.Name != nil { + objectMap["name"] = ccoup.Name + } + if ccoup.ConnectionCreateOrUpdateProperties != nil { + objectMap["properties"] = ccoup.ConnectionCreateOrUpdateProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ConnectionCreateOrUpdateParameters struct. +func (ccoup *ConnectionCreateOrUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ccoup.Name = &name + } + case "properties": + if v != nil { + var connectionCreateOrUpdateProperties ConnectionCreateOrUpdateProperties + err = json.Unmarshal(*v, &connectionCreateOrUpdateProperties) + if err != nil { + return err + } + ccoup.ConnectionCreateOrUpdateProperties = &connectionCreateOrUpdateProperties + } + } + } + + return nil +} + +// ConnectionCreateOrUpdateProperties the properties of the create connection properties +type ConnectionCreateOrUpdateProperties struct { + // Description - Gets or sets the description of the connection. + Description *string `json:"description,omitempty"` + // ConnectionType - Gets or sets the connectionType of the connection. + ConnectionType *ConnectionTypeAssociationProperty `json:"connectionType,omitempty"` + // FieldDefinitionValues - Gets or sets the field definition properties of the connection. + FieldDefinitionValues map[string]*string `json:"fieldDefinitionValues"` +} + +// MarshalJSON is the custom marshaler for ConnectionCreateOrUpdateProperties. +func (ccoup ConnectionCreateOrUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ccoup.Description != nil { + objectMap["description"] = ccoup.Description + } + if ccoup.ConnectionType != nil { + objectMap["connectionType"] = ccoup.ConnectionType + } + if ccoup.FieldDefinitionValues != nil { + objectMap["fieldDefinitionValues"] = ccoup.FieldDefinitionValues + } + return json.Marshal(objectMap) +} + +// ConnectionListResult the response model for the list connection operation. +type ConnectionListResult struct { + autorest.Response `json:"-"` + // Value - Gets or sets a list of connection. + Value *[]Connection `json:"value,omitempty"` + // NextLink - Gets or sets the next link. + NextLink *string `json:"nextLink,omitempty"` +} + +// ConnectionListResultIterator provides access to a complete listing of Connection values. +type ConnectionListResultIterator struct { + i int + page ConnectionListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ConnectionListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ConnectionListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ConnectionListResultIterator) Response() ConnectionListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ConnectionListResultIterator) Value() Connection { + if !iter.page.NotDone() { + return Connection{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (clr ConnectionListResult) IsEmpty() bool { + return clr.Value == nil || len(*clr.Value) == 0 +} + +// connectionListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (clr ConnectionListResult) connectionListResultPreparer() (*http.Request, error) { + if clr.NextLink == nil || len(to.String(clr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(clr.NextLink))) +} + +// ConnectionListResultPage contains a page of Connection values. +type ConnectionListResultPage struct { + fn func(ConnectionListResult) (ConnectionListResult, error) + clr ConnectionListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ConnectionListResultPage) Next() error { + next, err := page.fn(page.clr) + if err != nil { + return err + } + page.clr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ConnectionListResultPage) NotDone() bool { + return !page.clr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ConnectionListResultPage) Response() ConnectionListResult { + return page.clr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ConnectionListResultPage) Values() []Connection { + if page.clr.IsEmpty() { + return nil + } + return *page.clr.Value +} + +// ConnectionProperties definition of the connection properties. +type ConnectionProperties struct { + // ConnectionType - Gets or sets the connectionType of the connection. + ConnectionType *ConnectionTypeAssociationProperty `json:"connectionType,omitempty"` + // FieldDefinitionValues - Gets the field definition values of the connection. + FieldDefinitionValues map[string]*string `json:"fieldDefinitionValues"` + // CreationTime - Gets the creation time. + CreationTime *date.Time `json:"creationTime,omitempty"` + // LastModifiedTime - Gets the last modified time. + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + // Description - Gets or sets the description. + Description *string `json:"description,omitempty"` +} + +// MarshalJSON is the custom marshaler for ConnectionProperties. +func (cp ConnectionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cp.ConnectionType != nil { + objectMap["connectionType"] = cp.ConnectionType + } + if cp.FieldDefinitionValues != nil { + objectMap["fieldDefinitionValues"] = cp.FieldDefinitionValues + } + if cp.CreationTime != nil { + objectMap["creationTime"] = cp.CreationTime + } + if cp.LastModifiedTime != nil { + objectMap["lastModifiedTime"] = cp.LastModifiedTime + } + if cp.Description != nil { + objectMap["description"] = cp.Description + } + return json.Marshal(objectMap) +} + +// ConnectionType definition of the connection type. +type ConnectionType struct { + autorest.Response `json:"-"` + // ID - Gets the id of the resource. + ID *string `json:"id,omitempty"` + // Name - Gets the name of the connection type. + Name *string `json:"name,omitempty"` + // Type - Resource type + Type *string `json:"type,omitempty"` + // ConnectionTypeProperties - Gets or sets the properties of the connection type. + *ConnectionTypeProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for ConnectionType. +func (ct ConnectionType) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ct.ID != nil { + objectMap["id"] = ct.ID + } + if ct.Name != nil { + objectMap["name"] = ct.Name + } + if ct.Type != nil { + objectMap["type"] = ct.Type + } + if ct.ConnectionTypeProperties != nil { + objectMap["properties"] = ct.ConnectionTypeProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ConnectionType struct. +func (ct *ConnectionType) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ct.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ct.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ct.Type = &typeVar + } + case "properties": + if v != nil { + var connectionTypeProperties ConnectionTypeProperties + err = json.Unmarshal(*v, &connectionTypeProperties) + if err != nil { + return err + } + ct.ConnectionTypeProperties = &connectionTypeProperties + } + } + } + + return nil +} + +// ConnectionTypeAssociationProperty the connection type property associated with the entity. +type ConnectionTypeAssociationProperty struct { + // Name - Gets or sets the name of the connection type. + Name *string `json:"name,omitempty"` +} + +// ConnectionTypeCreateOrUpdateParameters the parameters supplied to the create or update connection type +// operation. +type ConnectionTypeCreateOrUpdateParameters struct { + // Name - Gets or sets the name of the connection type. + Name *string `json:"name,omitempty"` + // ConnectionTypeCreateOrUpdateProperties - Gets or sets the value of the connection type. + *ConnectionTypeCreateOrUpdateProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for ConnectionTypeCreateOrUpdateParameters. +func (ctcoup ConnectionTypeCreateOrUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ctcoup.Name != nil { + objectMap["name"] = ctcoup.Name + } + if ctcoup.ConnectionTypeCreateOrUpdateProperties != nil { + objectMap["properties"] = ctcoup.ConnectionTypeCreateOrUpdateProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ConnectionTypeCreateOrUpdateParameters struct. +func (ctcoup *ConnectionTypeCreateOrUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ctcoup.Name = &name + } + case "properties": + if v != nil { + var connectionTypeCreateOrUpdateProperties ConnectionTypeCreateOrUpdateProperties + err = json.Unmarshal(*v, &connectionTypeCreateOrUpdateProperties) + if err != nil { + return err + } + ctcoup.ConnectionTypeCreateOrUpdateProperties = &connectionTypeCreateOrUpdateProperties + } + } + } + + return nil +} + +// ConnectionTypeCreateOrUpdateProperties the properties of the create connection type. +type ConnectionTypeCreateOrUpdateProperties struct { + // IsGlobal - Gets or sets a Boolean value to indicate if the connection type is global. + IsGlobal *bool `json:"isGlobal,omitempty"` + // FieldDefinitions - Gets or sets the field definitions of the connection type. + FieldDefinitions map[string]*FieldDefinition `json:"fieldDefinitions"` +} + +// MarshalJSON is the custom marshaler for ConnectionTypeCreateOrUpdateProperties. +func (ctcoup ConnectionTypeCreateOrUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ctcoup.IsGlobal != nil { + objectMap["isGlobal"] = ctcoup.IsGlobal + } + if ctcoup.FieldDefinitions != nil { + objectMap["fieldDefinitions"] = ctcoup.FieldDefinitions + } + return json.Marshal(objectMap) +} + +// ConnectionTypeListResult the response model for the list connection type operation. +type ConnectionTypeListResult struct { + autorest.Response `json:"-"` + // Value - Gets or sets a list of connection types. + Value *[]ConnectionType `json:"value,omitempty"` + // NextLink - Gets or sets the next link. + NextLink *string `json:"nextLink,omitempty"` +} + +// ConnectionTypeListResultIterator provides access to a complete listing of ConnectionType values. +type ConnectionTypeListResultIterator struct { + i int + page ConnectionTypeListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ConnectionTypeListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ConnectionTypeListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ConnectionTypeListResultIterator) Response() ConnectionTypeListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ConnectionTypeListResultIterator) Value() ConnectionType { + if !iter.page.NotDone() { + return ConnectionType{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (ctlr ConnectionTypeListResult) IsEmpty() bool { + return ctlr.Value == nil || len(*ctlr.Value) == 0 +} + +// connectionTypeListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ctlr ConnectionTypeListResult) connectionTypeListResultPreparer() (*http.Request, error) { + if ctlr.NextLink == nil || len(to.String(ctlr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ctlr.NextLink))) +} + +// ConnectionTypeListResultPage contains a page of ConnectionType values. +type ConnectionTypeListResultPage struct { + fn func(ConnectionTypeListResult) (ConnectionTypeListResult, error) + ctlr ConnectionTypeListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ConnectionTypeListResultPage) Next() error { + next, err := page.fn(page.ctlr) + if err != nil { + return err + } + page.ctlr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ConnectionTypeListResultPage) NotDone() bool { + return !page.ctlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ConnectionTypeListResultPage) Response() ConnectionTypeListResult { + return page.ctlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ConnectionTypeListResultPage) Values() []ConnectionType { + if page.ctlr.IsEmpty() { + return nil + } + return *page.ctlr.Value +} + +// ConnectionTypeProperties properties of the connection type. +type ConnectionTypeProperties struct { + // IsGlobal - Gets or sets a Boolean value to indicate if the connection type is global. + IsGlobal *bool `json:"isGlobal,omitempty"` + // FieldDefinitions - Gets the field definitions of the connection type. + FieldDefinitions map[string]*FieldDefinition `json:"fieldDefinitions"` + // CreationTime - Gets the creation time. + CreationTime *date.Time `json:"creationTime,omitempty"` + // LastModifiedTime - Gets or sets the last modified time. + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + // Description - Gets or sets the description. + Description *string `json:"description,omitempty"` +} + +// MarshalJSON is the custom marshaler for ConnectionTypeProperties. +func (ctp ConnectionTypeProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ctp.IsGlobal != nil { + objectMap["isGlobal"] = ctp.IsGlobal + } + if ctp.FieldDefinitions != nil { + objectMap["fieldDefinitions"] = ctp.FieldDefinitions + } + if ctp.CreationTime != nil { + objectMap["creationTime"] = ctp.CreationTime + } + if ctp.LastModifiedTime != nil { + objectMap["lastModifiedTime"] = ctp.LastModifiedTime + } + if ctp.Description != nil { + objectMap["description"] = ctp.Description + } + return json.Marshal(objectMap) +} + +// ConnectionUpdateParameters the parameters supplied to the update connection operation. +type ConnectionUpdateParameters struct { + // Name - Gets or sets the name of the connection. + Name *string `json:"name,omitempty"` + // ConnectionUpdateProperties - Gets or sets the properties of the connection. + *ConnectionUpdateProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for ConnectionUpdateParameters. +func (cup ConnectionUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cup.Name != nil { + objectMap["name"] = cup.Name + } + if cup.ConnectionUpdateProperties != nil { + objectMap["properties"] = cup.ConnectionUpdateProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ConnectionUpdateParameters struct. +func (cup *ConnectionUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + cup.Name = &name + } + case "properties": + if v != nil { + var connectionUpdateProperties ConnectionUpdateProperties + err = json.Unmarshal(*v, &connectionUpdateProperties) + if err != nil { + return err + } + cup.ConnectionUpdateProperties = &connectionUpdateProperties + } + } + } + + return nil +} + +// ConnectionUpdateProperties the properties of the update connection operation. +type ConnectionUpdateProperties struct { + // Description - Gets or sets the description of the connection. + Description *string `json:"description,omitempty"` + // FieldDefinitionValues - Gets or sets the field definition values of the connection. + FieldDefinitionValues map[string]*string `json:"fieldDefinitionValues"` +} + +// MarshalJSON is the custom marshaler for ConnectionUpdateProperties. +func (cup ConnectionUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cup.Description != nil { + objectMap["description"] = cup.Description + } + if cup.FieldDefinitionValues != nil { + objectMap["fieldDefinitionValues"] = cup.FieldDefinitionValues + } + return json.Marshal(objectMap) +} + +// ContentHash definition of the runbook property type. +type ContentHash struct { + // Algorithm - Gets or sets the content hash algorithm used to hash the content. + Algorithm *string `json:"algorithm,omitempty"` + // Value - Gets or sets expected hash value of the content. + Value *string `json:"value,omitempty"` +} + +// ContentLink definition of the content link. +type ContentLink struct { + // URI - Gets or sets the uri of the runbook content. + URI *string `json:"uri,omitempty"` + // ContentHash - Gets or sets the hash. + ContentHash *ContentHash `json:"contentHash,omitempty"` + // Version - Gets or sets the version of the content. + Version *string `json:"version,omitempty"` +} + +// ContentSource definition of the content source. +type ContentSource struct { + // Hash - Gets or sets the hash. + Hash *ContentHash `json:"hash,omitempty"` + // Type - Gets or sets the content source type. Possible values include: 'EmbeddedContent', 'URI' + Type ContentSourceType `json:"type,omitempty"` + // Value - Gets or sets the value of the content. This is based on the content source type. + Value *string `json:"value,omitempty"` + // Version - Gets or sets the version of the content. + Version *string `json:"version,omitempty"` +} + +// Credential definition of the credential. +type Credential struct { + autorest.Response `json:"-"` + // CredentialProperties - Gets or sets the properties of the credential. + *CredentialProperties `json:"properties,omitempty"` + // ID - Fully qualified resource Id for the resource + ID *string `json:"id,omitempty"` + // Name - The name of the resource + Name *string `json:"name,omitempty"` + // Type - The type of the resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Credential. +func (c Credential) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if c.CredentialProperties != nil { + objectMap["properties"] = c.CredentialProperties + } + if c.ID != nil { + objectMap["id"] = c.ID + } + if c.Name != nil { + objectMap["name"] = c.Name + } + if c.Type != nil { + objectMap["type"] = c.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Credential struct. +func (c *Credential) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var credentialProperties CredentialProperties + err = json.Unmarshal(*v, &credentialProperties) + if err != nil { + return err + } + c.CredentialProperties = &credentialProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + c.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + c.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + c.Type = &typeVar + } + } + } + + return nil +} + +// CredentialCreateOrUpdateParameters the parameters supplied to the create or update credential operation. +type CredentialCreateOrUpdateParameters struct { + // Name - Gets or sets the name of the credential. + Name *string `json:"name,omitempty"` + // CredentialCreateOrUpdateProperties - Gets or sets the properties of the credential. + *CredentialCreateOrUpdateProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for CredentialCreateOrUpdateParameters. +func (ccoup CredentialCreateOrUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ccoup.Name != nil { + objectMap["name"] = ccoup.Name + } + if ccoup.CredentialCreateOrUpdateProperties != nil { + objectMap["properties"] = ccoup.CredentialCreateOrUpdateProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for CredentialCreateOrUpdateParameters struct. +func (ccoup *CredentialCreateOrUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ccoup.Name = &name + } + case "properties": + if v != nil { + var credentialCreateOrUpdateProperties CredentialCreateOrUpdateProperties + err = json.Unmarshal(*v, &credentialCreateOrUpdateProperties) + if err != nil { + return err + } + ccoup.CredentialCreateOrUpdateProperties = &credentialCreateOrUpdateProperties + } + } + } + + return nil +} + +// CredentialCreateOrUpdateProperties the properties of the create cerdential operation. +type CredentialCreateOrUpdateProperties struct { + // UserName - Gets or sets the user name of the credential. + UserName *string `json:"userName,omitempty"` + // Password - Gets or sets the password of the credential. + Password *string `json:"password,omitempty"` + // Description - Gets or sets the description of the credential. + Description *string `json:"description,omitempty"` +} + +// CredentialListResult the response model for the list credential operation. +type CredentialListResult struct { + autorest.Response `json:"-"` + // Value - Gets or sets a list of credentials. + Value *[]Credential `json:"value,omitempty"` + // NextLink - Gets or sets the next link. + NextLink *string `json:"nextLink,omitempty"` +} + +// CredentialListResultIterator provides access to a complete listing of Credential values. +type CredentialListResultIterator struct { + i int + page CredentialListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *CredentialListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter CredentialListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter CredentialListResultIterator) Response() CredentialListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter CredentialListResultIterator) Value() Credential { + if !iter.page.NotDone() { + return Credential{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (clr CredentialListResult) IsEmpty() bool { + return clr.Value == nil || len(*clr.Value) == 0 +} + +// credentialListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (clr CredentialListResult) credentialListResultPreparer() (*http.Request, error) { + if clr.NextLink == nil || len(to.String(clr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(clr.NextLink))) +} + +// CredentialListResultPage contains a page of Credential values. +type CredentialListResultPage struct { + fn func(CredentialListResult) (CredentialListResult, error) + clr CredentialListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *CredentialListResultPage) Next() error { + next, err := page.fn(page.clr) + if err != nil { + return err + } + page.clr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page CredentialListResultPage) NotDone() bool { + return !page.clr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page CredentialListResultPage) Response() CredentialListResult { + return page.clr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page CredentialListResultPage) Values() []Credential { + if page.clr.IsEmpty() { + return nil + } + return *page.clr.Value +} + +// CredentialProperties definition of the credential properties +type CredentialProperties struct { + // UserName - Gets the user name of the credential. + UserName *string `json:"userName,omitempty"` + // CreationTime - Gets the creation time. + CreationTime *date.Time `json:"creationTime,omitempty"` + // LastModifiedTime - Gets the last modified time. + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + // Description - Gets or sets the description. + Description *string `json:"description,omitempty"` +} + +// CredentialUpdateParameters the parameters supplied to the Update credential operation. +type CredentialUpdateParameters struct { + // Name - Gets or sets the name of the credential. + Name *string `json:"name,omitempty"` + // CredentialUpdateProperties - Gets or sets the properties of the variable. + *CredentialUpdateProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for CredentialUpdateParameters. +func (cup CredentialUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cup.Name != nil { + objectMap["name"] = cup.Name + } + if cup.CredentialUpdateProperties != nil { + objectMap["properties"] = cup.CredentialUpdateProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for CredentialUpdateParameters struct. +func (cup *CredentialUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + cup.Name = &name + } + case "properties": + if v != nil { + var credentialUpdateProperties CredentialUpdateProperties + err = json.Unmarshal(*v, &credentialUpdateProperties) + if err != nil { + return err + } + cup.CredentialUpdateProperties = &credentialUpdateProperties + } + } + } + + return nil +} + +// CredentialUpdateProperties the properties of the Update credential +type CredentialUpdateProperties struct { + // UserName - Gets or sets the user name of the credential. + UserName *string `json:"userName,omitempty"` + // Password - Gets or sets the password of the credential. + Password *string `json:"password,omitempty"` + // Description - Gets or sets the description of the credential. + Description *string `json:"description,omitempty"` +} + +// DscCompilationJob definition of the Dsc Compilation job. +type DscCompilationJob struct { + autorest.Response `json:"-"` + // DscCompilationJobProperties - Gets or sets the properties of the Dsc Compilation job. + *DscCompilationJobProperties `json:"properties,omitempty"` + // ID - Fully qualified resource Id for the resource + ID *string `json:"id,omitempty"` + // Name - The name of the resource + Name *string `json:"name,omitempty"` + // Type - The type of the resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for DscCompilationJob. +func (dcj DscCompilationJob) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dcj.DscCompilationJobProperties != nil { + objectMap["properties"] = dcj.DscCompilationJobProperties + } + if dcj.ID != nil { + objectMap["id"] = dcj.ID + } + if dcj.Name != nil { + objectMap["name"] = dcj.Name + } + if dcj.Type != nil { + objectMap["type"] = dcj.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DscCompilationJob struct. +func (dcj *DscCompilationJob) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var dscCompilationJobProperties DscCompilationJobProperties + err = json.Unmarshal(*v, &dscCompilationJobProperties) + if err != nil { + return err + } + dcj.DscCompilationJobProperties = &dscCompilationJobProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + dcj.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dcj.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + dcj.Type = &typeVar + } + } + } + + return nil +} + +// DscCompilationJobCreateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type DscCompilationJobCreateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *DscCompilationJobCreateFuture) Result(client DscCompilationJobClient) (dcj DscCompilationJob, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobCreateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("automation.DscCompilationJobCreateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if dcj.Response.Response, err = future.GetResult(sender); err == nil && dcj.Response.Response.StatusCode != http.StatusNoContent { + dcj, err = client.CreateResponder(dcj.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobCreateFuture", "Result", dcj.Response.Response, "Failure responding to request") + } + } + return +} + +// DscCompilationJobCreateParameters the parameters supplied to the create compilation job operation. +type DscCompilationJobCreateParameters struct { + // DscCompilationJobCreateProperties - Gets or sets the list of compilation job properties. + *DscCompilationJobCreateProperties `json:"properties,omitempty"` + // Name - Gets or sets name of the resource. + Name *string `json:"name,omitempty"` + // Location - Gets or sets the location of the resource. + Location *string `json:"location,omitempty"` + // Tags - Gets or sets the tags attached to the resource. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for DscCompilationJobCreateParameters. +func (dcjcp DscCompilationJobCreateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dcjcp.DscCompilationJobCreateProperties != nil { + objectMap["properties"] = dcjcp.DscCompilationJobCreateProperties + } + if dcjcp.Name != nil { + objectMap["name"] = dcjcp.Name + } + if dcjcp.Location != nil { + objectMap["location"] = dcjcp.Location + } + if dcjcp.Tags != nil { + objectMap["tags"] = dcjcp.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DscCompilationJobCreateParameters struct. +func (dcjcp *DscCompilationJobCreateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var dscCompilationJobCreateProperties DscCompilationJobCreateProperties + err = json.Unmarshal(*v, &dscCompilationJobCreateProperties) + if err != nil { + return err + } + dcjcp.DscCompilationJobCreateProperties = &dscCompilationJobCreateProperties + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dcjcp.Name = &name + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + dcjcp.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + dcjcp.Tags = tags + } + } + } + + return nil +} + +// DscCompilationJobCreateProperties the parameters supplied to the create compilation job operation. +type DscCompilationJobCreateProperties struct { + // Configuration - Gets or sets the configuration. + Configuration *DscConfigurationAssociationProperty `json:"configuration,omitempty"` + // Parameters - Gets or sets the parameters of the job. + Parameters map[string]*string `json:"parameters"` + // IncrementNodeConfigurationBuild - If a new build version of NodeConfiguration is required. + IncrementNodeConfigurationBuild *bool `json:"incrementNodeConfigurationBuild,omitempty"` +} + +// MarshalJSON is the custom marshaler for DscCompilationJobCreateProperties. +func (dcjcp DscCompilationJobCreateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dcjcp.Configuration != nil { + objectMap["configuration"] = dcjcp.Configuration + } + if dcjcp.Parameters != nil { + objectMap["parameters"] = dcjcp.Parameters + } + if dcjcp.IncrementNodeConfigurationBuild != nil { + objectMap["incrementNodeConfigurationBuild"] = dcjcp.IncrementNodeConfigurationBuild + } + return json.Marshal(objectMap) +} + +// DscCompilationJobListResult the response model for the list job operation. +type DscCompilationJobListResult struct { + autorest.Response `json:"-"` + // Value - Gets or sets a list of Dsc Compilation jobs. + Value *[]DscCompilationJob `json:"value,omitempty"` + // NextLink - Gets or sets the next link. + NextLink *string `json:"nextLink,omitempty"` +} + +// DscCompilationJobListResultIterator provides access to a complete listing of DscCompilationJob values. +type DscCompilationJobListResultIterator struct { + i int + page DscCompilationJobListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *DscCompilationJobListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter DscCompilationJobListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter DscCompilationJobListResultIterator) Response() DscCompilationJobListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter DscCompilationJobListResultIterator) Value() DscCompilationJob { + if !iter.page.NotDone() { + return DscCompilationJob{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (dcjlr DscCompilationJobListResult) IsEmpty() bool { + return dcjlr.Value == nil || len(*dcjlr.Value) == 0 +} + +// dscCompilationJobListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (dcjlr DscCompilationJobListResult) dscCompilationJobListResultPreparer() (*http.Request, error) { + if dcjlr.NextLink == nil || len(to.String(dcjlr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(dcjlr.NextLink))) +} + +// DscCompilationJobListResultPage contains a page of DscCompilationJob values. +type DscCompilationJobListResultPage struct { + fn func(DscCompilationJobListResult) (DscCompilationJobListResult, error) + dcjlr DscCompilationJobListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *DscCompilationJobListResultPage) Next() error { + next, err := page.fn(page.dcjlr) + if err != nil { + return err + } + page.dcjlr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page DscCompilationJobListResultPage) NotDone() bool { + return !page.dcjlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page DscCompilationJobListResultPage) Response() DscCompilationJobListResult { + return page.dcjlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page DscCompilationJobListResultPage) Values() []DscCompilationJob { + if page.dcjlr.IsEmpty() { + return nil + } + return *page.dcjlr.Value +} + +// DscCompilationJobProperties definition of Dsc Compilation job properties. +type DscCompilationJobProperties struct { + // Configuration - Gets or sets the configuration. + Configuration *DscConfigurationAssociationProperty `json:"configuration,omitempty"` + // StartedBy - Gets the compilation job started by. + StartedBy *string `json:"startedBy,omitempty"` + // JobID - Gets the id of the job. + JobID *uuid.UUID `json:"jobId,omitempty"` + // CreationTime - Gets the creation time of the job. + CreationTime *date.Time `json:"creationTime,omitempty"` + // ProvisioningState - The current provisioning state of the job. Possible values include: 'JobProvisioningStateFailed', 'JobProvisioningStateSucceeded', 'JobProvisioningStateSuspended', 'JobProvisioningStateProcessing' + ProvisioningState JobProvisioningState `json:"provisioningState,omitempty"` + // RunOn - Gets or sets the runOn which specifies the group name where the job is to be executed. + RunOn *string `json:"runOn,omitempty"` + // Status - Gets or sets the status of the job. Possible values include: 'JobStatusNew', 'JobStatusActivating', 'JobStatusRunning', 'JobStatusCompleted', 'JobStatusFailed', 'JobStatusStopped', 'JobStatusBlocked', 'JobStatusSuspended', 'JobStatusDisconnected', 'JobStatusSuspending', 'JobStatusStopping', 'JobStatusResuming', 'JobStatusRemoving' + Status JobStatus `json:"status,omitempty"` + // StatusDetails - Gets or sets the status details of the job. + StatusDetails *string `json:"statusDetails,omitempty"` + // StartTime - Gets the start time of the job. + StartTime *date.Time `json:"startTime,omitempty"` + // EndTime - Gets the end time of the job. + EndTime *date.Time `json:"endTime,omitempty"` + // Exception - Gets the exception of the job. + Exception *string `json:"exception,omitempty"` + // LastModifiedTime - Gets the last modified time of the job. + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + // LastStatusModifiedTime - Gets the last status modified time of the job. + LastStatusModifiedTime *date.Time `json:"lastStatusModifiedTime,omitempty"` + // Parameters - Gets or sets the parameters of the job. + Parameters map[string]*string `json:"parameters"` +} + +// MarshalJSON is the custom marshaler for DscCompilationJobProperties. +func (dcjp DscCompilationJobProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dcjp.Configuration != nil { + objectMap["configuration"] = dcjp.Configuration + } + if dcjp.StartedBy != nil { + objectMap["startedBy"] = dcjp.StartedBy + } + if dcjp.JobID != nil { + objectMap["jobId"] = dcjp.JobID + } + if dcjp.CreationTime != nil { + objectMap["creationTime"] = dcjp.CreationTime + } + if dcjp.ProvisioningState != "" { + objectMap["provisioningState"] = dcjp.ProvisioningState + } + if dcjp.RunOn != nil { + objectMap["runOn"] = dcjp.RunOn + } + if dcjp.Status != "" { + objectMap["status"] = dcjp.Status + } + if dcjp.StatusDetails != nil { + objectMap["statusDetails"] = dcjp.StatusDetails + } + if dcjp.StartTime != nil { + objectMap["startTime"] = dcjp.StartTime + } + if dcjp.EndTime != nil { + objectMap["endTime"] = dcjp.EndTime + } + if dcjp.Exception != nil { + objectMap["exception"] = dcjp.Exception + } + if dcjp.LastModifiedTime != nil { + objectMap["lastModifiedTime"] = dcjp.LastModifiedTime + } + if dcjp.LastStatusModifiedTime != nil { + objectMap["lastStatusModifiedTime"] = dcjp.LastStatusModifiedTime + } + if dcjp.Parameters != nil { + objectMap["parameters"] = dcjp.Parameters + } + return json.Marshal(objectMap) +} + +// DscConfiguration definition of the configuration type. +type DscConfiguration struct { + autorest.Response `json:"-"` + // DscConfigurationProperties - Gets or sets the configuration properties. + *DscConfigurationProperties `json:"properties,omitempty"` + // Etag - Gets or sets the etag of the resource. + Etag *string `json:"etag,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The Azure Region where the resource lives + Location *string `json:"location,omitempty"` + // ID - Fully qualified resource Id for the resource + ID *string `json:"id,omitempty"` + // Name - The name of the resource + Name *string `json:"name,omitempty"` + // Type - The type of the resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for DscConfiguration. +func (dc DscConfiguration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dc.DscConfigurationProperties != nil { + objectMap["properties"] = dc.DscConfigurationProperties + } + if dc.Etag != nil { + objectMap["etag"] = dc.Etag + } + if dc.Tags != nil { + objectMap["tags"] = dc.Tags + } + if dc.Location != nil { + objectMap["location"] = dc.Location + } + if dc.ID != nil { + objectMap["id"] = dc.ID + } + if dc.Name != nil { + objectMap["name"] = dc.Name + } + if dc.Type != nil { + objectMap["type"] = dc.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DscConfiguration struct. +func (dc *DscConfiguration) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var dscConfigurationProperties DscConfigurationProperties + err = json.Unmarshal(*v, &dscConfigurationProperties) + if err != nil { + return err + } + dc.DscConfigurationProperties = &dscConfigurationProperties + } + case "etag": + if v != nil { + var etag string + err = json.Unmarshal(*v, &etag) + if err != nil { + return err + } + dc.Etag = &etag + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + dc.Tags = tags + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + dc.Location = &location + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + dc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + dc.Type = &typeVar + } + } + } + + return nil +} + +// DscConfigurationAssociationProperty the Dsc configuration property associated with the entity. +type DscConfigurationAssociationProperty struct { + // Name - Gets or sets the name of the Dsc configuration. + Name *string `json:"name,omitempty"` +} + +// DscConfigurationCreateOrUpdateParameters the parameters supplied to the create or update configuration +// operation. +type DscConfigurationCreateOrUpdateParameters struct { + // DscConfigurationCreateOrUpdateProperties - Gets or sets configuration create or update properties. + *DscConfigurationCreateOrUpdateProperties `json:"properties,omitempty"` + // Name - Gets or sets name of the resource. + Name *string `json:"name,omitempty"` + // Location - Gets or sets the location of the resource. + Location *string `json:"location,omitempty"` + // Tags - Gets or sets the tags attached to the resource. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for DscConfigurationCreateOrUpdateParameters. +func (dccoup DscConfigurationCreateOrUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dccoup.DscConfigurationCreateOrUpdateProperties != nil { + objectMap["properties"] = dccoup.DscConfigurationCreateOrUpdateProperties + } + if dccoup.Name != nil { + objectMap["name"] = dccoup.Name + } + if dccoup.Location != nil { + objectMap["location"] = dccoup.Location + } + if dccoup.Tags != nil { + objectMap["tags"] = dccoup.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DscConfigurationCreateOrUpdateParameters struct. +func (dccoup *DscConfigurationCreateOrUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var dscConfigurationCreateOrUpdateProperties DscConfigurationCreateOrUpdateProperties + err = json.Unmarshal(*v, &dscConfigurationCreateOrUpdateProperties) + if err != nil { + return err + } + dccoup.DscConfigurationCreateOrUpdateProperties = &dscConfigurationCreateOrUpdateProperties + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dccoup.Name = &name + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + dccoup.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + dccoup.Tags = tags + } + } + } + + return nil +} + +// DscConfigurationCreateOrUpdateProperties the properties to create or update configuration. +type DscConfigurationCreateOrUpdateProperties struct { + // LogVerbose - Gets or sets verbose log option. + LogVerbose *bool `json:"logVerbose,omitempty"` + // LogProgress - Gets or sets progress log option. + LogProgress *bool `json:"logProgress,omitempty"` + // Source - Gets or sets the source. + Source *ContentSource `json:"source,omitempty"` + // Parameters - Gets or sets the configuration parameters. + Parameters map[string]*DscConfigurationParameter `json:"parameters"` + // Description - Gets or sets the description of the configuration. + Description *string `json:"description,omitempty"` +} + +// MarshalJSON is the custom marshaler for DscConfigurationCreateOrUpdateProperties. +func (dccoup DscConfigurationCreateOrUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dccoup.LogVerbose != nil { + objectMap["logVerbose"] = dccoup.LogVerbose + } + if dccoup.LogProgress != nil { + objectMap["logProgress"] = dccoup.LogProgress + } + if dccoup.Source != nil { + objectMap["source"] = dccoup.Source + } + if dccoup.Parameters != nil { + objectMap["parameters"] = dccoup.Parameters + } + if dccoup.Description != nil { + objectMap["description"] = dccoup.Description + } + return json.Marshal(objectMap) +} + +// DscConfigurationListResult the response model for the list configuration operation. +type DscConfigurationListResult struct { + autorest.Response `json:"-"` + // Value - Gets or sets a list of configurations. + Value *[]DscConfiguration `json:"value,omitempty"` + // NextLink - Gets or sets the next link. + NextLink *string `json:"nextLink,omitempty"` + // TotalCount - Gets the total number of configurations matching filter criteria. + TotalCount *int32 `json:"totalCount,omitempty"` +} + +// DscConfigurationListResultIterator provides access to a complete listing of DscConfiguration values. +type DscConfigurationListResultIterator struct { + i int + page DscConfigurationListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *DscConfigurationListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter DscConfigurationListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter DscConfigurationListResultIterator) Response() DscConfigurationListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter DscConfigurationListResultIterator) Value() DscConfiguration { + if !iter.page.NotDone() { + return DscConfiguration{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (dclr DscConfigurationListResult) IsEmpty() bool { + return dclr.Value == nil || len(*dclr.Value) == 0 +} + +// dscConfigurationListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (dclr DscConfigurationListResult) dscConfigurationListResultPreparer() (*http.Request, error) { + if dclr.NextLink == nil || len(to.String(dclr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(dclr.NextLink))) +} + +// DscConfigurationListResultPage contains a page of DscConfiguration values. +type DscConfigurationListResultPage struct { + fn func(DscConfigurationListResult) (DscConfigurationListResult, error) + dclr DscConfigurationListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *DscConfigurationListResultPage) Next() error { + next, err := page.fn(page.dclr) + if err != nil { + return err + } + page.dclr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page DscConfigurationListResultPage) NotDone() bool { + return !page.dclr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page DscConfigurationListResultPage) Response() DscConfigurationListResult { + return page.dclr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page DscConfigurationListResultPage) Values() []DscConfiguration { + if page.dclr.IsEmpty() { + return nil + } + return *page.dclr.Value +} + +// DscConfigurationParameter definition of the configuration parameter type. +type DscConfigurationParameter struct { + // Type - Gets or sets the type of the parameter. + Type *string `json:"type,omitempty"` + // IsMandatory - Gets or sets a Boolean value to indicate whether the parameter is madatory or not. + IsMandatory *bool `json:"isMandatory,omitempty"` + // Position - Get or sets the position of the parameter. + Position *int32 `json:"position,omitempty"` + // DefaultValue - Gets or sets the default value of parameter. + DefaultValue *string `json:"defaultValue,omitempty"` +} + +// DscConfigurationProperties definition of the configuration property type. +type DscConfigurationProperties struct { + // ProvisioningState - Gets or sets the provisioning state of the configuration. Possible values include: 'Succeeded' + ProvisioningState DscConfigurationProvisioningState `json:"provisioningState,omitempty"` + // JobCount - Gets or sets the job count of the configuration. + JobCount *int32 `json:"jobCount,omitempty"` + // Parameters - Gets or sets the configuration parameters. + Parameters map[string]*DscConfigurationParameter `json:"parameters"` + // Source - Gets or sets the source. + Source *ContentSource `json:"source,omitempty"` + // State - Gets or sets the state of the configuration. Possible values include: 'DscConfigurationStateNew', 'DscConfigurationStateEdit', 'DscConfigurationStatePublished' + State DscConfigurationState `json:"state,omitempty"` + // LogVerbose - Gets or sets verbose log option. + LogVerbose *bool `json:"logVerbose,omitempty"` + // CreationTime - Gets or sets the creation time. + CreationTime *date.Time `json:"creationTime,omitempty"` + // LastModifiedTime - Gets or sets the last modified time. + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + // NodeConfigurationCount - Gets the number of compiled node configurations. + NodeConfigurationCount *int32 `json:"nodeConfigurationCount,omitempty"` + // Description - Gets or sets the description. + Description *string `json:"description,omitempty"` +} + +// MarshalJSON is the custom marshaler for DscConfigurationProperties. +func (dcp DscConfigurationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dcp.ProvisioningState != "" { + objectMap["provisioningState"] = dcp.ProvisioningState + } + if dcp.JobCount != nil { + objectMap["jobCount"] = dcp.JobCount + } + if dcp.Parameters != nil { + objectMap["parameters"] = dcp.Parameters + } + if dcp.Source != nil { + objectMap["source"] = dcp.Source + } + if dcp.State != "" { + objectMap["state"] = dcp.State + } + if dcp.LogVerbose != nil { + objectMap["logVerbose"] = dcp.LogVerbose + } + if dcp.CreationTime != nil { + objectMap["creationTime"] = dcp.CreationTime + } + if dcp.LastModifiedTime != nil { + objectMap["lastModifiedTime"] = dcp.LastModifiedTime + } + if dcp.NodeConfigurationCount != nil { + objectMap["nodeConfigurationCount"] = dcp.NodeConfigurationCount + } + if dcp.Description != nil { + objectMap["description"] = dcp.Description + } + return json.Marshal(objectMap) +} + +// DscConfigurationUpdateParameters the parameters supplied to the create or update configuration operation. +type DscConfigurationUpdateParameters struct { + // DscConfigurationCreateOrUpdateProperties - Gets or sets configuration create or update properties. + *DscConfigurationCreateOrUpdateProperties `json:"properties,omitempty"` + // Name - Gets or sets name of the resource. + Name *string `json:"name,omitempty"` + // Tags - Gets or sets the tags attached to the resource. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for DscConfigurationUpdateParameters. +func (dcup DscConfigurationUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dcup.DscConfigurationCreateOrUpdateProperties != nil { + objectMap["properties"] = dcup.DscConfigurationCreateOrUpdateProperties + } + if dcup.Name != nil { + objectMap["name"] = dcup.Name + } + if dcup.Tags != nil { + objectMap["tags"] = dcup.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DscConfigurationUpdateParameters struct. +func (dcup *DscConfigurationUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var dscConfigurationCreateOrUpdateProperties DscConfigurationCreateOrUpdateProperties + err = json.Unmarshal(*v, &dscConfigurationCreateOrUpdateProperties) + if err != nil { + return err + } + dcup.DscConfigurationCreateOrUpdateProperties = &dscConfigurationCreateOrUpdateProperties + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dcup.Name = &name + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + dcup.Tags = tags + } + } + } + + return nil +} + +// DscMetaConfiguration definition of the DSC Meta Configuration. +type DscMetaConfiguration struct { + // ConfigurationModeFrequencyMins - Gets or sets the ConfigurationModeFrequencyMins value of the meta configuration. + ConfigurationModeFrequencyMins *int32 `json:"configurationModeFrequencyMins,omitempty"` + // RebootNodeIfNeeded - Gets or sets the RebootNodeIfNeeded value of the meta configuration. + RebootNodeIfNeeded *bool `json:"rebootNodeIfNeeded,omitempty"` + // ConfigurationMode - Gets or sets the ConfigurationMode value of the meta configuration. + ConfigurationMode *string `json:"configurationMode,omitempty"` + // ActionAfterReboot - Gets or sets the ActionAfterReboot value of the meta configuration. + ActionAfterReboot *string `json:"actionAfterReboot,omitempty"` + // CertificateID - Gets or sets the CertificateId value of the meta configuration. + CertificateID *string `json:"certificateId,omitempty"` + // RefreshFrequencyMins - Gets or sets the RefreshFrequencyMins value of the meta configuration. + RefreshFrequencyMins *int32 `json:"refreshFrequencyMins,omitempty"` + // AllowModuleOverwrite - Gets or sets the AllowModuleOverwrite value of the meta configuration. + AllowModuleOverwrite *bool `json:"allowModuleOverwrite,omitempty"` +} + +// DscNode definition of a DscNode +type DscNode struct { + autorest.Response `json:"-"` + // DscNodeProperties - The properties of a DscNode. + *DscNodeProperties `json:"properties,omitempty"` + // ID - Fully qualified resource Id for the resource + ID *string `json:"id,omitempty"` + // Name - The name of the resource + Name *string `json:"name,omitempty"` + // Type - The type of the resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for DscNode. +func (dn DscNode) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dn.DscNodeProperties != nil { + objectMap["properties"] = dn.DscNodeProperties + } + if dn.ID != nil { + objectMap["id"] = dn.ID + } + if dn.Name != nil { + objectMap["name"] = dn.Name + } + if dn.Type != nil { + objectMap["type"] = dn.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DscNode struct. +func (dn *DscNode) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var dscNodeProperties DscNodeProperties + err = json.Unmarshal(*v, &dscNodeProperties) + if err != nil { + return err + } + dn.DscNodeProperties = &dscNodeProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + dn.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dn.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + dn.Type = &typeVar + } + } + } + + return nil +} + +// DscNodeConfiguration definition of the dsc node configuration. +type DscNodeConfiguration struct { + autorest.Response `json:"-"` + // DscNodeConfigurationProperties - Gets or sets the configuration properties. + *DscNodeConfigurationProperties `json:"properties,omitempty"` + // ID - Fully qualified resource Id for the resource + ID *string `json:"id,omitempty"` + // Name - The name of the resource + Name *string `json:"name,omitempty"` + // Type - The type of the resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for DscNodeConfiguration. +func (dnc DscNodeConfiguration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dnc.DscNodeConfigurationProperties != nil { + objectMap["properties"] = dnc.DscNodeConfigurationProperties + } + if dnc.ID != nil { + objectMap["id"] = dnc.ID + } + if dnc.Name != nil { + objectMap["name"] = dnc.Name + } + if dnc.Type != nil { + objectMap["type"] = dnc.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DscNodeConfiguration struct. +func (dnc *DscNodeConfiguration) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var dscNodeConfigurationProperties DscNodeConfigurationProperties + err = json.Unmarshal(*v, &dscNodeConfigurationProperties) + if err != nil { + return err + } + dnc.DscNodeConfigurationProperties = &dscNodeConfigurationProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + dnc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dnc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + dnc.Type = &typeVar + } + } + } + + return nil +} + +// DscNodeConfigurationAssociationProperty the dsc nodeconfiguration property associated with the entity. +type DscNodeConfigurationAssociationProperty struct { + // Name - Gets or sets the name of the dsc nodeconfiguration. + Name *string `json:"name,omitempty"` +} + +// DscNodeConfigurationCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type DscNodeConfigurationCreateOrUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *DscNodeConfigurationCreateOrUpdateFuture) Result(client DscNodeConfigurationClient) (dnc DscNodeConfiguration, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeConfigurationCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("automation.DscNodeConfigurationCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if dnc.Response.Response, err = future.GetResult(sender); err == nil && dnc.Response.Response.StatusCode != http.StatusNoContent { + dnc, err = client.CreateOrUpdateResponder(dnc.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeConfigurationCreateOrUpdateFuture", "Result", dnc.Response.Response, "Failure responding to request") + } + } + return +} + +// DscNodeConfigurationCreateOrUpdateParameters the parameters supplied to the create or update node configuration +// operation. +type DscNodeConfigurationCreateOrUpdateParameters struct { + // DscNodeConfigurationCreateOrUpdateParametersProperties - Node configuration properties + *DscNodeConfigurationCreateOrUpdateParametersProperties `json:"properties,omitempty"` + // Name - Name of the node configuration. + Name *string `json:"name,omitempty"` + // Tags - Gets or sets the tags attached to the resource. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for DscNodeConfigurationCreateOrUpdateParameters. +func (dnccoup DscNodeConfigurationCreateOrUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dnccoup.DscNodeConfigurationCreateOrUpdateParametersProperties != nil { + objectMap["properties"] = dnccoup.DscNodeConfigurationCreateOrUpdateParametersProperties + } + if dnccoup.Name != nil { + objectMap["name"] = dnccoup.Name + } + if dnccoup.Tags != nil { + objectMap["tags"] = dnccoup.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DscNodeConfigurationCreateOrUpdateParameters struct. +func (dnccoup *DscNodeConfigurationCreateOrUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var dscNodeConfigurationCreateOrUpdateParametersProperties DscNodeConfigurationCreateOrUpdateParametersProperties + err = json.Unmarshal(*v, &dscNodeConfigurationCreateOrUpdateParametersProperties) + if err != nil { + return err + } + dnccoup.DscNodeConfigurationCreateOrUpdateParametersProperties = &dscNodeConfigurationCreateOrUpdateParametersProperties + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dnccoup.Name = &name + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + dnccoup.Tags = tags + } + } + } + + return nil +} + +// DscNodeConfigurationCreateOrUpdateParametersProperties the parameter properties supplied to the create or update +// node configuration operation. +type DscNodeConfigurationCreateOrUpdateParametersProperties struct { + // Source - Gets or sets the source. + Source *ContentSource `json:"source,omitempty"` + // Configuration - Gets or sets the configuration of the node. + Configuration *DscConfigurationAssociationProperty `json:"configuration,omitempty"` + // IncrementNodeConfigurationBuild - If a new build version of NodeConfiguration is required. + IncrementNodeConfigurationBuild *bool `json:"incrementNodeConfigurationBuild,omitempty"` +} + +// DscNodeConfigurationListResult the response model for the list job operation. +type DscNodeConfigurationListResult struct { + autorest.Response `json:"-"` + // Value - Gets or sets a list of Dsc node configurations. + Value *[]DscNodeConfiguration `json:"value,omitempty"` + // NextLink - Gets or sets the next link. + NextLink *string `json:"nextLink,omitempty"` + // TotalCount - Gets or sets the total rows in query. + TotalCount *int32 `json:"totalCount,omitempty"` +} + +// DscNodeConfigurationListResultIterator provides access to a complete listing of DscNodeConfiguration values. +type DscNodeConfigurationListResultIterator struct { + i int + page DscNodeConfigurationListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *DscNodeConfigurationListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter DscNodeConfigurationListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter DscNodeConfigurationListResultIterator) Response() DscNodeConfigurationListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter DscNodeConfigurationListResultIterator) Value() DscNodeConfiguration { + if !iter.page.NotDone() { + return DscNodeConfiguration{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (dnclr DscNodeConfigurationListResult) IsEmpty() bool { + return dnclr.Value == nil || len(*dnclr.Value) == 0 +} + +// dscNodeConfigurationListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (dnclr DscNodeConfigurationListResult) dscNodeConfigurationListResultPreparer() (*http.Request, error) { + if dnclr.NextLink == nil || len(to.String(dnclr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(dnclr.NextLink))) +} + +// DscNodeConfigurationListResultPage contains a page of DscNodeConfiguration values. +type DscNodeConfigurationListResultPage struct { + fn func(DscNodeConfigurationListResult) (DscNodeConfigurationListResult, error) + dnclr DscNodeConfigurationListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *DscNodeConfigurationListResultPage) Next() error { + next, err := page.fn(page.dnclr) + if err != nil { + return err + } + page.dnclr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page DscNodeConfigurationListResultPage) NotDone() bool { + return !page.dnclr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page DscNodeConfigurationListResultPage) Response() DscNodeConfigurationListResult { + return page.dnclr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page DscNodeConfigurationListResultPage) Values() []DscNodeConfiguration { + if page.dnclr.IsEmpty() { + return nil + } + return *page.dnclr.Value +} + +// DscNodeConfigurationProperties properties for the DscNodeConfiguration +type DscNodeConfigurationProperties struct { + // LastModifiedTime - Gets or sets the last modified time. + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + // CreationTime - Gets or sets creation time. + CreationTime *date.Time `json:"creationTime,omitempty"` + // Configuration - Gets or sets the configuration of the node. + Configuration *DscConfigurationAssociationProperty `json:"configuration,omitempty"` + // Source - Source of node configuration. + Source *string `json:"source,omitempty"` + // NodeCount - Number of nodes with this nodeconfiguration assigned + NodeCount *int64 `json:"nodeCount,omitempty"` + // IncrementNodeConfigurationBuild - If a new build version of NodeConfiguration is required. + IncrementNodeConfigurationBuild *bool `json:"incrementNodeConfigurationBuild,omitempty"` +} + +// DscNodeExtensionHandlerAssociationProperty the dsc extensionHandler property associated with the node +type DscNodeExtensionHandlerAssociationProperty struct { + // Name - Gets or sets the name of the extension handler. + Name *string `json:"name,omitempty"` + // Version - Gets or sets the version of the extension handler. + Version *string `json:"version,omitempty"` +} + +// DscNodeListResult the response model for the list dsc nodes operation. +type DscNodeListResult struct { + autorest.Response `json:"-"` + // Value - Gets or sets a list of dsc nodes. + Value *[]DscNode `json:"value,omitempty"` + // NextLink - Gets or sets the next link. + NextLink *string `json:"nextLink,omitempty"` + // TotalCount - Gets the total number of nodes matching filter criteria. + TotalCount *int32 `json:"totalCount,omitempty"` +} + +// DscNodeListResultIterator provides access to a complete listing of DscNode values. +type DscNodeListResultIterator struct { + i int + page DscNodeListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *DscNodeListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter DscNodeListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter DscNodeListResultIterator) Response() DscNodeListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter DscNodeListResultIterator) Value() DscNode { + if !iter.page.NotDone() { + return DscNode{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (dnlr DscNodeListResult) IsEmpty() bool { + return dnlr.Value == nil || len(*dnlr.Value) == 0 +} + +// dscNodeListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (dnlr DscNodeListResult) dscNodeListResultPreparer() (*http.Request, error) { + if dnlr.NextLink == nil || len(to.String(dnlr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(dnlr.NextLink))) +} + +// DscNodeListResultPage contains a page of DscNode values. +type DscNodeListResultPage struct { + fn func(DscNodeListResult) (DscNodeListResult, error) + dnlr DscNodeListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *DscNodeListResultPage) Next() error { + next, err := page.fn(page.dnlr) + if err != nil { + return err + } + page.dnlr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page DscNodeListResultPage) NotDone() bool { + return !page.dnlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page DscNodeListResultPage) Response() DscNodeListResult { + return page.dnlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page DscNodeListResultPage) Values() []DscNode { + if page.dnlr.IsEmpty() { + return nil + } + return *page.dnlr.Value +} + +// DscNodeProperties the properties of a DscNode +type DscNodeProperties struct { + // LastSeen - Gets or sets the last seen time of the node. + LastSeen *date.Time `json:"lastSeen,omitempty"` + // RegistrationTime - Gets or sets the registration time of the node. + RegistrationTime *date.Time `json:"registrationTime,omitempty"` + // IP - Gets or sets the ip of the node. + IP *string `json:"ip,omitempty"` + // AccountID - Gets or sets the account id of the node. + AccountID *string `json:"accountId,omitempty"` + // DscNodeConfigurationAssociationProperty - Gets or sets the configuration of the node. + *DscNodeConfigurationAssociationProperty `json:"nodeConfiguration,omitempty"` + // Status - Gets or sets the status of the node. + Status *string `json:"status,omitempty"` + // NodeID - Gets or sets the node id. + NodeID *string `json:"nodeId,omitempty"` + // Etag - Gets or sets the etag of the resource. + Etag *string `json:"etag,omitempty"` + // TotalCount - Gets the total number of records matching filter criteria. + TotalCount *int32 `json:"totalCount,omitempty"` + // ExtensionHandler - Gets or sets the list of extensionHandler properties for a Node. + ExtensionHandler *[]DscNodeExtensionHandlerAssociationProperty `json:"extensionHandler,omitempty"` +} + +// MarshalJSON is the custom marshaler for DscNodeProperties. +func (dnp DscNodeProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dnp.LastSeen != nil { + objectMap["lastSeen"] = dnp.LastSeen + } + if dnp.RegistrationTime != nil { + objectMap["registrationTime"] = dnp.RegistrationTime + } + if dnp.IP != nil { + objectMap["ip"] = dnp.IP + } + if dnp.AccountID != nil { + objectMap["accountId"] = dnp.AccountID + } + if dnp.DscNodeConfigurationAssociationProperty != nil { + objectMap["nodeConfiguration"] = dnp.DscNodeConfigurationAssociationProperty + } + if dnp.Status != nil { + objectMap["status"] = dnp.Status + } + if dnp.NodeID != nil { + objectMap["nodeId"] = dnp.NodeID + } + if dnp.Etag != nil { + objectMap["etag"] = dnp.Etag + } + if dnp.TotalCount != nil { + objectMap["totalCount"] = dnp.TotalCount + } + if dnp.ExtensionHandler != nil { + objectMap["extensionHandler"] = dnp.ExtensionHandler + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DscNodeProperties struct. +func (dnp *DscNodeProperties) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "lastSeen": + if v != nil { + var lastSeen date.Time + err = json.Unmarshal(*v, &lastSeen) + if err != nil { + return err + } + dnp.LastSeen = &lastSeen + } + case "registrationTime": + if v != nil { + var registrationTime date.Time + err = json.Unmarshal(*v, ®istrationTime) + if err != nil { + return err + } + dnp.RegistrationTime = ®istrationTime + } + case "ip": + if v != nil { + var IP string + err = json.Unmarshal(*v, &IP) + if err != nil { + return err + } + dnp.IP = &IP + } + case "accountId": + if v != nil { + var accountID string + err = json.Unmarshal(*v, &accountID) + if err != nil { + return err + } + dnp.AccountID = &accountID + } + case "nodeConfiguration": + if v != nil { + var dscNodeConfigurationAssociationProperty DscNodeConfigurationAssociationProperty + err = json.Unmarshal(*v, &dscNodeConfigurationAssociationProperty) + if err != nil { + return err + } + dnp.DscNodeConfigurationAssociationProperty = &dscNodeConfigurationAssociationProperty + } + case "status": + if v != nil { + var status string + err = json.Unmarshal(*v, &status) + if err != nil { + return err + } + dnp.Status = &status + } + case "nodeId": + if v != nil { + var nodeID string + err = json.Unmarshal(*v, &nodeID) + if err != nil { + return err + } + dnp.NodeID = &nodeID + } + case "etag": + if v != nil { + var etag string + err = json.Unmarshal(*v, &etag) + if err != nil { + return err + } + dnp.Etag = &etag + } + case "totalCount": + if v != nil { + var totalCount int32 + err = json.Unmarshal(*v, &totalCount) + if err != nil { + return err + } + dnp.TotalCount = &totalCount + } + case "extensionHandler": + if v != nil { + var extensionHandler []DscNodeExtensionHandlerAssociationProperty + err = json.Unmarshal(*v, &extensionHandler) + if err != nil { + return err + } + dnp.ExtensionHandler = &extensionHandler + } + } + } + + return nil +} + +// DscNodeReport definition of the dsc node report type. +type DscNodeReport struct { + autorest.Response `json:"-"` + // EndTime - Gets or sets the end time of the node report. + EndTime *date.Time `json:"endTime,omitempty"` + // LastModifiedTime - Gets or sets the lastModifiedTime of the node report. + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + // StartTime - Gets or sets the start time of the node report. + StartTime *date.Time `json:"startTime,omitempty"` + // Type - Gets or sets the type of the node report. + Type *string `json:"type,omitempty"` + // ReportID - Gets or sets the id of the node report. + ReportID *string `json:"reportId,omitempty"` + // Status - Gets or sets the status of the node report. + Status *string `json:"status,omitempty"` + // RefreshMode - Gets or sets the refreshMode of the node report. + RefreshMode *string `json:"refreshMode,omitempty"` + // RebootRequested - Gets or sets the rebootRequested of the node report. + RebootRequested *string `json:"rebootRequested,omitempty"` + // ReportFormatVersion - Gets or sets the reportFormatVersion of the node report. + ReportFormatVersion *string `json:"reportFormatVersion,omitempty"` + // ConfigurationVersion - Gets or sets the configurationVersion of the node report. + ConfigurationVersion *string `json:"configurationVersion,omitempty"` + // ID - Gets or sets the id. + ID *string `json:"id,omitempty"` + // Errors - Gets or sets the errors for the node report. + Errors *[]DscReportError `json:"errors,omitempty"` + // Resources - Gets or sets the resource for the node report. + Resources *[]DscReportResource `json:"resources,omitempty"` + // MetaConfiguration - Gets or sets the metaConfiguration of the node at the time of the report. + MetaConfiguration *DscMetaConfiguration `json:"metaConfiguration,omitempty"` + // HostName - Gets or sets the hostname of the node that sent the report. + HostName *string `json:"hostName,omitempty"` + // IPV4Addresses - Gets or sets the IPv4 address of the node that sent the report. + IPV4Addresses *[]string `json:"iPV4Addresses,omitempty"` + // IPV6Addresses - Gets or sets the IPv6 address of the node that sent the report. + IPV6Addresses *[]string `json:"iPV6Addresses,omitempty"` + // NumberOfResources - Gets or sets the number of resource in the node report. + NumberOfResources *int32 `json:"numberOfResources,omitempty"` + // RawErrors - Gets or sets the unparsed errors for the node report. + RawErrors *string `json:"rawErrors,omitempty"` +} + +// DscNodeReportListResult the response model for the list dsc nodes operation. +type DscNodeReportListResult struct { + autorest.Response `json:"-"` + // Value - Gets or sets a list of dsc node reports. + Value *[]DscNodeReport `json:"value,omitempty"` + // NextLink - Gets or sets the next link. + NextLink *string `json:"nextLink,omitempty"` +} + +// DscNodeReportListResultIterator provides access to a complete listing of DscNodeReport values. +type DscNodeReportListResultIterator struct { + i int + page DscNodeReportListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *DscNodeReportListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter DscNodeReportListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter DscNodeReportListResultIterator) Response() DscNodeReportListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter DscNodeReportListResultIterator) Value() DscNodeReport { + if !iter.page.NotDone() { + return DscNodeReport{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (dnrlr DscNodeReportListResult) IsEmpty() bool { + return dnrlr.Value == nil || len(*dnrlr.Value) == 0 +} + +// dscNodeReportListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (dnrlr DscNodeReportListResult) dscNodeReportListResultPreparer() (*http.Request, error) { + if dnrlr.NextLink == nil || len(to.String(dnrlr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(dnrlr.NextLink))) +} + +// DscNodeReportListResultPage contains a page of DscNodeReport values. +type DscNodeReportListResultPage struct { + fn func(DscNodeReportListResult) (DscNodeReportListResult, error) + dnrlr DscNodeReportListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *DscNodeReportListResultPage) Next() error { + next, err := page.fn(page.dnrlr) + if err != nil { + return err + } + page.dnrlr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page DscNodeReportListResultPage) NotDone() bool { + return !page.dnrlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page DscNodeReportListResultPage) Response() DscNodeReportListResult { + return page.dnrlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page DscNodeReportListResultPage) Values() []DscNodeReport { + if page.dnrlr.IsEmpty() { + return nil + } + return *page.dnrlr.Value +} + +// DscNodeUpdateParameters the parameters supplied to the update dsc node operation. +type DscNodeUpdateParameters struct { + // NodeID - Gets or sets the id of the dsc node. + NodeID *string `json:"nodeId,omitempty"` + Properties *DscNodeUpdateParametersProperties `json:"properties,omitempty"` +} + +// DscNodeUpdateParametersProperties ... +type DscNodeUpdateParametersProperties struct { + // DscNodeConfigurationAssociationProperty - Gets or sets the configuration of the node. + *DscNodeConfigurationAssociationProperty `json:"nodeConfiguration,omitempty"` +} + +// MarshalJSON is the custom marshaler for DscNodeUpdateParametersProperties. +func (dnup DscNodeUpdateParametersProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dnup.DscNodeConfigurationAssociationProperty != nil { + objectMap["nodeConfiguration"] = dnup.DscNodeConfigurationAssociationProperty + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DscNodeUpdateParametersProperties struct. +func (dnup *DscNodeUpdateParametersProperties) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "nodeConfiguration": + if v != nil { + var dscNodeConfigurationAssociationProperty DscNodeConfigurationAssociationProperty + err = json.Unmarshal(*v, &dscNodeConfigurationAssociationProperty) + if err != nil { + return err + } + dnup.DscNodeConfigurationAssociationProperty = &dscNodeConfigurationAssociationProperty + } + } + } + + return nil +} + +// DscReportError definition of the dsc node report error type. +type DscReportError struct { + // ErrorSource - Gets or sets the source of the error. + ErrorSource *string `json:"errorSource,omitempty"` + // ResourceID - Gets or sets the resource ID which generated the error. + ResourceID *string `json:"resourceId,omitempty"` + // ErrorCode - Gets or sets the error code. + ErrorCode *string `json:"errorCode,omitempty"` + // ErrorMessage - Gets or sets the error message. + ErrorMessage *string `json:"errorMessage,omitempty"` + // Locale - Gets or sets the locale of the error. + Locale *string `json:"locale,omitempty"` + // ErrorDetails - Gets or sets the error details. + ErrorDetails *string `json:"errorDetails,omitempty"` +} + +// DscReportResource definition of the DSC Report Resource. +type DscReportResource struct { + // ResourceID - Gets or sets the ID of the resource. + ResourceID *string `json:"resourceId,omitempty"` + // SourceInfo - Gets or sets the source info of the resource. + SourceInfo *string `json:"sourceInfo,omitempty"` + // DependsOn - Gets or sets the Resource Navigation values for resources the resource depends on. + DependsOn *[]DscReportResourceNavigation `json:"dependsOn,omitempty"` + // ModuleName - Gets or sets the module name of the resource. + ModuleName *string `json:"moduleName,omitempty"` + // ModuleVersion - Gets or sets the module version of the resource. + ModuleVersion *string `json:"moduleVersion,omitempty"` + // ResourceName - Gets or sets the name of the resource. + ResourceName *string `json:"resourceName,omitempty"` + // Error - Gets or sets the error of the resource. + Error *string `json:"error,omitempty"` + // Status - Gets or sets the status of the resource. + Status *string `json:"status,omitempty"` + // DurationInSeconds - Gets or sets the duration in seconds for the resource. + DurationInSeconds *float64 `json:"durationInSeconds,omitempty"` + // StartDate - Gets or sets the start date of the resource. + StartDate *date.Time `json:"startDate,omitempty"` +} + +// DscReportResourceNavigation navigation for DSC Report Resource. +type DscReportResourceNavigation struct { + // ResourceID - Gets or sets the ID of the resource to navigate to. + ResourceID *string `json:"resourceId,omitempty"` +} + +// ErrorResponse error response of an operation failure +type ErrorResponse struct { + // Code - Error code + Code *string `json:"code,omitempty"` + // Message - Error message indicating why the operation failed. + Message *string `json:"message,omitempty"` +} + +// FieldDefinition definition of the connection fields. +type FieldDefinition struct { + // IsEncrypted - Gets or sets the isEncrypted flag of the connection field definition. + IsEncrypted *bool `json:"isEncrypted,omitempty"` + // IsOptional - Gets or sets the isOptional flag of the connection field definition. + IsOptional *bool `json:"isOptional,omitempty"` + // Type - Gets or sets the type of the connection field definition. + Type *string `json:"type,omitempty"` +} + +// HybridRunbookWorker definition of hybrid runbook worker. +type HybridRunbookWorker struct { + // Name - Gets or sets the worker machine name. + Name *string `json:"name,omitempty"` + // IP - Gets or sets the assigned machine IP address. + IP *string `json:"ip,omitempty"` + // RegistrationTime - Gets or sets the registration time of the worker machine. + RegistrationTime *date.Time `json:"registrationTime,omitempty"` + // LastSeenDateTime - Last Heartbeat from the Worker + LastSeenDateTime *date.Time `json:"lastSeenDateTime,omitempty"` +} + +// HybridRunbookWorkerGroup definition of hybrid runbook worker group. +type HybridRunbookWorkerGroup struct { + autorest.Response `json:"-"` + // ID - Gets or sets the id of the resource. + ID *string `json:"id,omitempty"` + // Name - Gets or sets the name of the group. + Name *string `json:"name,omitempty"` + // HybridRunbookWorkers - Gets or sets the list of hybrid runbook workers. + HybridRunbookWorkers *[]HybridRunbookWorker `json:"hybridRunbookWorkers,omitempty"` + // Credential - Sets the credential of a worker group. + Credential *RunAsCredentialAssociationProperty `json:"credential,omitempty"` + // GroupType - Type of the HybridWorkerGroup. Possible values include: 'User', 'System' + GroupType GroupTypeEnum `json:"groupType,omitempty"` +} + +// HybridRunbookWorkerGroupsListResult the response model for the list hybrid runbook worker groups. +type HybridRunbookWorkerGroupsListResult struct { + autorest.Response `json:"-"` + // Value - Gets or sets a list of hybrid runbook worker groups. + Value *[]HybridRunbookWorkerGroup `json:"value,omitempty"` + // NextLink - Gets or sets the next link. + NextLink *string `json:"nextLink,omitempty"` +} + +// HybridRunbookWorkerGroupsListResultIterator provides access to a complete listing of HybridRunbookWorkerGroup +// values. +type HybridRunbookWorkerGroupsListResultIterator struct { + i int + page HybridRunbookWorkerGroupsListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *HybridRunbookWorkerGroupsListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter HybridRunbookWorkerGroupsListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter HybridRunbookWorkerGroupsListResultIterator) Response() HybridRunbookWorkerGroupsListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter HybridRunbookWorkerGroupsListResultIterator) Value() HybridRunbookWorkerGroup { + if !iter.page.NotDone() { + return HybridRunbookWorkerGroup{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (hrwglr HybridRunbookWorkerGroupsListResult) IsEmpty() bool { + return hrwglr.Value == nil || len(*hrwglr.Value) == 0 +} + +// hybridRunbookWorkerGroupsListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (hrwglr HybridRunbookWorkerGroupsListResult) hybridRunbookWorkerGroupsListResultPreparer() (*http.Request, error) { + if hrwglr.NextLink == nil || len(to.String(hrwglr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(hrwglr.NextLink))) +} + +// HybridRunbookWorkerGroupsListResultPage contains a page of HybridRunbookWorkerGroup values. +type HybridRunbookWorkerGroupsListResultPage struct { + fn func(HybridRunbookWorkerGroupsListResult) (HybridRunbookWorkerGroupsListResult, error) + hrwglr HybridRunbookWorkerGroupsListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *HybridRunbookWorkerGroupsListResultPage) Next() error { + next, err := page.fn(page.hrwglr) + if err != nil { + return err + } + page.hrwglr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page HybridRunbookWorkerGroupsListResultPage) NotDone() bool { + return !page.hrwglr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page HybridRunbookWorkerGroupsListResultPage) Response() HybridRunbookWorkerGroupsListResult { + return page.hrwglr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page HybridRunbookWorkerGroupsListResultPage) Values() []HybridRunbookWorkerGroup { + if page.hrwglr.IsEmpty() { + return nil + } + return *page.hrwglr.Value +} + +// HybridRunbookWorkerGroupUpdateParameters parameters supplied to the update operation. +type HybridRunbookWorkerGroupUpdateParameters struct { + // Credential - Sets the credential of a worker group. + Credential *RunAsCredentialAssociationProperty `json:"credential,omitempty"` +} + +// Job definition of the job. +type Job struct { + autorest.Response `json:"-"` + // JobProperties - The properties of the job. + *JobProperties `json:"properties,omitempty"` + // ID - Fully qualified resource Id for the resource + ID *string `json:"id,omitempty"` + // Name - The name of the resource + Name *string `json:"name,omitempty"` + // Type - The type of the resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Job. +func (j Job) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if j.JobProperties != nil { + objectMap["properties"] = j.JobProperties + } + if j.ID != nil { + objectMap["id"] = j.ID + } + if j.Name != nil { + objectMap["name"] = j.Name + } + if j.Type != nil { + objectMap["type"] = j.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Job struct. +func (j *Job) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var jobProperties JobProperties + err = json.Unmarshal(*v, &jobProperties) + if err != nil { + return err + } + j.JobProperties = &jobProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + j.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + j.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + j.Type = &typeVar + } + } + } + + return nil +} + +// JobCollectionItem job collection item properties. +type JobCollectionItem struct { + // JobCollectionItemProperties - Job properties. + *JobCollectionItemProperties `json:"properties,omitempty"` + // ID - Fully qualified resource Id for the resource + ID *string `json:"id,omitempty"` + // Name - The name of the resource + Name *string `json:"name,omitempty"` + // Type - The type of the resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for JobCollectionItem. +func (jci JobCollectionItem) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if jci.JobCollectionItemProperties != nil { + objectMap["properties"] = jci.JobCollectionItemProperties + } + if jci.ID != nil { + objectMap["id"] = jci.ID + } + if jci.Name != nil { + objectMap["name"] = jci.Name + } + if jci.Type != nil { + objectMap["type"] = jci.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for JobCollectionItem struct. +func (jci *JobCollectionItem) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var jobCollectionItemProperties JobCollectionItemProperties + err = json.Unmarshal(*v, &jobCollectionItemProperties) + if err != nil { + return err + } + jci.JobCollectionItemProperties = &jobCollectionItemProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + jci.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + jci.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + jci.Type = &typeVar + } + } + } + + return nil +} + +// JobCollectionItemProperties job collection item properties. +type JobCollectionItemProperties struct { + // Runbook - The runbook association. + Runbook *RunbookAssociationProperty `json:"runbook,omitempty"` + // JobID - The id of the job. + JobID *uuid.UUID `json:"jobId,omitempty"` + // CreationTime - The creation time of the job. + CreationTime *date.Time `json:"creationTime,omitempty"` + // Status - The status of the job. Possible values include: 'JobStatusNew', 'JobStatusActivating', 'JobStatusRunning', 'JobStatusCompleted', 'JobStatusFailed', 'JobStatusStopped', 'JobStatusBlocked', 'JobStatusSuspended', 'JobStatusDisconnected', 'JobStatusSuspending', 'JobStatusStopping', 'JobStatusResuming', 'JobStatusRemoving' + Status JobStatus `json:"status,omitempty"` + // StartTime - The start time of the job. + StartTime *date.Time `json:"startTime,omitempty"` + // EndTime - The end time of the job. + EndTime *date.Time `json:"endTime,omitempty"` + // LastModifiedTime - The last modified time of the job. + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + // ProvisioningState - The provisioning state of a resource. + ProvisioningState *string `json:"provisioningState,omitempty"` + // RunOn - Specifies the runOn group name where the job was executed. + RunOn *string `json:"runOn,omitempty"` +} + +// JobCreateParameters the parameters supplied to the create job operation. +type JobCreateParameters struct { + // JobCreateProperties - Gets or sets the list of job properties. + *JobCreateProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for JobCreateParameters. +func (jcp JobCreateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if jcp.JobCreateProperties != nil { + objectMap["properties"] = jcp.JobCreateProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for JobCreateParameters struct. +func (jcp *JobCreateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var jobCreateProperties JobCreateProperties + err = json.Unmarshal(*v, &jobCreateProperties) + if err != nil { + return err + } + jcp.JobCreateProperties = &jobCreateProperties + } + } + } + + return nil +} + +// JobCreateProperties ... +type JobCreateProperties struct { + // Runbook - Gets or sets the runbook. + Runbook *RunbookAssociationProperty `json:"runbook,omitempty"` + // Parameters - Gets or sets the parameters of the job. + Parameters map[string]*string `json:"parameters"` + // RunOn - Gets or sets the runOn which specifies the group name where the job is to be executed. + RunOn *string `json:"runOn,omitempty"` +} + +// MarshalJSON is the custom marshaler for JobCreateProperties. +func (jcp JobCreateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if jcp.Runbook != nil { + objectMap["runbook"] = jcp.Runbook + } + if jcp.Parameters != nil { + objectMap["parameters"] = jcp.Parameters + } + if jcp.RunOn != nil { + objectMap["runOn"] = jcp.RunOn + } + return json.Marshal(objectMap) +} + +// JobListResultV2 the response model for the list job operation. +type JobListResultV2 struct { + autorest.Response `json:"-"` + // Value - List of jobs. + Value *[]JobCollectionItem `json:"value,omitempty"` + // NextLink - The link to the next page. + NextLink *string `json:"nextLink,omitempty"` +} + +// JobListResultV2Iterator provides access to a complete listing of JobCollectionItem values. +type JobListResultV2Iterator struct { + i int + page JobListResultV2Page +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *JobListResultV2Iterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter JobListResultV2Iterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter JobListResultV2Iterator) Response() JobListResultV2 { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter JobListResultV2Iterator) Value() JobCollectionItem { + if !iter.page.NotDone() { + return JobCollectionItem{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (jlrv JobListResultV2) IsEmpty() bool { + return jlrv.Value == nil || len(*jlrv.Value) == 0 +} + +// jobListResultV2Preparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (jlrv JobListResultV2) jobListResultV2Preparer() (*http.Request, error) { + if jlrv.NextLink == nil || len(to.String(jlrv.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(jlrv.NextLink))) +} + +// JobListResultV2Page contains a page of JobCollectionItem values. +type JobListResultV2Page struct { + fn func(JobListResultV2) (JobListResultV2, error) + jlrv JobListResultV2 +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *JobListResultV2Page) Next() error { + next, err := page.fn(page.jlrv) + if err != nil { + return err + } + page.jlrv = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page JobListResultV2Page) NotDone() bool { + return !page.jlrv.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page JobListResultV2Page) Response() JobListResultV2 { + return page.jlrv +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page JobListResultV2Page) Values() []JobCollectionItem { + if page.jlrv.IsEmpty() { + return nil + } + return *page.jlrv.Value +} + +// JobNavigation software update configuration machine run job navigation properties. +type JobNavigation struct { + // ID - Id of the job associated with the software update configuration run + ID *string `json:"id,omitempty"` +} + +// JobProperties definition of job properties. +type JobProperties struct { + // Runbook - Gets or sets the runbook. + Runbook *RunbookAssociationProperty `json:"runbook,omitempty"` + // StartedBy - Gets or sets the job started by. + StartedBy *string `json:"startedBy,omitempty"` + // RunOn - Gets or sets the runOn which specifies the group name where the job is to be executed. + RunOn *string `json:"runOn,omitempty"` + // JobID - Gets or sets the id of the job. + JobID *uuid.UUID `json:"jobId,omitempty"` + // CreationTime - Gets or sets the creation time of the job. + CreationTime *date.Time `json:"creationTime,omitempty"` + // Status - Gets or sets the status of the job. Possible values include: 'JobStatusNew', 'JobStatusActivating', 'JobStatusRunning', 'JobStatusCompleted', 'JobStatusFailed', 'JobStatusStopped', 'JobStatusBlocked', 'JobStatusSuspended', 'JobStatusDisconnected', 'JobStatusSuspending', 'JobStatusStopping', 'JobStatusResuming', 'JobStatusRemoving' + Status JobStatus `json:"status,omitempty"` + // StatusDetails - Gets or sets the status details of the job. + StatusDetails *string `json:"statusDetails,omitempty"` + // StartTime - Gets or sets the start time of the job. + StartTime *date.Time `json:"startTime,omitempty"` + // EndTime - Gets or sets the end time of the job. + EndTime *date.Time `json:"endTime,omitempty"` + // Exception - Gets or sets the exception of the job. + Exception *string `json:"exception,omitempty"` + // LastModifiedTime - Gets or sets the last modified time of the job. + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + // LastStatusModifiedTime - Gets or sets the last status modified time of the job. + LastStatusModifiedTime *date.Time `json:"lastStatusModifiedTime,omitempty"` + // Parameters - Gets or sets the parameters of the job. + Parameters map[string]*string `json:"parameters"` + // ProvisioningState - The current provisioning state of the job. Possible values include: 'JobProvisioningStateFailed', 'JobProvisioningStateSucceeded', 'JobProvisioningStateSuspended', 'JobProvisioningStateProcessing' + ProvisioningState JobProvisioningState `json:"provisioningState,omitempty"` +} + +// MarshalJSON is the custom marshaler for JobProperties. +func (jp JobProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if jp.Runbook != nil { + objectMap["runbook"] = jp.Runbook + } + if jp.StartedBy != nil { + objectMap["startedBy"] = jp.StartedBy + } + if jp.RunOn != nil { + objectMap["runOn"] = jp.RunOn + } + if jp.JobID != nil { + objectMap["jobId"] = jp.JobID + } + if jp.CreationTime != nil { + objectMap["creationTime"] = jp.CreationTime + } + if jp.Status != "" { + objectMap["status"] = jp.Status + } + if jp.StatusDetails != nil { + objectMap["statusDetails"] = jp.StatusDetails + } + if jp.StartTime != nil { + objectMap["startTime"] = jp.StartTime + } + if jp.EndTime != nil { + objectMap["endTime"] = jp.EndTime + } + if jp.Exception != nil { + objectMap["exception"] = jp.Exception + } + if jp.LastModifiedTime != nil { + objectMap["lastModifiedTime"] = jp.LastModifiedTime + } + if jp.LastStatusModifiedTime != nil { + objectMap["lastStatusModifiedTime"] = jp.LastStatusModifiedTime + } + if jp.Parameters != nil { + objectMap["parameters"] = jp.Parameters + } + if jp.ProvisioningState != "" { + objectMap["provisioningState"] = jp.ProvisioningState + } + return json.Marshal(objectMap) +} + +// JobSchedule definition of the job schedule. +type JobSchedule struct { + autorest.Response `json:"-"` + // ID - Gets the id of the resource. + ID *string `json:"id,omitempty"` + // Name - Gets the name of the variable. + Name *string `json:"name,omitempty"` + // Type - Resource type + Type *string `json:"type,omitempty"` + // JobScheduleProperties - Gets or sets the properties of the job schedule. + *JobScheduleProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for JobSchedule. +func (js JobSchedule) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if js.ID != nil { + objectMap["id"] = js.ID + } + if js.Name != nil { + objectMap["name"] = js.Name + } + if js.Type != nil { + objectMap["type"] = js.Type + } + if js.JobScheduleProperties != nil { + objectMap["properties"] = js.JobScheduleProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for JobSchedule struct. +func (js *JobSchedule) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + js.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + js.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + js.Type = &typeVar + } + case "properties": + if v != nil { + var jobScheduleProperties JobScheduleProperties + err = json.Unmarshal(*v, &jobScheduleProperties) + if err != nil { + return err + } + js.JobScheduleProperties = &jobScheduleProperties + } + } + } + + return nil +} + +// JobScheduleCreateParameters the parameters supplied to the create job schedule operation. +type JobScheduleCreateParameters struct { + // JobScheduleCreateProperties - Gets or sets the list of job schedule properties. + *JobScheduleCreateProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for JobScheduleCreateParameters. +func (jscp JobScheduleCreateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if jscp.JobScheduleCreateProperties != nil { + objectMap["properties"] = jscp.JobScheduleCreateProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for JobScheduleCreateParameters struct. +func (jscp *JobScheduleCreateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var jobScheduleCreateProperties JobScheduleCreateProperties + err = json.Unmarshal(*v, &jobScheduleCreateProperties) + if err != nil { + return err + } + jscp.JobScheduleCreateProperties = &jobScheduleCreateProperties + } + } + } + + return nil +} + +// JobScheduleCreateProperties the parameters supplied to the create job schedule operation. +type JobScheduleCreateProperties struct { + // Schedule - Gets or sets the schedule. + Schedule *ScheduleAssociationProperty `json:"schedule,omitempty"` + // Runbook - Gets or sets the runbook. + Runbook *RunbookAssociationProperty `json:"runbook,omitempty"` + // RunOn - Gets or sets the hybrid worker group that the scheduled job should run on. + RunOn *string `json:"runOn,omitempty"` + // Parameters - Gets or sets a list of job properties. + Parameters map[string]*string `json:"parameters"` +} + +// MarshalJSON is the custom marshaler for JobScheduleCreateProperties. +func (jscp JobScheduleCreateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if jscp.Schedule != nil { + objectMap["schedule"] = jscp.Schedule + } + if jscp.Runbook != nil { + objectMap["runbook"] = jscp.Runbook + } + if jscp.RunOn != nil { + objectMap["runOn"] = jscp.RunOn + } + if jscp.Parameters != nil { + objectMap["parameters"] = jscp.Parameters + } + return json.Marshal(objectMap) +} + +// JobScheduleListResult the response model for the list job schedule operation. +type JobScheduleListResult struct { + autorest.Response `json:"-"` + // Value - Gets or sets a list of job schedules. + Value *[]JobSchedule `json:"value,omitempty"` + // NextLink - Gets or sets the next link. + NextLink *string `json:"nextLink,omitempty"` +} + +// JobScheduleListResultIterator provides access to a complete listing of JobSchedule values. +type JobScheduleListResultIterator struct { + i int + page JobScheduleListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *JobScheduleListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter JobScheduleListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter JobScheduleListResultIterator) Response() JobScheduleListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter JobScheduleListResultIterator) Value() JobSchedule { + if !iter.page.NotDone() { + return JobSchedule{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (jslr JobScheduleListResult) IsEmpty() bool { + return jslr.Value == nil || len(*jslr.Value) == 0 +} + +// jobScheduleListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (jslr JobScheduleListResult) jobScheduleListResultPreparer() (*http.Request, error) { + if jslr.NextLink == nil || len(to.String(jslr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(jslr.NextLink))) +} + +// JobScheduleListResultPage contains a page of JobSchedule values. +type JobScheduleListResultPage struct { + fn func(JobScheduleListResult) (JobScheduleListResult, error) + jslr JobScheduleListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *JobScheduleListResultPage) Next() error { + next, err := page.fn(page.jslr) + if err != nil { + return err + } + page.jslr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page JobScheduleListResultPage) NotDone() bool { + return !page.jslr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page JobScheduleListResultPage) Response() JobScheduleListResult { + return page.jslr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page JobScheduleListResultPage) Values() []JobSchedule { + if page.jslr.IsEmpty() { + return nil + } + return *page.jslr.Value +} + +// JobScheduleProperties definition of job schedule parameters. +type JobScheduleProperties struct { + // JobScheduleID - Gets or sets the id of job schedule. + JobScheduleID *string `json:"jobScheduleId,omitempty"` + // Schedule - Gets or sets the schedule. + Schedule *ScheduleAssociationProperty `json:"schedule,omitempty"` + // Runbook - Gets or sets the runbook. + Runbook *RunbookAssociationProperty `json:"runbook,omitempty"` + // RunOn - Gets or sets the hybrid worker group that the scheduled job should run on. + RunOn *string `json:"runOn,omitempty"` + // Parameters - Gets or sets the parameters of the job schedule. + Parameters map[string]*string `json:"parameters"` +} + +// MarshalJSON is the custom marshaler for JobScheduleProperties. +func (jsp JobScheduleProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if jsp.JobScheduleID != nil { + objectMap["jobScheduleId"] = jsp.JobScheduleID + } + if jsp.Schedule != nil { + objectMap["schedule"] = jsp.Schedule + } + if jsp.Runbook != nil { + objectMap["runbook"] = jsp.Runbook + } + if jsp.RunOn != nil { + objectMap["runOn"] = jsp.RunOn + } + if jsp.Parameters != nil { + objectMap["parameters"] = jsp.Parameters + } + return json.Marshal(objectMap) +} + +// JobStream definition of the job stream. +type JobStream struct { + autorest.Response `json:"-"` + // ID - Gets or sets the id of the resource. + ID *string `json:"id,omitempty"` + // JobStreamProperties - Gets or sets the id of the job stream. + *JobStreamProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for JobStream. +func (js JobStream) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if js.ID != nil { + objectMap["id"] = js.ID + } + if js.JobStreamProperties != nil { + objectMap["properties"] = js.JobStreamProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for JobStream struct. +func (js *JobStream) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + js.ID = &ID + } + case "properties": + if v != nil { + var jobStreamProperties JobStreamProperties + err = json.Unmarshal(*v, &jobStreamProperties) + if err != nil { + return err + } + js.JobStreamProperties = &jobStreamProperties + } + } + } + + return nil +} + +// JobStreamListResult the response model for the list job stream operation. +type JobStreamListResult struct { + autorest.Response `json:"-"` + // Value - A list of job streams. + Value *[]JobStream `json:"value,omitempty"` + // NextLink - Gets or sets the next link. + NextLink *string `json:"nextLink,omitempty"` +} + +// JobStreamListResultIterator provides access to a complete listing of JobStream values. +type JobStreamListResultIterator struct { + i int + page JobStreamListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *JobStreamListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter JobStreamListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter JobStreamListResultIterator) Response() JobStreamListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter JobStreamListResultIterator) Value() JobStream { + if !iter.page.NotDone() { + return JobStream{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (jslr JobStreamListResult) IsEmpty() bool { + return jslr.Value == nil || len(*jslr.Value) == 0 +} + +// jobStreamListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (jslr JobStreamListResult) jobStreamListResultPreparer() (*http.Request, error) { + if jslr.NextLink == nil || len(to.String(jslr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(jslr.NextLink))) +} + +// JobStreamListResultPage contains a page of JobStream values. +type JobStreamListResultPage struct { + fn func(JobStreamListResult) (JobStreamListResult, error) + jslr JobStreamListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *JobStreamListResultPage) Next() error { + next, err := page.fn(page.jslr) + if err != nil { + return err + } + page.jslr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page JobStreamListResultPage) NotDone() bool { + return !page.jslr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page JobStreamListResultPage) Response() JobStreamListResult { + return page.jslr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page JobStreamListResultPage) Values() []JobStream { + if page.jslr.IsEmpty() { + return nil + } + return *page.jslr.Value +} + +// JobStreamProperties definition of the job stream. +type JobStreamProperties struct { + // JobStreamID - Gets or sets the id of the job stream. + JobStreamID *string `json:"jobStreamId,omitempty"` + // Time - Gets or sets the creation time of the job. + Time *date.Time `json:"time,omitempty"` + // StreamType - Gets or sets the stream type. Possible values include: 'Progress', 'Output', 'Warning', 'Error', 'Debug', 'Verbose', 'Any' + StreamType JobStreamType `json:"streamType,omitempty"` + // StreamText - Gets or sets the stream text. + StreamText *string `json:"streamText,omitempty"` + // Summary - Gets or sets the summary. + Summary *string `json:"summary,omitempty"` + // Value - Gets or sets the values of the job stream. + Value map[string]interface{} `json:"value"` +} + +// MarshalJSON is the custom marshaler for JobStreamProperties. +func (jsp JobStreamProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if jsp.JobStreamID != nil { + objectMap["jobStreamId"] = jsp.JobStreamID + } + if jsp.Time != nil { + objectMap["time"] = jsp.Time + } + if jsp.StreamType != "" { + objectMap["streamType"] = jsp.StreamType + } + if jsp.StreamText != nil { + objectMap["streamText"] = jsp.StreamText + } + if jsp.Summary != nil { + objectMap["summary"] = jsp.Summary + } + if jsp.Value != nil { + objectMap["value"] = jsp.Value + } + 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: 'Read', '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:"-"` + // Keys - Lists the automation keys. + Keys *[]Key `json:"keys,omitempty"` +} + +// LinkedWorkspace definition of the linked workspace. +type LinkedWorkspace struct { + autorest.Response `json:"-"` + // ID - Gets the id of the linked workspace. + ID *string `json:"id,omitempty"` +} + +// LinuxProperties linux specific update configuration. +type LinuxProperties struct { + // IncludedPackageClassifications - Update classifications included in the software update configuration. Possible values include: 'Unclassified', 'Critical', 'Security', 'Other' + IncludedPackageClassifications LinuxUpdateClasses `json:"includedPackageClassifications,omitempty"` + // ExcludedPackageNameMasks - packages excluded from the software update configuration. + ExcludedPackageNameMasks *[]string `json:"excludedPackageNameMasks,omitempty"` + // IncludedPackageNameMasks - packages included from the software update configuration. + IncludedPackageNameMasks *[]string `json:"includedPackageNameMasks,omitempty"` + // RebootSetting - Reboot setting for the software update configuration. + RebootSetting *string `json:"rebootSetting,omitempty"` +} + +// Module definition of the module type. +type Module struct { + autorest.Response `json:"-"` + // ModuleProperties - Gets or sets the module properties. + *ModuleProperties `json:"properties,omitempty"` + // Etag - Gets or sets the etag of the resource. + Etag *string `json:"etag,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The Azure Region where the resource lives + Location *string `json:"location,omitempty"` + // ID - Fully qualified resource Id for the resource + ID *string `json:"id,omitempty"` + // Name - The name of the resource + Name *string `json:"name,omitempty"` + // Type - The type of the resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Module. +func (mVar Module) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mVar.ModuleProperties != nil { + objectMap["properties"] = mVar.ModuleProperties + } + if mVar.Etag != nil { + objectMap["etag"] = mVar.Etag + } + if mVar.Tags != nil { + objectMap["tags"] = mVar.Tags + } + if mVar.Location != nil { + objectMap["location"] = mVar.Location + } + if mVar.ID != nil { + objectMap["id"] = mVar.ID + } + if mVar.Name != nil { + objectMap["name"] = mVar.Name + } + if mVar.Type != nil { + objectMap["type"] = mVar.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Module struct. +func (mVar *Module) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var moduleProperties ModuleProperties + err = json.Unmarshal(*v, &moduleProperties) + if err != nil { + return err + } + mVar.ModuleProperties = &moduleProperties + } + case "etag": + if v != nil { + var etag string + err = json.Unmarshal(*v, &etag) + if err != nil { + return err + } + mVar.Etag = &etag + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + mVar.Tags = tags + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + mVar.Location = &location + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + mVar.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mVar.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + mVar.Type = &typeVar + } + } + } + + return nil +} + +// ModuleCreateOrUpdateParameters the parameters supplied to the create or update module operation. +type ModuleCreateOrUpdateParameters struct { + // ModuleCreateOrUpdateProperties - Gets or sets the module create properties. + *ModuleCreateOrUpdateProperties `json:"properties,omitempty"` + // Name - Gets or sets name of the resource. + Name *string `json:"name,omitempty"` + // Location - Gets or sets the location of the resource. + Location *string `json:"location,omitempty"` + // Tags - Gets or sets the tags attached to the resource. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for ModuleCreateOrUpdateParameters. +func (mcoup ModuleCreateOrUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mcoup.ModuleCreateOrUpdateProperties != nil { + objectMap["properties"] = mcoup.ModuleCreateOrUpdateProperties + } + if mcoup.Name != nil { + objectMap["name"] = mcoup.Name + } + if mcoup.Location != nil { + objectMap["location"] = mcoup.Location + } + if mcoup.Tags != nil { + objectMap["tags"] = mcoup.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ModuleCreateOrUpdateParameters struct. +func (mcoup *ModuleCreateOrUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var moduleCreateOrUpdateProperties ModuleCreateOrUpdateProperties + err = json.Unmarshal(*v, &moduleCreateOrUpdateProperties) + if err != nil { + return err + } + mcoup.ModuleCreateOrUpdateProperties = &moduleCreateOrUpdateProperties + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mcoup.Name = &name + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + mcoup.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + mcoup.Tags = tags + } + } + } + + return nil +} + +// ModuleCreateOrUpdateProperties the parameters supplied to the create or update module properties. +type ModuleCreateOrUpdateProperties struct { + // ContentLink - Gets or sets the module content link. + ContentLink *ContentLink `json:"contentLink,omitempty"` +} + +// ModuleErrorInfo definition of the module error info type. +type ModuleErrorInfo struct { + // Code - Gets or sets the error code. + Code *string `json:"code,omitempty"` + // Message - Gets or sets the error message. + Message *string `json:"message,omitempty"` +} + +// ModuleListResult the response model for the list module operation. +type ModuleListResult struct { + autorest.Response `json:"-"` + // Value - Gets or sets a list of modules. + Value *[]Module `json:"value,omitempty"` + // NextLink - Gets or sets the next link. + NextLink *string `json:"nextLink,omitempty"` +} + +// ModuleListResultIterator provides access to a complete listing of Module values. +type ModuleListResultIterator struct { + i int + page ModuleListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ModuleListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ModuleListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ModuleListResultIterator) Response() ModuleListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ModuleListResultIterator) Value() Module { + if !iter.page.NotDone() { + return Module{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (mlr ModuleListResult) IsEmpty() bool { + return mlr.Value == nil || len(*mlr.Value) == 0 +} + +// moduleListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (mlr ModuleListResult) moduleListResultPreparer() (*http.Request, error) { + if mlr.NextLink == nil || len(to.String(mlr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(mlr.NextLink))) +} + +// ModuleListResultPage contains a page of Module values. +type ModuleListResultPage struct { + fn func(ModuleListResult) (ModuleListResult, error) + mlr ModuleListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ModuleListResultPage) Next() error { + next, err := page.fn(page.mlr) + if err != nil { + return err + } + page.mlr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ModuleListResultPage) NotDone() bool { + return !page.mlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ModuleListResultPage) Response() ModuleListResult { + return page.mlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ModuleListResultPage) Values() []Module { + if page.mlr.IsEmpty() { + return nil + } + return *page.mlr.Value +} + +// ModuleProperties definition of the module property type. +type ModuleProperties struct { + // IsGlobal - Gets or sets the isGlobal flag of the module. + IsGlobal *bool `json:"isGlobal,omitempty"` + // Version - Gets or sets the version of the module. + Version *string `json:"version,omitempty"` + // SizeInBytes - Gets or sets the size in bytes of the module. + SizeInBytes *int64 `json:"sizeInBytes,omitempty"` + // ActivityCount - Gets or sets the activity count of the module. + ActivityCount *int32 `json:"activityCount,omitempty"` + // ProvisioningState - Gets or sets the provisioning state of the module. Possible values include: 'ModuleProvisioningStateCreated', 'ModuleProvisioningStateCreating', 'ModuleProvisioningStateStartingImportModuleRunbook', 'ModuleProvisioningStateRunningImportModuleRunbook', 'ModuleProvisioningStateContentRetrieved', 'ModuleProvisioningStateContentDownloaded', 'ModuleProvisioningStateContentValidated', 'ModuleProvisioningStateConnectionTypeImported', 'ModuleProvisioningStateContentStored', 'ModuleProvisioningStateModuleDataStored', 'ModuleProvisioningStateActivitiesStored', 'ModuleProvisioningStateModuleImportRunbookComplete', 'ModuleProvisioningStateSucceeded', 'ModuleProvisioningStateFailed', 'ModuleProvisioningStateCancelled', 'ModuleProvisioningStateUpdating' + ProvisioningState ModuleProvisioningState `json:"provisioningState,omitempty"` + // ContentLink - Gets or sets the contentLink of the module. + ContentLink *ContentLink `json:"contentLink,omitempty"` + // Error - Gets or sets the error info of the module. + Error *ModuleErrorInfo `json:"error,omitempty"` + // CreationTime - Gets or sets the creation time. + CreationTime *date.Time `json:"creationTime,omitempty"` + // LastModifiedTime - Gets or sets the last modified time. + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + // Description - Gets or sets the description. + Description *string `json:"description,omitempty"` + // IsComposite - Gets or sets type of module, if its composite or not. + IsComposite *bool `json:"isComposite,omitempty"` +} + +// ModuleUpdateParameters the parameters supplied to the update module operation. +type ModuleUpdateParameters struct { + // ModuleUpdateProperties - Gets or sets the module update properties. + *ModuleUpdateProperties `json:"properties,omitempty"` + // Name - Gets or sets name of the resource. + Name *string `json:"name,omitempty"` + // Location - Gets or sets the location of the resource. + Location *string `json:"location,omitempty"` + // Tags - Gets or sets the tags attached to the resource. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for ModuleUpdateParameters. +func (mup ModuleUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mup.ModuleUpdateProperties != nil { + objectMap["properties"] = mup.ModuleUpdateProperties + } + if mup.Name != nil { + objectMap["name"] = mup.Name + } + if mup.Location != nil { + objectMap["location"] = mup.Location + } + if mup.Tags != nil { + objectMap["tags"] = mup.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ModuleUpdateParameters struct. +func (mup *ModuleUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var moduleUpdateProperties ModuleUpdateProperties + err = json.Unmarshal(*v, &moduleUpdateProperties) + if err != nil { + return err + } + mup.ModuleUpdateProperties = &moduleUpdateProperties + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mup.Name = &name + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + mup.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + mup.Tags = tags + } + } + } + + return nil +} + +// ModuleUpdateProperties the parameters supplied to the update properties. +type ModuleUpdateProperties struct { + // ContentLink - Gets or sets the module content link. + ContentLink *ContentLink `json:"contentLink,omitempty"` +} + +// NodeCount number of nodes based on the Filter +type NodeCount struct { + // Name - Gets the name of a count type + Name *string `json:"name,omitempty"` + Properties *NodeCountProperties `json:"properties,omitempty"` +} + +// NodeCountProperties ... +type NodeCountProperties struct { + // Count - Gets the count for the name + Count *int32 `json:"count,omitempty"` +} + +// NodeCounts gets the count of nodes by count type +type NodeCounts struct { + autorest.Response `json:"-"` + // Value - Gets an array of counts + Value *[]NodeCount `json:"value,omitempty"` + // TotalCount - Gets the total number of records matching countType criteria. + TotalCount *int32 `json:"totalCount,omitempty"` +} + +// Operation automation REST API operation +type Operation struct { + // Name - Operation name: {provider}/{resource}/{operation} + Name *string `json:"name,omitempty"` + // Display - Provider, Resource and Operation values + Display *OperationDisplay `json:"display,omitempty"` +} + +// OperationDisplay provider, Resource and Operation values +type OperationDisplay struct { + // Provider - Service provider: Microsoft.Automation + Provider *string `json:"provider,omitempty"` + // Resource - Resource on which the operation is performed: Runbooks, Jobs etc. + Resource *string `json:"resource,omitempty"` + // Operation - Operation type: Read, write, delete, etc. + Operation *string `json:"operation,omitempty"` +} + +// OperationListResult the response model for the list of Automation operations +type OperationListResult struct { + autorest.Response `json:"-"` + // Value - List of Automation operations supported by the Automation resource provider. + Value *[]Operation `json:"value,omitempty"` +} + +// ProxyResource ARM proxy resource. +type ProxyResource struct { + // ID - Fully qualified resource Id for the resource + ID *string `json:"id,omitempty"` + // Name - The name of the resource + Name *string `json:"name,omitempty"` + // Type - The type of the resource. + Type *string `json:"type,omitempty"` +} + +// PythonPackageCreateParameters the parameters supplied to the create or update module operation. +type PythonPackageCreateParameters struct { + // PythonPackageCreateProperties - Gets or sets the module create properties. + *PythonPackageCreateProperties `json:"properties,omitempty"` + // Tags - Gets or sets the tags attached to the resource. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for PythonPackageCreateParameters. +func (ppcp PythonPackageCreateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ppcp.PythonPackageCreateProperties != nil { + objectMap["properties"] = ppcp.PythonPackageCreateProperties + } + if ppcp.Tags != nil { + objectMap["tags"] = ppcp.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for PythonPackageCreateParameters struct. +func (ppcp *PythonPackageCreateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var pythonPackageCreateProperties PythonPackageCreateProperties + err = json.Unmarshal(*v, &pythonPackageCreateProperties) + if err != nil { + return err + } + ppcp.PythonPackageCreateProperties = &pythonPackageCreateProperties + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + ppcp.Tags = tags + } + } + } + + return nil +} + +// PythonPackageCreateProperties the parameters supplied to the create or update module properties. +type PythonPackageCreateProperties struct { + // ContentLink - Gets or sets the module content link. + ContentLink *ContentLink `json:"contentLink,omitempty"` +} + +// PythonPackageUpdateParameters the parameters supplied to the update module operation. +type PythonPackageUpdateParameters struct { + // Tags - Gets or sets the tags attached to the resource. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for PythonPackageUpdateParameters. +func (ppup PythonPackageUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ppup.Tags != nil { + objectMap["tags"] = ppup.Tags + } + return json.Marshal(objectMap) +} + +// ReadCloser ... +type ReadCloser struct { + autorest.Response `json:"-"` + Value *io.ReadCloser `json:"value,omitempty"` +} + +// Resource the core properties of ARM resources +type Resource struct { + // ID - Fully qualified resource Id for the resource + ID *string `json:"id,omitempty"` + // Name - The name of the resource + Name *string `json:"name,omitempty"` + // Type - The type of the resource. + Type *string `json:"type,omitempty"` +} + +// RunAsCredentialAssociationProperty definition of runas credential to use for hybrid worker. +type RunAsCredentialAssociationProperty struct { + // Name - Gets or sets the name of the credential. + Name *string `json:"name,omitempty"` +} + +// Runbook definition of the runbook type. +type Runbook struct { + autorest.Response `json:"-"` + // RunbookProperties - Gets or sets the runbook properties. + *RunbookProperties `json:"properties,omitempty"` + // Etag - Gets or sets the etag of the resource. + Etag *string `json:"etag,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The Azure Region where the resource lives + Location *string `json:"location,omitempty"` + // ID - Fully qualified resource Id for the resource + ID *string `json:"id,omitempty"` + // Name - The name of the resource + Name *string `json:"name,omitempty"` + // Type - The type of the resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Runbook. +func (r Runbook) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if r.RunbookProperties != nil { + objectMap["properties"] = r.RunbookProperties + } + if r.Etag != nil { + objectMap["etag"] = r.Etag + } + if r.Tags != nil { + objectMap["tags"] = r.Tags + } + if r.Location != nil { + objectMap["location"] = r.Location + } + if r.ID != nil { + objectMap["id"] = r.ID + } + if r.Name != nil { + objectMap["name"] = r.Name + } + if r.Type != nil { + objectMap["type"] = r.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Runbook struct. +func (r *Runbook) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var runbookProperties RunbookProperties + err = json.Unmarshal(*v, &runbookProperties) + if err != nil { + return err + } + r.RunbookProperties = &runbookProperties + } + case "etag": + if v != nil { + var etag string + err = json.Unmarshal(*v, &etag) + if err != nil { + return err + } + r.Etag = &etag + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + r.Tags = tags + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + r.Location = &location + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + r.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + r.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + r.Type = &typeVar + } + } + } + + return nil +} + +// RunbookAssociationProperty the runbook property associated with the entity. +type RunbookAssociationProperty struct { + // Name - Gets or sets the name of the runbook. + Name *string `json:"name,omitempty"` +} + +// RunbookCreateOrUpdateDraftParameters the parameters supplied to the create or update runbook operation. +type RunbookCreateOrUpdateDraftParameters struct { + // RunbookContent - Content of the Runbook. + RunbookContent *string `json:"runbookContent,omitempty"` +} + +// RunbookCreateOrUpdateDraftProperties the parameters supplied to the create or update dratft runbook properties. +type RunbookCreateOrUpdateDraftProperties struct { + // LogVerbose - Gets or sets verbose log option. + LogVerbose *bool `json:"logVerbose,omitempty"` + // LogProgress - Gets or sets progress log option. + LogProgress *bool `json:"logProgress,omitempty"` + // RunbookType - Gets or sets the type of the runbook. Possible values include: 'Script', 'Graph', 'PowerShellWorkflow', 'PowerShell', 'GraphPowerShellWorkflow', 'GraphPowerShell' + RunbookType RunbookTypeEnum `json:"runbookType,omitempty"` + // Draft - Gets or sets the draft runbook properties. + Draft *RunbookDraft `json:"draft,omitempty"` + // Description - Gets or sets the description of the runbook. + Description *string `json:"description,omitempty"` + // LogActivityTrace - Gets or sets the activity-level tracing options of the runbook. + LogActivityTrace *int32 `json:"logActivityTrace,omitempty"` +} + +// RunbookCreateOrUpdateParameters the parameters supplied to the create or update runbook operation. +type RunbookCreateOrUpdateParameters struct { + // RunbookCreateOrUpdateProperties - Gets or sets runbook create or update properties. + *RunbookCreateOrUpdateProperties `json:"properties,omitempty"` + // Name - Gets or sets the name of the resource. + Name *string `json:"name,omitempty"` + // Location - Gets or sets the location of the resource. + Location *string `json:"location,omitempty"` + // Tags - Gets or sets the tags attached to the resource. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for RunbookCreateOrUpdateParameters. +func (rcoup RunbookCreateOrUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rcoup.RunbookCreateOrUpdateProperties != nil { + objectMap["properties"] = rcoup.RunbookCreateOrUpdateProperties + } + if rcoup.Name != nil { + objectMap["name"] = rcoup.Name + } + if rcoup.Location != nil { + objectMap["location"] = rcoup.Location + } + if rcoup.Tags != nil { + objectMap["tags"] = rcoup.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RunbookCreateOrUpdateParameters struct. +func (rcoup *RunbookCreateOrUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var runbookCreateOrUpdateProperties RunbookCreateOrUpdateProperties + err = json.Unmarshal(*v, &runbookCreateOrUpdateProperties) + if err != nil { + return err + } + rcoup.RunbookCreateOrUpdateProperties = &runbookCreateOrUpdateProperties + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rcoup.Name = &name + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + rcoup.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + rcoup.Tags = tags + } + } + } + + return nil +} + +// RunbookCreateOrUpdateProperties the parameters supplied to the create or update runbook properties. +type RunbookCreateOrUpdateProperties struct { + // LogVerbose - Gets or sets verbose log option. + LogVerbose *bool `json:"logVerbose,omitempty"` + // LogProgress - Gets or sets progress log option. + LogProgress *bool `json:"logProgress,omitempty"` + // RunbookType - Gets or sets the type of the runbook. Possible values include: 'Script', 'Graph', 'PowerShellWorkflow', 'PowerShell', 'GraphPowerShellWorkflow', 'GraphPowerShell' + RunbookType RunbookTypeEnum `json:"runbookType,omitempty"` + // Draft - Gets or sets the draft runbook properties. + Draft *RunbookDraft `json:"draft,omitempty"` + // PublishContentLink - Gets or sets the published runbook content link. + PublishContentLink *ContentLink `json:"publishContentLink,omitempty"` + // Description - Gets or sets the description of the runbook. + Description *string `json:"description,omitempty"` + // LogActivityTrace - Gets or sets the activity-level tracing options of the runbook. + LogActivityTrace *int32 `json:"logActivityTrace,omitempty"` +} + +// RunbookDraft ... +type RunbookDraft struct { + autorest.Response `json:"-"` + // InEdit - Gets or sets whether runbook is in edit mode. + InEdit *bool `json:"inEdit,omitempty"` + // DraftContentLink - Gets or sets the draft runbook content link. + DraftContentLink *ContentLink `json:"draftContentLink,omitempty"` + // CreationTime - Gets or sets the creation time of the runbook draft. + CreationTime *date.Time `json:"creationTime,omitempty"` + // LastModifiedTime - Gets or sets the last modified time of the runbook draft. + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + // Parameters - Gets or sets the runbook draft parameters. + Parameters map[string]*RunbookParameter `json:"parameters"` + // OutputTypes - Gets or sets the runbook output types. + OutputTypes *[]string `json:"outputTypes,omitempty"` +} + +// MarshalJSON is the custom marshaler for RunbookDraft. +func (rd RunbookDraft) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rd.InEdit != nil { + objectMap["inEdit"] = rd.InEdit + } + if rd.DraftContentLink != nil { + objectMap["draftContentLink"] = rd.DraftContentLink + } + if rd.CreationTime != nil { + objectMap["creationTime"] = rd.CreationTime + } + if rd.LastModifiedTime != nil { + objectMap["lastModifiedTime"] = rd.LastModifiedTime + } + if rd.Parameters != nil { + objectMap["parameters"] = rd.Parameters + } + if rd.OutputTypes != nil { + objectMap["outputTypes"] = rd.OutputTypes + } + return json.Marshal(objectMap) +} + +// RunbookDraftReplaceContentFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type RunbookDraftReplaceContentFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *RunbookDraftReplaceContentFuture) Result(client RunbookDraftClient) (rc ReadCloser, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookDraftReplaceContentFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("automation.RunbookDraftReplaceContentFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if rc.Response.Response, err = future.GetResult(sender); err == nil && rc.Response.Response.StatusCode != http.StatusNoContent { + rc, err = client.ReplaceContentResponder(rc.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookDraftReplaceContentFuture", "Result", rc.Response.Response, "Failure responding to request") + } + } + return +} + +// RunbookDraftUndoEditResult the response model for the undoedit runbook operation. +type RunbookDraftUndoEditResult struct { + autorest.Response `json:"-"` + // StatusCode - Possible values include: 'Continue', 'SwitchingProtocols', 'OK', 'Created', 'Accepted', 'NonAuthoritativeInformation', 'NoContent', 'ResetContent', 'PartialContent', 'MultipleChoices', 'Ambiguous', 'MovedPermanently', 'Moved', 'Found', 'Redirect', 'SeeOther', 'RedirectMethod', 'NotModified', 'UseProxy', 'Unused', 'TemporaryRedirect', 'RedirectKeepVerb', 'BadRequest', 'Unauthorized', 'PaymentRequired', 'Forbidden', 'NotFound', 'MethodNotAllowed', 'NotAcceptable', 'ProxyAuthenticationRequired', 'RequestTimeout', 'Conflict', 'Gone', 'LengthRequired', 'PreconditionFailed', 'RequestEntityTooLarge', 'RequestURITooLong', 'UnsupportedMediaType', 'RequestedRangeNotSatisfiable', 'ExpectationFailed', 'UpgradeRequired', 'InternalServerError', 'NotImplemented', 'BadGateway', 'ServiceUnavailable', 'GatewayTimeout', 'HTTPVersionNotSupported' + StatusCode HTTPStatusCode `json:"statusCode,omitempty"` + RequestID *string `json:"requestId,omitempty"` +} + +// RunbookListResult the response model for the list runbook operation. +type RunbookListResult struct { + autorest.Response `json:"-"` + // Value - Gets or sets a list of runbooks. + Value *[]Runbook `json:"value,omitempty"` + // NextLink - Gets or sets the next link. + NextLink *string `json:"nextLink,omitempty"` +} + +// RunbookListResultIterator provides access to a complete listing of Runbook values. +type RunbookListResultIterator struct { + i int + page RunbookListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *RunbookListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter RunbookListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter RunbookListResultIterator) Response() RunbookListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter RunbookListResultIterator) Value() Runbook { + if !iter.page.NotDone() { + return Runbook{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (rlr RunbookListResult) IsEmpty() bool { + return rlr.Value == nil || len(*rlr.Value) == 0 +} + +// runbookListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (rlr RunbookListResult) runbookListResultPreparer() (*http.Request, error) { + if rlr.NextLink == nil || len(to.String(rlr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(rlr.NextLink))) +} + +// RunbookListResultPage contains a page of Runbook values. +type RunbookListResultPage struct { + fn func(RunbookListResult) (RunbookListResult, error) + rlr RunbookListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *RunbookListResultPage) Next() error { + next, err := page.fn(page.rlr) + if err != nil { + return err + } + page.rlr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page RunbookListResultPage) NotDone() bool { + return !page.rlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page RunbookListResultPage) Response() RunbookListResult { + return page.rlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page RunbookListResultPage) Values() []Runbook { + if page.rlr.IsEmpty() { + return nil + } + return *page.rlr.Value +} + +// RunbookParameter definition of the runbook parameter type. +type RunbookParameter struct { + // Type - Gets or sets the type of the parameter. + Type *string `json:"type,omitempty"` + // IsMandatory - Gets or sets a Boolean value to indicate whether the parameter is madatory or not. + IsMandatory *bool `json:"isMandatory,omitempty"` + // Position - Get or sets the position of the parameter. + Position *int32 `json:"position,omitempty"` + // DefaultValue - Gets or sets the default value of parameter. + DefaultValue *string `json:"defaultValue,omitempty"` +} + +// RunbookProperties definition of the runbook property type. +type RunbookProperties struct { + // RunbookType - Gets or sets the type of the runbook. Possible values include: 'Script', 'Graph', 'PowerShellWorkflow', 'PowerShell', 'GraphPowerShellWorkflow', 'GraphPowerShell' + RunbookType RunbookTypeEnum `json:"runbookType,omitempty"` + // PublishContentLink - Gets or sets the published runbook content link. + PublishContentLink *ContentLink `json:"publishContentLink,omitempty"` + // State - Gets or sets the state of the runbook. Possible values include: 'RunbookStateNew', 'RunbookStateEdit', 'RunbookStatePublished' + State RunbookState `json:"state,omitempty"` + // LogVerbose - Gets or sets verbose log option. + LogVerbose *bool `json:"logVerbose,omitempty"` + // LogProgress - Gets or sets progress log option. + LogProgress *bool `json:"logProgress,omitempty"` + // LogActivityTrace - Gets or sets the option to log activity trace of the runbook. + LogActivityTrace *int32 `json:"logActivityTrace,omitempty"` + // JobCount - Gets or sets the job count of the runbook. + JobCount *int32 `json:"jobCount,omitempty"` + // Parameters - Gets or sets the runbook parameters. + Parameters map[string]*RunbookParameter `json:"parameters"` + // OutputTypes - Gets or sets the runbook output types. + OutputTypes *[]string `json:"outputTypes,omitempty"` + // Draft - Gets or sets the draft runbook properties. + Draft *RunbookDraft `json:"draft,omitempty"` + // ProvisioningState - Gets or sets the provisioning state of the runbook. Possible values include: 'RunbookProvisioningStateSucceeded' + ProvisioningState RunbookProvisioningState `json:"provisioningState,omitempty"` + // LastModifiedBy - Gets or sets the last modified by. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + // CreationTime - Gets or sets the creation time. + CreationTime *date.Time `json:"creationTime,omitempty"` + // LastModifiedTime - Gets or sets the last modified time. + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + // Description - Gets or sets the description. + Description *string `json:"description,omitempty"` +} + +// MarshalJSON is the custom marshaler for RunbookProperties. +func (rp RunbookProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rp.RunbookType != "" { + objectMap["runbookType"] = rp.RunbookType + } + if rp.PublishContentLink != nil { + objectMap["publishContentLink"] = rp.PublishContentLink + } + if rp.State != "" { + objectMap["state"] = rp.State + } + if rp.LogVerbose != nil { + objectMap["logVerbose"] = rp.LogVerbose + } + if rp.LogProgress != nil { + objectMap["logProgress"] = rp.LogProgress + } + if rp.LogActivityTrace != nil { + objectMap["logActivityTrace"] = rp.LogActivityTrace + } + if rp.JobCount != nil { + objectMap["jobCount"] = rp.JobCount + } + if rp.Parameters != nil { + objectMap["parameters"] = rp.Parameters + } + if rp.OutputTypes != nil { + objectMap["outputTypes"] = rp.OutputTypes + } + if rp.Draft != nil { + objectMap["draft"] = rp.Draft + } + if rp.ProvisioningState != "" { + objectMap["provisioningState"] = rp.ProvisioningState + } + if rp.LastModifiedBy != nil { + objectMap["lastModifiedBy"] = rp.LastModifiedBy + } + if rp.CreationTime != nil { + objectMap["creationTime"] = rp.CreationTime + } + if rp.LastModifiedTime != nil { + objectMap["lastModifiedTime"] = rp.LastModifiedTime + } + if rp.Description != nil { + objectMap["description"] = rp.Description + } + return json.Marshal(objectMap) +} + +// RunbookPublishFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type RunbookPublishFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *RunbookPublishFuture) Result(client RunbookClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookPublishFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("automation.RunbookPublishFuture") + return + } + ar.Response = future.Response() + return +} + +// RunbookUpdateParameters the parameters supplied to the update runbook operation. +type RunbookUpdateParameters struct { + // RunbookUpdateProperties - Gets or sets the runbook update properties. + *RunbookUpdateProperties `json:"properties,omitempty"` + // Name - Gets or sets the name of the resource. + Name *string `json:"name,omitempty"` + // Location - Gets or sets the location of the resource. + Location *string `json:"location,omitempty"` + // Tags - Gets or sets the tags attached to the resource. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for RunbookUpdateParameters. +func (rup RunbookUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rup.RunbookUpdateProperties != nil { + objectMap["properties"] = rup.RunbookUpdateProperties + } + if rup.Name != nil { + objectMap["name"] = rup.Name + } + if rup.Location != nil { + objectMap["location"] = rup.Location + } + if rup.Tags != nil { + objectMap["tags"] = rup.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RunbookUpdateParameters struct. +func (rup *RunbookUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var runbookUpdateProperties RunbookUpdateProperties + err = json.Unmarshal(*v, &runbookUpdateProperties) + if err != nil { + return err + } + rup.RunbookUpdateProperties = &runbookUpdateProperties + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rup.Name = &name + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + rup.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + rup.Tags = tags + } + } + } + + return nil +} + +// RunbookUpdateProperties the parameters supplied to the update runbook properties. +type RunbookUpdateProperties struct { + // Description - Gets or sets the description of the runbook. + Description *string `json:"description,omitempty"` + // LogVerbose - Gets or sets verbose log option. + LogVerbose *bool `json:"logVerbose,omitempty"` + // LogProgress - Gets or sets progress log option. + LogProgress *bool `json:"logProgress,omitempty"` + // LogActivityTrace - Gets or sets the activity-level tracing options of the runbook. + LogActivityTrace *int32 `json:"logActivityTrace,omitempty"` +} + +// Schedule definition of the schedule. +type Schedule struct { + autorest.Response `json:"-"` + // ScheduleProperties - Gets or sets the properties of the schedule. + *ScheduleProperties `json:"properties,omitempty"` + // ID - Fully qualified resource Id for the resource + ID *string `json:"id,omitempty"` + // Name - The name of the resource + Name *string `json:"name,omitempty"` + // Type - The type of the resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Schedule. +func (s Schedule) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if s.ScheduleProperties != nil { + objectMap["properties"] = s.ScheduleProperties + } + if s.ID != nil { + objectMap["id"] = s.ID + } + if s.Name != nil { + objectMap["name"] = s.Name + } + if s.Type != nil { + objectMap["type"] = s.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Schedule struct. +func (s *Schedule) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var scheduleProperties ScheduleProperties + err = json.Unmarshal(*v, &scheduleProperties) + if err != nil { + return err + } + s.ScheduleProperties = &scheduleProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + s.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + s.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + s.Type = &typeVar + } + } + } + + return nil +} + +// ScheduleAssociationProperty the schedule property associated with the entity. +type ScheduleAssociationProperty struct { + // Name - Gets or sets the name of the Schedule. + Name *string `json:"name,omitempty"` +} + +// ScheduleCreateOrUpdateParameters the parameters supplied to the create or update schedule operation. +type ScheduleCreateOrUpdateParameters struct { + // Name - Gets or sets the name of the Schedule. + Name *string `json:"name,omitempty"` + // ScheduleCreateOrUpdateProperties - Gets or sets the list of schedule properties. + *ScheduleCreateOrUpdateProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for ScheduleCreateOrUpdateParameters. +func (scoup ScheduleCreateOrUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if scoup.Name != nil { + objectMap["name"] = scoup.Name + } + if scoup.ScheduleCreateOrUpdateProperties != nil { + objectMap["properties"] = scoup.ScheduleCreateOrUpdateProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ScheduleCreateOrUpdateParameters struct. +func (scoup *ScheduleCreateOrUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + scoup.Name = &name + } + case "properties": + if v != nil { + var scheduleCreateOrUpdateProperties ScheduleCreateOrUpdateProperties + err = json.Unmarshal(*v, &scheduleCreateOrUpdateProperties) + if err != nil { + return err + } + scoup.ScheduleCreateOrUpdateProperties = &scheduleCreateOrUpdateProperties + } + } + } + + return nil +} + +// ScheduleCreateOrUpdateProperties the parameters supplied to the create or update schedule operation. +type ScheduleCreateOrUpdateProperties struct { + // Description - Gets or sets the description of the schedule. + Description *string `json:"description,omitempty"` + // StartTime - Gets or sets the start time of the schedule. + StartTime *date.Time `json:"startTime,omitempty"` + // ExpiryTime - Gets or sets the end time of the schedule. + ExpiryTime *date.Time `json:"expiryTime,omitempty"` + // Interval - Gets or sets the interval of the schedule. + Interval interface{} `json:"interval,omitempty"` + // Frequency - Possible values include: 'OneTime', 'Day', 'Hour', 'Week', 'Month' + Frequency ScheduleFrequency `json:"frequency,omitempty"` + // TimeZone - Gets or sets the time zone of the schedule. + TimeZone *string `json:"timeZone,omitempty"` + // AdvancedSchedule - Gets or sets the AdvancedSchedule. + AdvancedSchedule *AdvancedSchedule `json:"advancedSchedule,omitempty"` +} + +// ScheduleListResult the response model for the list schedule operation. +type ScheduleListResult struct { + autorest.Response `json:"-"` + // Value - Gets or sets a list of schedules. + Value *[]Schedule `json:"value,omitempty"` + // NextLink - Gets or sets the next link. + NextLink *string `json:"nextLink,omitempty"` +} + +// ScheduleListResultIterator provides access to a complete listing of Schedule values. +type ScheduleListResultIterator struct { + i int + page ScheduleListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ScheduleListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ScheduleListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ScheduleListResultIterator) Response() ScheduleListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ScheduleListResultIterator) Value() Schedule { + if !iter.page.NotDone() { + return Schedule{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (slr ScheduleListResult) IsEmpty() bool { + return slr.Value == nil || len(*slr.Value) == 0 +} + +// scheduleListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (slr ScheduleListResult) scheduleListResultPreparer() (*http.Request, error) { + if slr.NextLink == nil || len(to.String(slr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(slr.NextLink))) +} + +// ScheduleListResultPage contains a page of Schedule values. +type ScheduleListResultPage struct { + fn func(ScheduleListResult) (ScheduleListResult, error) + slr ScheduleListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ScheduleListResultPage) Next() error { + next, err := page.fn(page.slr) + if err != nil { + return err + } + page.slr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ScheduleListResultPage) NotDone() bool { + return !page.slr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ScheduleListResultPage) Response() ScheduleListResult { + return page.slr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ScheduleListResultPage) Values() []Schedule { + if page.slr.IsEmpty() { + return nil + } + return *page.slr.Value +} + +// ScheduleProperties definition of schedule parameters. +type ScheduleProperties struct { + // StartTime - Gets or sets the start time of the schedule. + StartTime *date.Time `json:"startTime,omitempty"` + // StartTimeOffsetMinutes - Gets the start time's offset in minutes. + StartTimeOffsetMinutes *float64 `json:"startTimeOffsetMinutes,omitempty"` + // ExpiryTime - Gets or sets the end time of the schedule. + ExpiryTime *date.Time `json:"expiryTime,omitempty"` + // ExpiryTimeOffsetMinutes - Gets or sets the expiry time's offset in minutes. + ExpiryTimeOffsetMinutes *float64 `json:"expiryTimeOffsetMinutes,omitempty"` + // IsEnabled - Gets or sets a value indicating whether this schedule is enabled. + IsEnabled *bool `json:"isEnabled,omitempty"` + // NextRun - Gets or sets the next run time of the schedule. + NextRun *date.Time `json:"nextRun,omitempty"` + // NextRunOffsetMinutes - Gets or sets the next run time's offset in minutes. + NextRunOffsetMinutes *float64 `json:"nextRunOffsetMinutes,omitempty"` + // Interval - Gets or sets the interval of the schedule. + Interval *int32 `json:"interval,omitempty"` + // Frequency - Gets or sets the frequency of the schedule. Possible values include: 'OneTime', 'Day', 'Hour', 'Week', 'Month' + Frequency ScheduleFrequency `json:"frequency,omitempty"` + // TimeZone - Gets or sets the time zone of the schedule. + TimeZone *string `json:"timeZone,omitempty"` + // AdvancedSchedule - Gets or sets the advanced schedule. + AdvancedSchedule *AdvancedSchedule `json:"advancedSchedule,omitempty"` + // CreationTime - Gets or sets the creation time. + CreationTime *date.Time `json:"creationTime,omitempty"` + // LastModifiedTime - Gets or sets the last modified time. + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + // Description - Gets or sets the description. + Description *string `json:"description,omitempty"` +} + +// ScheduleUpdateParameters the parameters supplied to the update schedule operation. +type ScheduleUpdateParameters struct { + // Name - Gets or sets the name of the Schedule. + Name *string `json:"name,omitempty"` + // ScheduleUpdateProperties - Gets or sets the list of schedule properties. + *ScheduleUpdateProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for ScheduleUpdateParameters. +func (sup ScheduleUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sup.Name != nil { + objectMap["name"] = sup.Name + } + if sup.ScheduleUpdateProperties != nil { + objectMap["properties"] = sup.ScheduleUpdateProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ScheduleUpdateParameters struct. +func (sup *ScheduleUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sup.Name = &name + } + case "properties": + if v != nil { + var scheduleUpdateProperties ScheduleUpdateProperties + err = json.Unmarshal(*v, &scheduleUpdateProperties) + if err != nil { + return err + } + sup.ScheduleUpdateProperties = &scheduleUpdateProperties + } + } + } + + return nil +} + +// ScheduleUpdateProperties the parameters supplied to the update schedule operation. +type ScheduleUpdateProperties struct { + // Description - Gets or sets the description of the schedule. + Description *string `json:"description,omitempty"` + // IsEnabled - Gets or sets a value indicating whether this schedule is enabled. + IsEnabled *bool `json:"isEnabled,omitempty"` +} + +// SetObject ... +type SetObject struct { + autorest.Response `json:"-"` + Value interface{} `json:"value,omitempty"` +} + +// Sku the account SKU. +type Sku struct { + // Name - Gets or sets the SKU name of the account. Possible values include: 'Free', 'Basic' + Name SkuNameEnum `json:"name,omitempty"` + // Family - Gets or sets the SKU family. + Family *string `json:"family,omitempty"` + // Capacity - Gets or sets the SKU capacity. + Capacity *int32 `json:"capacity,omitempty"` +} + +// SoftwareUpdateConfiguration software update configuration properties. +type SoftwareUpdateConfiguration struct { + autorest.Response `json:"-"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // ID - Resource Id. + ID *string `json:"id,omitempty"` + // Type - Resource type + Type *string `json:"type,omitempty"` + // SoftwareUpdateConfigurationProperties - Software update configuration properties. + *SoftwareUpdateConfigurationProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for SoftwareUpdateConfiguration. +func (suc SoftwareUpdateConfiguration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if suc.Name != nil { + objectMap["name"] = suc.Name + } + if suc.ID != nil { + objectMap["id"] = suc.ID + } + if suc.Type != nil { + objectMap["type"] = suc.Type + } + if suc.SoftwareUpdateConfigurationProperties != nil { + objectMap["properties"] = suc.SoftwareUpdateConfigurationProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SoftwareUpdateConfiguration struct. +func (suc *SoftwareUpdateConfiguration) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + suc.Name = &name + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + suc.ID = &ID + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + suc.Type = &typeVar + } + case "properties": + if v != nil { + var softwareUpdateConfigurationProperties SoftwareUpdateConfigurationProperties + err = json.Unmarshal(*v, &softwareUpdateConfigurationProperties) + if err != nil { + return err + } + suc.SoftwareUpdateConfigurationProperties = &softwareUpdateConfigurationProperties + } + } + } + + return nil +} + +// SoftwareUpdateConfigurationCollectionItem software update configuration collection item properties. +type SoftwareUpdateConfigurationCollectionItem struct { + // Name - Name of the software update configuration. + Name *string `json:"name,omitempty"` + // ID - Resource Id of the software update configuration + ID *string `json:"id,omitempty"` + // SoftwareUpdateConfigurationCollectionItemProperties - Software update configuration properties. + *SoftwareUpdateConfigurationCollectionItemProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for SoftwareUpdateConfigurationCollectionItem. +func (succi SoftwareUpdateConfigurationCollectionItem) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if succi.Name != nil { + objectMap["name"] = succi.Name + } + if succi.ID != nil { + objectMap["id"] = succi.ID + } + if succi.SoftwareUpdateConfigurationCollectionItemProperties != nil { + objectMap["properties"] = succi.SoftwareUpdateConfigurationCollectionItemProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SoftwareUpdateConfigurationCollectionItem struct. +func (succi *SoftwareUpdateConfigurationCollectionItem) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + succi.Name = &name + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + succi.ID = &ID + } + case "properties": + if v != nil { + var softwareUpdateConfigurationCollectionItemProperties SoftwareUpdateConfigurationCollectionItemProperties + err = json.Unmarshal(*v, &softwareUpdateConfigurationCollectionItemProperties) + if err != nil { + return err + } + succi.SoftwareUpdateConfigurationCollectionItemProperties = &softwareUpdateConfigurationCollectionItemProperties + } + } + } + + return nil +} + +// SoftwareUpdateConfigurationCollectionItemProperties software update configuration collection item properties. +type SoftwareUpdateConfigurationCollectionItemProperties struct { + // UpdateConfiguration - Update specific properties of the software update configuration. + UpdateConfiguration *CollectionItemUpdateConfiguration `json:"updateConfiguration,omitempty"` + // Frequency - execution frequency of the schedule associated with the software update configuration. Possible values include: 'OneTime', 'Day', 'Hour', 'Week', 'Month' + Frequency ScheduleFrequency `json:"frequency,omitempty"` + // StartTime - the start time of the update. + StartTime *date.Time `json:"startTime,omitempty"` + // CreationTime - Creation time of the software update configuration, which only appears in the response. + CreationTime *date.Time `json:"creationTime,omitempty"` + // LastModifiedTime - Last time software update configuration was modified, which only appears in the response. + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + // ProvisioningState - Provisioning state for the software update configuration, which only appears in the response. + ProvisioningState *string `json:"provisioningState,omitempty"` + // NextRun - ext run time of the update. + NextRun *date.Time `json:"nextRun,omitempty"` +} + +// SoftwareUpdateConfigurationListResult result of listing all software update configuration +type SoftwareUpdateConfigurationListResult struct { + autorest.Response `json:"-"` + // Value - outer object returned when listing all software update configurations + Value *[]SoftwareUpdateConfigurationCollectionItem `json:"value,omitempty"` +} + +// SoftwareUpdateConfigurationMachineRun software update configuration machine run model. +type SoftwareUpdateConfigurationMachineRun struct { + autorest.Response `json:"-"` + // Name - Name of the software update configuration machine run + Name *string `json:"name,omitempty"` + // ID - Resource Id of the software update configuration machine run + ID *string `json:"id,omitempty"` + // UpdateConfigurationMachineRunProperties - Software update configuration machine run properties. + *UpdateConfigurationMachineRunProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for SoftwareUpdateConfigurationMachineRun. +func (sucmr SoftwareUpdateConfigurationMachineRun) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sucmr.Name != nil { + objectMap["name"] = sucmr.Name + } + if sucmr.ID != nil { + objectMap["id"] = sucmr.ID + } + if sucmr.UpdateConfigurationMachineRunProperties != nil { + objectMap["properties"] = sucmr.UpdateConfigurationMachineRunProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SoftwareUpdateConfigurationMachineRun struct. +func (sucmr *SoftwareUpdateConfigurationMachineRun) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sucmr.Name = &name + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sucmr.ID = &ID + } + case "properties": + if v != nil { + var updateConfigurationMachineRunProperties UpdateConfigurationMachineRunProperties + err = json.Unmarshal(*v, &updateConfigurationMachineRunProperties) + if err != nil { + return err + } + sucmr.UpdateConfigurationMachineRunProperties = &updateConfigurationMachineRunProperties + } + } + } + + return nil +} + +// SoftwareUpdateConfigurationMachineRunListResult result of listing all software update configuration machine runs +type SoftwareUpdateConfigurationMachineRunListResult struct { + autorest.Response `json:"-"` + // Value - outer object returned when listing all software update configuration machine runs + Value *[]SoftwareUpdateConfigurationMachineRun `json:"value,omitempty"` + // NextLink - link to next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// SoftwareUpdateConfigurationProperties software update configuration properties. +type SoftwareUpdateConfigurationProperties struct { + // UpdateConfiguration - update specific properties for the Software update configuration + UpdateConfiguration *UpdateConfiguration `json:"updateConfiguration,omitempty"` + // ScheduleInfo - Schedule information for the Software update configuration + ScheduleInfo *ScheduleProperties `json:"scheduleInfo,omitempty"` + // ProvisioningState - Provisioning state for the software update configuration, which only appears in the response. + ProvisioningState *string `json:"provisioningState,omitempty"` + // Error - detailes of provisioning error + Error *ErrorResponse `json:"error,omitempty"` + // CreationTime - Creation time of theresource, which only appears in the response. + CreationTime *date.Time `json:"creationTime,omitempty"` + // CreatedBy - createdBy property, which only appears in the response. + CreatedBy *string `json:"createdBy,omitempty"` + // LastModifiedTime - Last time resource was modified, which only appears in the response. + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + // LastModifiedBy - lastModifiedBy property, which only appears in the response. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` +} + +// SoftwareUpdateConfigurationRun software update configuration Run properties. +type SoftwareUpdateConfigurationRun struct { + autorest.Response `json:"-"` + // Name - Name of the software update configuration run. + Name *string `json:"name,omitempty"` + // ID - Resource Id of the software update configuration run + ID *string `json:"id,omitempty"` + // SoftwareUpdateConfigurationRunProperties - Software update configuration Run properties. + *SoftwareUpdateConfigurationRunProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for SoftwareUpdateConfigurationRun. +func (sucr SoftwareUpdateConfigurationRun) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sucr.Name != nil { + objectMap["name"] = sucr.Name + } + if sucr.ID != nil { + objectMap["id"] = sucr.ID + } + if sucr.SoftwareUpdateConfigurationRunProperties != nil { + objectMap["properties"] = sucr.SoftwareUpdateConfigurationRunProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SoftwareUpdateConfigurationRun struct. +func (sucr *SoftwareUpdateConfigurationRun) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sucr.Name = &name + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sucr.ID = &ID + } + case "properties": + if v != nil { + var softwareUpdateConfigurationRunProperties SoftwareUpdateConfigurationRunProperties + err = json.Unmarshal(*v, &softwareUpdateConfigurationRunProperties) + if err != nil { + return err + } + sucr.SoftwareUpdateConfigurationRunProperties = &softwareUpdateConfigurationRunProperties + } + } + } + + return nil +} + +// SoftwareUpdateConfigurationRunListResult result of listing all software update configuration runs +type SoftwareUpdateConfigurationRunListResult struct { + autorest.Response `json:"-"` + // Value - outer object returned when listing all software update configuration runs + Value *[]SoftwareUpdateConfigurationRun `json:"value,omitempty"` + // NextLink - link to next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// SoftwareUpdateConfigurationRunProperties software update configuration properties. +type SoftwareUpdateConfigurationRunProperties struct { + // SoftwareUpdateConfiguration - software update configuration triggered this run + SoftwareUpdateConfiguration *UpdateConfigurationNavigation `json:"softwareUpdateConfiguration,omitempty"` + // Status - Status of the software update configuration run. + Status *string `json:"status,omitempty"` + // ConfiguredDuration - configured duration for the software update configuration run. + ConfiguredDuration *string `json:"configuredDuration,omitempty"` + // OsType - Operating system target of the software update configuration triggered this run + OsType *string `json:"osType,omitempty"` + // StartTime - Etart time of the software update configuration run. + StartTime *date.Time `json:"startTime,omitempty"` + // EndTime - End time of the software update configuration run. + EndTime *date.Time `json:"endTime,omitempty"` + // ComputerCount - Number of computers in the software update configuration run. + ComputerCount *int32 `json:"computerCount,omitempty"` + // FailedCount - Number of computers with failed status. + FailedCount *int32 `json:"failedCount,omitempty"` + // CreationTime - Creation time of theresource, which only appears in the response. + CreationTime *date.Time `json:"creationTime,omitempty"` + // CreatedBy - createdBy property, which only appears in the response. + CreatedBy *string `json:"createdBy,omitempty"` + // LastModifiedTime - Last time resource was modified, which only appears in the response. + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + // LastModifiedBy - lastModifiedBy property, which only appears in the response. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` +} + +// SourceControl definition of the source control. +type SourceControl struct { + autorest.Response `json:"-"` + // SourceControlProperties - The properties of the source control. + *SourceControlProperties `json:"properties,omitempty"` + // ID - Fully qualified resource Id for the resource + ID *string `json:"id,omitempty"` + // Name - The name of the resource + Name *string `json:"name,omitempty"` + // Type - The type of the resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for SourceControl. +func (sc SourceControl) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sc.SourceControlProperties != nil { + objectMap["properties"] = sc.SourceControlProperties + } + if sc.ID != nil { + objectMap["id"] = sc.ID + } + if sc.Name != nil { + objectMap["name"] = sc.Name + } + if sc.Type != nil { + objectMap["type"] = sc.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SourceControl struct. +func (sc *SourceControl) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var sourceControlProperties SourceControlProperties + err = json.Unmarshal(*v, &sourceControlProperties) + if err != nil { + return err + } + sc.SourceControlProperties = &sourceControlProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sc.Type = &typeVar + } + } + } + + return nil +} + +// SourceControlCreateOrUpdateParameters the parameters supplied to the create or update source control operation. +type SourceControlCreateOrUpdateParameters struct { + // SourceControlCreateOrUpdateProperties - The properties of the source control. + *SourceControlCreateOrUpdateProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for SourceControlCreateOrUpdateParameters. +func (sccoup SourceControlCreateOrUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sccoup.SourceControlCreateOrUpdateProperties != nil { + objectMap["properties"] = sccoup.SourceControlCreateOrUpdateProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SourceControlCreateOrUpdateParameters struct. +func (sccoup *SourceControlCreateOrUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var sourceControlCreateOrUpdateProperties SourceControlCreateOrUpdateProperties + err = json.Unmarshal(*v, &sourceControlCreateOrUpdateProperties) + if err != nil { + return err + } + sccoup.SourceControlCreateOrUpdateProperties = &sourceControlCreateOrUpdateProperties + } + } + } + + return nil +} + +// SourceControlCreateOrUpdateProperties the properties of the create source control operation. +type SourceControlCreateOrUpdateProperties struct { + // RepoURL - The repo url of the source control. + RepoURL *string `json:"repoUrl,omitempty"` + // Branch - The repo branch of the source control. Include branch as empty string for VsoTfvc. + Branch *string `json:"branch,omitempty"` + // FolderPath - The folder path of the source control. Path must be relative. + FolderPath *string `json:"folderPath,omitempty"` + // AutoSync - The auto async of the source control. Default is false. + AutoSync *bool `json:"autoSync,omitempty"` + // PublishRunbook - The auto publish of the source control. Default is true. + PublishRunbook *bool `json:"publishRunbook,omitempty"` + // SourceType - The source type. Must be one of VsoGit, VsoTfvc, GitHub, case sensitive. Possible values include: 'VsoGit', 'VsoTfvc', 'GitHub' + SourceType SourceType `json:"sourceType,omitempty"` + // SecurityToken - The authorization token for the repo of the source control. + SecurityToken *SourceControlSecurityTokenProperties `json:"securityToken,omitempty"` + // Description - The user description of the source control. + Description *string `json:"description,omitempty"` +} + +// SourceControlListResult the response model for the list source controls operation. +type SourceControlListResult struct { + autorest.Response `json:"-"` + // Value - The list of souce controls. + Value *[]SourceControl `json:"value,omitempty"` + // NextLink - The next link. + NextLink *string `json:"nextLink,omitempty"` +} + +// SourceControlListResultIterator provides access to a complete listing of SourceControl values. +type SourceControlListResultIterator struct { + i int + page SourceControlListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *SourceControlListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter SourceControlListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter SourceControlListResultIterator) Response() SourceControlListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter SourceControlListResultIterator) Value() SourceControl { + if !iter.page.NotDone() { + return SourceControl{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (sclr SourceControlListResult) IsEmpty() bool { + return sclr.Value == nil || len(*sclr.Value) == 0 +} + +// sourceControlListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sclr SourceControlListResult) sourceControlListResultPreparer() (*http.Request, error) { + if sclr.NextLink == nil || len(to.String(sclr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sclr.NextLink))) +} + +// SourceControlListResultPage contains a page of SourceControl values. +type SourceControlListResultPage struct { + fn func(SourceControlListResult) (SourceControlListResult, error) + sclr SourceControlListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *SourceControlListResultPage) Next() error { + next, err := page.fn(page.sclr) + if err != nil { + return err + } + page.sclr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page SourceControlListResultPage) NotDone() bool { + return !page.sclr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page SourceControlListResultPage) Response() SourceControlListResult { + return page.sclr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page SourceControlListResultPage) Values() []SourceControl { + if page.sclr.IsEmpty() { + return nil + } + return *page.sclr.Value +} + +// SourceControlProperties definition of the source control properties +type SourceControlProperties struct { + // RepoURL - The repo url of the source control. + RepoURL *string `json:"repoUrl,omitempty"` + // Branch - The repo branch of the source control. Include branch as empty string for VsoTfvc. + Branch *string `json:"branch,omitempty"` + // FolderPath - The folder path of the source control. + FolderPath *string `json:"folderPath,omitempty"` + // AutoSync - The auto sync of the source control. Default is false. + AutoSync *bool `json:"autoSync,omitempty"` + // PublishRunbook - The auto publish of the source control. Default is true. + PublishRunbook *bool `json:"publishRunbook,omitempty"` + // SourceType - The source type. Must be one of VsoGit, VsoTfvc, GitHub. Possible values include: 'VsoGit', 'VsoTfvc', 'GitHub' + SourceType SourceType `json:"sourceType,omitempty"` + // Description - The description. + Description *string `json:"description,omitempty"` + // CreationTime - The creation time. + CreationTime *date.Time `json:"creationTime,omitempty"` + // LastModifiedTime - The last modified time. + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` +} + +// SourceControlSecurityTokenProperties ... +type SourceControlSecurityTokenProperties struct { + // AccessToken - The access token. + AccessToken *string `json:"accessToken,omitempty"` + // RefreshToken - The refresh token. + RefreshToken *string `json:"refreshToken,omitempty"` + // TokenType - The token type. Must be either PersonalAccessToken or Oauth. Possible values include: 'PersonalAccessToken', 'Oauth' + TokenType TokenType `json:"tokenType,omitempty"` +} + +// SourceControlSyncJob definition of the source control sync job. +type SourceControlSyncJob struct { + autorest.Response `json:"-"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` + // ID - Resource id. + ID *string `json:"id,omitempty"` + // SourceControlSyncJobProperties - The properties of the source control sync job. + *SourceControlSyncJobProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for SourceControlSyncJob. +func (scsj SourceControlSyncJob) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if scsj.Name != nil { + objectMap["name"] = scsj.Name + } + if scsj.Type != nil { + objectMap["type"] = scsj.Type + } + if scsj.ID != nil { + objectMap["id"] = scsj.ID + } + if scsj.SourceControlSyncJobProperties != nil { + objectMap["properties"] = scsj.SourceControlSyncJobProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SourceControlSyncJob struct. +func (scsj *SourceControlSyncJob) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + scsj.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + scsj.Type = &typeVar + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + scsj.ID = &ID + } + case "properties": + if v != nil { + var sourceControlSyncJobProperties SourceControlSyncJobProperties + err = json.Unmarshal(*v, &sourceControlSyncJobProperties) + if err != nil { + return err + } + scsj.SourceControlSyncJobProperties = &sourceControlSyncJobProperties + } + } + } + + return nil +} + +// SourceControlSyncJobByID definition of the source control sync job. +type SourceControlSyncJobByID struct { + autorest.Response `json:"-"` + // ID - The id of the job. + ID *string `json:"id,omitempty"` + // SourceControlSyncJobByIDProperties - The properties of the source control sync job. + *SourceControlSyncJobByIDProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for SourceControlSyncJobByID. +func (scsjbi SourceControlSyncJobByID) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if scsjbi.ID != nil { + objectMap["id"] = scsjbi.ID + } + if scsjbi.SourceControlSyncJobByIDProperties != nil { + objectMap["properties"] = scsjbi.SourceControlSyncJobByIDProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SourceControlSyncJobByID struct. +func (scsjbi *SourceControlSyncJobByID) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + scsjbi.ID = &ID + } + case "properties": + if v != nil { + var sourceControlSyncJobByIDProperties SourceControlSyncJobByIDProperties + err = json.Unmarshal(*v, &sourceControlSyncJobByIDProperties) + if err != nil { + return err + } + scsjbi.SourceControlSyncJobByIDProperties = &sourceControlSyncJobByIDProperties + } + } + } + + return nil +} + +// SourceControlSyncJobByIDProperties definition of source control sync job properties. +type SourceControlSyncJobByIDProperties struct { + // SourceControlSyncJobID - The source control sync job id. + SourceControlSyncJobID *string `json:"sourceControlSyncJobId,omitempty"` + // CreationTime - The creation time of the job. + CreationTime *date.Time `json:"creationTime,omitempty"` + // ProvisioningState - The provisioning state of the job. Possible values include: 'Completed', 'Failed', 'Running' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + // StartTime - The start time of the job. + StartTime *date.Time `json:"startTime,omitempty"` + // EndTime - The end time of the job. + EndTime *date.Time `json:"endTime,omitempty"` + // SyncType - The sync type. Possible values include: 'PartialSync', 'FullSync' + SyncType SyncType `json:"syncType,omitempty"` + // Exception - The exceptions that occured while running the sync job. + Exception *string `json:"exception,omitempty"` +} + +// SourceControlSyncJobCreateParameters the parameters supplied to the create source control sync job operation. +type SourceControlSyncJobCreateParameters struct { + // SourceControlSyncJobCreateProperties - The properties of the source control sync job. + *SourceControlSyncJobCreateProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for SourceControlSyncJobCreateParameters. +func (scsjcp SourceControlSyncJobCreateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if scsjcp.SourceControlSyncJobCreateProperties != nil { + objectMap["properties"] = scsjcp.SourceControlSyncJobCreateProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SourceControlSyncJobCreateParameters struct. +func (scsjcp *SourceControlSyncJobCreateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var sourceControlSyncJobCreateProperties SourceControlSyncJobCreateProperties + err = json.Unmarshal(*v, &sourceControlSyncJobCreateProperties) + if err != nil { + return err + } + scsjcp.SourceControlSyncJobCreateProperties = &sourceControlSyncJobCreateProperties + } + } + } + + return nil +} + +// SourceControlSyncJobCreateProperties definition of create source control sync job properties. +type SourceControlSyncJobCreateProperties struct { + // CommitID - The commit id of the source control sync job. If not syncing to a commitId, enter an empty string. + CommitID *string `json:"commitId,omitempty"` +} + +// SourceControlSyncJobListResult the response model for the list source control sync jobs operation. +type SourceControlSyncJobListResult struct { + autorest.Response `json:"-"` + // Value - The list of source control sync jobs. + Value *[]SourceControlSyncJob `json:"value,omitempty"` + // NextLink - The next link. + NextLink *string `json:"nextLink,omitempty"` +} + +// SourceControlSyncJobListResultIterator provides access to a complete listing of SourceControlSyncJob values. +type SourceControlSyncJobListResultIterator struct { + i int + page SourceControlSyncJobListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *SourceControlSyncJobListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter SourceControlSyncJobListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter SourceControlSyncJobListResultIterator) Response() SourceControlSyncJobListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter SourceControlSyncJobListResultIterator) Value() SourceControlSyncJob { + if !iter.page.NotDone() { + return SourceControlSyncJob{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (scsjlr SourceControlSyncJobListResult) IsEmpty() bool { + return scsjlr.Value == nil || len(*scsjlr.Value) == 0 +} + +// sourceControlSyncJobListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (scsjlr SourceControlSyncJobListResult) sourceControlSyncJobListResultPreparer() (*http.Request, error) { + if scsjlr.NextLink == nil || len(to.String(scsjlr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(scsjlr.NextLink))) +} + +// SourceControlSyncJobListResultPage contains a page of SourceControlSyncJob values. +type SourceControlSyncJobListResultPage struct { + fn func(SourceControlSyncJobListResult) (SourceControlSyncJobListResult, error) + scsjlr SourceControlSyncJobListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *SourceControlSyncJobListResultPage) Next() error { + next, err := page.fn(page.scsjlr) + if err != nil { + return err + } + page.scsjlr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page SourceControlSyncJobListResultPage) NotDone() bool { + return !page.scsjlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page SourceControlSyncJobListResultPage) Response() SourceControlSyncJobListResult { + return page.scsjlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page SourceControlSyncJobListResultPage) Values() []SourceControlSyncJob { + if page.scsjlr.IsEmpty() { + return nil + } + return *page.scsjlr.Value +} + +// SourceControlSyncJobProperties definition of source control sync job properties. +type SourceControlSyncJobProperties struct { + // SourceControlSyncJobID - The source control sync job id. + SourceControlSyncJobID *string `json:"sourceControlSyncJobId,omitempty"` + // CreationTime - The creation time of the job. + CreationTime *date.Time `json:"creationTime,omitempty"` + // ProvisioningState - The provisioning state of the job. Possible values include: 'Completed', 'Failed', 'Running' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + // StartTime - The start time of the job. + StartTime *date.Time `json:"startTime,omitempty"` + // EndTime - The end time of the job. + EndTime *date.Time `json:"endTime,omitempty"` + // SyncType - The sync type. Possible values include: 'PartialSync', 'FullSync' + SyncType SyncType `json:"syncType,omitempty"` +} + +// SourceControlSyncJobStream definition of the source control sync job stream. +type SourceControlSyncJobStream struct { + // ID - Resource id. + ID *string `json:"id,omitempty"` + // SourceControlSyncJobStreamProperties - The properties of the source control sync job stream. + *SourceControlSyncJobStreamProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for SourceControlSyncJobStream. +func (scsjs SourceControlSyncJobStream) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if scsjs.ID != nil { + objectMap["id"] = scsjs.ID + } + if scsjs.SourceControlSyncJobStreamProperties != nil { + objectMap["properties"] = scsjs.SourceControlSyncJobStreamProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SourceControlSyncJobStream struct. +func (scsjs *SourceControlSyncJobStream) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + scsjs.ID = &ID + } + case "properties": + if v != nil { + var sourceControlSyncJobStreamProperties SourceControlSyncJobStreamProperties + err = json.Unmarshal(*v, &sourceControlSyncJobStreamProperties) + if err != nil { + return err + } + scsjs.SourceControlSyncJobStreamProperties = &sourceControlSyncJobStreamProperties + } + } + } + + return nil +} + +// SourceControlSyncJobStreamByID definition of the source control sync job stream by id. +type SourceControlSyncJobStreamByID struct { + autorest.Response `json:"-"` + // ID - Resource id. + ID *string `json:"id,omitempty"` + // SourceControlSyncJobStreamByIDProperties - The properties of the source control sync job stream. + *SourceControlSyncJobStreamByIDProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for SourceControlSyncJobStreamByID. +func (scsjsbi SourceControlSyncJobStreamByID) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if scsjsbi.ID != nil { + objectMap["id"] = scsjsbi.ID + } + if scsjsbi.SourceControlSyncJobStreamByIDProperties != nil { + objectMap["properties"] = scsjsbi.SourceControlSyncJobStreamByIDProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SourceControlSyncJobStreamByID struct. +func (scsjsbi *SourceControlSyncJobStreamByID) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + scsjsbi.ID = &ID + } + case "properties": + if v != nil { + var sourceControlSyncJobStreamByIDProperties SourceControlSyncJobStreamByIDProperties + err = json.Unmarshal(*v, &sourceControlSyncJobStreamByIDProperties) + if err != nil { + return err + } + scsjsbi.SourceControlSyncJobStreamByIDProperties = &sourceControlSyncJobStreamByIDProperties + } + } + } + + return nil +} + +// SourceControlSyncJobStreamByIDProperties definition of source control sync job stream by id properties. +type SourceControlSyncJobStreamByIDProperties struct { + // SourceControlSyncJobStreamID - The sync job stream id. + SourceControlSyncJobStreamID *string `json:"sourceControlSyncJobStreamId,omitempty"` + // Summary - The summary of the sync job stream. + Summary *string `json:"summary,omitempty"` + // Time - The time of the sync job stream. + Time *date.Time `json:"time,omitempty"` + // StreamType - The type of the sync job stream. Possible values include: 'StreamTypeError', 'StreamTypeOutput' + StreamType StreamType `json:"streamType,omitempty"` + // StreamText - The text of the sync job stream. + StreamText *string `json:"streamText,omitempty"` + // Value - The values of the job stream. + Value map[string]interface{} `json:"value"` +} + +// MarshalJSON is the custom marshaler for SourceControlSyncJobStreamByIDProperties. +func (scsjsbip SourceControlSyncJobStreamByIDProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if scsjsbip.SourceControlSyncJobStreamID != nil { + objectMap["sourceControlSyncJobStreamId"] = scsjsbip.SourceControlSyncJobStreamID + } + if scsjsbip.Summary != nil { + objectMap["summary"] = scsjsbip.Summary + } + if scsjsbip.Time != nil { + objectMap["time"] = scsjsbip.Time + } + if scsjsbip.StreamType != "" { + objectMap["streamType"] = scsjsbip.StreamType + } + if scsjsbip.StreamText != nil { + objectMap["streamText"] = scsjsbip.StreamText + } + if scsjsbip.Value != nil { + objectMap["value"] = scsjsbip.Value + } + return json.Marshal(objectMap) +} + +// SourceControlSyncJobStreamProperties definition of source control sync job stream properties. +type SourceControlSyncJobStreamProperties struct { + // SourceControlSyncJobStreamID - The sync job stream id. + SourceControlSyncJobStreamID *string `json:"sourceControlSyncJobStreamId,omitempty"` + // Summary - The summary of the sync job stream. + Summary *string `json:"summary,omitempty"` + // Time - The time of the sync job stream. + Time *date.Time `json:"time,omitempty"` + // StreamType - The type of the sync job stream. Possible values include: 'StreamTypeError', 'StreamTypeOutput' + StreamType StreamType `json:"streamType,omitempty"` +} + +// SourceControlSyncJobStreamsListBySyncJob the response model for the list source control sync job streams +// operation. +type SourceControlSyncJobStreamsListBySyncJob struct { + autorest.Response `json:"-"` + // Value - The list of source control sync job streams. + Value *[]SourceControlSyncJobStream `json:"value,omitempty"` + // NextLink - The next link. + NextLink *string `json:"nextLink,omitempty"` +} + +// SourceControlSyncJobStreamsListBySyncJobIterator provides access to a complete listing of +// SourceControlSyncJobStream values. +type SourceControlSyncJobStreamsListBySyncJobIterator struct { + i int + page SourceControlSyncJobStreamsListBySyncJobPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *SourceControlSyncJobStreamsListBySyncJobIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter SourceControlSyncJobStreamsListBySyncJobIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter SourceControlSyncJobStreamsListBySyncJobIterator) Response() SourceControlSyncJobStreamsListBySyncJob { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter SourceControlSyncJobStreamsListBySyncJobIterator) Value() SourceControlSyncJobStream { + if !iter.page.NotDone() { + return SourceControlSyncJobStream{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (scsjslbsj SourceControlSyncJobStreamsListBySyncJob) IsEmpty() bool { + return scsjslbsj.Value == nil || len(*scsjslbsj.Value) == 0 +} + +// sourceControlSyncJobStreamsListBySyncJobPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (scsjslbsj SourceControlSyncJobStreamsListBySyncJob) sourceControlSyncJobStreamsListBySyncJobPreparer() (*http.Request, error) { + if scsjslbsj.NextLink == nil || len(to.String(scsjslbsj.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(scsjslbsj.NextLink))) +} + +// SourceControlSyncJobStreamsListBySyncJobPage contains a page of SourceControlSyncJobStream values. +type SourceControlSyncJobStreamsListBySyncJobPage struct { + fn func(SourceControlSyncJobStreamsListBySyncJob) (SourceControlSyncJobStreamsListBySyncJob, error) + scsjslbsj SourceControlSyncJobStreamsListBySyncJob +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *SourceControlSyncJobStreamsListBySyncJobPage) Next() error { + next, err := page.fn(page.scsjslbsj) + if err != nil { + return err + } + page.scsjslbsj = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page SourceControlSyncJobStreamsListBySyncJobPage) NotDone() bool { + return !page.scsjslbsj.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page SourceControlSyncJobStreamsListBySyncJobPage) Response() SourceControlSyncJobStreamsListBySyncJob { + return page.scsjslbsj +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page SourceControlSyncJobStreamsListBySyncJobPage) Values() []SourceControlSyncJobStream { + if page.scsjslbsj.IsEmpty() { + return nil + } + return *page.scsjslbsj.Value +} + +// SourceControlUpdateParameters the parameters supplied to the update source control operation. +type SourceControlUpdateParameters struct { + // SourceControlUpdateProperties - The value of the source control. + *SourceControlUpdateProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for SourceControlUpdateParameters. +func (scup SourceControlUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if scup.SourceControlUpdateProperties != nil { + objectMap["properties"] = scup.SourceControlUpdateProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SourceControlUpdateParameters struct. +func (scup *SourceControlUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var sourceControlUpdateProperties SourceControlUpdateProperties + err = json.Unmarshal(*v, &sourceControlUpdateProperties) + if err != nil { + return err + } + scup.SourceControlUpdateProperties = &sourceControlUpdateProperties + } + } + } + + return nil +} + +// SourceControlUpdateProperties the properties of the update source control +type SourceControlUpdateProperties struct { + // Branch - The repo branch of the source control. + Branch *string `json:"branch,omitempty"` + // FolderPath - The folder path of the source control. Path must be relative. + FolderPath *string `json:"folderPath,omitempty"` + // AutoSync - The auto sync of the source control. Default is false. + AutoSync *bool `json:"autoSync,omitempty"` + // PublishRunbook - The auto publish of the source control. Default is true. + PublishRunbook *bool `json:"publishRunbook,omitempty"` + // SecurityToken - The authorization token for the repo of the source control. + SecurityToken *SourceControlSecurityTokenProperties `json:"securityToken,omitempty"` + // Description - The user description of the source control. + Description *string `json:"description,omitempty"` +} + +// Statistics definition of the statistic. +type Statistics struct { + // CounterProperty - Gets the property value of the statistic. + CounterProperty *string `json:"counterProperty,omitempty"` + // CounterValue - Gets the value of the statistic. + CounterValue *int64 `json:"counterValue,omitempty"` + // StartTime - Gets the startTime of the statistic. + StartTime *date.Time `json:"startTime,omitempty"` + // EndTime - Gets the endTime of the statistic. + EndTime *date.Time `json:"endTime,omitempty"` + // ID - Gets the id. + ID *string `json:"id,omitempty"` +} + +// StatisticsListResult the response model for the list statistics operation. +type StatisticsListResult struct { + autorest.Response `json:"-"` + // Value - Gets or sets a list of statistics. + Value *[]Statistics `json:"value,omitempty"` +} + +// String ... +type String struct { + autorest.Response `json:"-"` + Value *string `json:"value,omitempty"` +} + +// TagSettingsProperties tag filter information for the VM. +type TagSettingsProperties struct { + // Tags - Dictionary of tags with its list of values. + Tags map[string][]string `json:"tags"` + // FilterOperator - Filter VMs by Any or All specified tags. Possible values include: 'TagOperatorsAll', 'TagOperatorsAny' + FilterOperator TagOperators `json:"filterOperator,omitempty"` +} + +// MarshalJSON is the custom marshaler for TagSettingsProperties. +func (tsp TagSettingsProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tsp.Tags != nil { + objectMap["tags"] = tsp.Tags + } + if tsp.FilterOperator != "" { + objectMap["filterOperator"] = tsp.FilterOperator + } + return json.Marshal(objectMap) +} + +// TargetProperties group specific to the update configuration. +type TargetProperties struct { + // AzureQueries - List of Azure queries in the software update configuration. + AzureQueries *[]AzureQueryProperties `json:"azureQueries,omitempty"` +} + +// TestJob definition of the test job. +type TestJob struct { + autorest.Response `json:"-"` + // CreationTime - Gets or sets the creation time of the test job. + CreationTime *date.Time `json:"creationTime,omitempty"` + // Status - Gets or sets the status of the test job. + Status *string `json:"status,omitempty"` + // StatusDetails - Gets or sets the status details of the test job. + StatusDetails *string `json:"statusDetails,omitempty"` + // RunOn - Gets or sets the runOn which specifies the group name where the job is to be executed. + RunOn *string `json:"runOn,omitempty"` + // StartTime - Gets or sets the start time of the test job. + StartTime *date.Time `json:"startTime,omitempty"` + // EndTime - Gets or sets the end time of the test job. + EndTime *date.Time `json:"endTime,omitempty"` + // Exception - Gets or sets the exception of the test job. + Exception *string `json:"exception,omitempty"` + // LastModifiedTime - Gets or sets the last modified time of the test job. + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + // LastStatusModifiedTime - Gets or sets the last status modified time of the test job. + LastStatusModifiedTime *date.Time `json:"lastStatusModifiedTime,omitempty"` + // Parameters - Gets or sets the parameters of the test job. + Parameters map[string]*string `json:"parameters"` + // LogActivityTrace - The activity-level tracing options of the runbook. + LogActivityTrace *int32 `json:"logActivityTrace,omitempty"` +} + +// MarshalJSON is the custom marshaler for TestJob. +func (tj TestJob) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tj.CreationTime != nil { + objectMap["creationTime"] = tj.CreationTime + } + if tj.Status != nil { + objectMap["status"] = tj.Status + } + if tj.StatusDetails != nil { + objectMap["statusDetails"] = tj.StatusDetails + } + if tj.RunOn != nil { + objectMap["runOn"] = tj.RunOn + } + if tj.StartTime != nil { + objectMap["startTime"] = tj.StartTime + } + if tj.EndTime != nil { + objectMap["endTime"] = tj.EndTime + } + if tj.Exception != nil { + objectMap["exception"] = tj.Exception + } + if tj.LastModifiedTime != nil { + objectMap["lastModifiedTime"] = tj.LastModifiedTime + } + if tj.LastStatusModifiedTime != nil { + objectMap["lastStatusModifiedTime"] = tj.LastStatusModifiedTime + } + if tj.Parameters != nil { + objectMap["parameters"] = tj.Parameters + } + if tj.LogActivityTrace != nil { + objectMap["logActivityTrace"] = tj.LogActivityTrace + } + return json.Marshal(objectMap) +} + +// TestJobCreateParameters the parameters supplied to the create test job operation. +type TestJobCreateParameters struct { + // Parameters - Gets or sets the parameters of the test job. + Parameters map[string]*string `json:"parameters"` + // RunOn - Gets or sets the runOn which specifies the group name where the job is to be executed. + RunOn *string `json:"runOn,omitempty"` +} + +// MarshalJSON is the custom marshaler for TestJobCreateParameters. +func (tjcp TestJobCreateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tjcp.Parameters != nil { + objectMap["parameters"] = tjcp.Parameters + } + if tjcp.RunOn != nil { + objectMap["runOn"] = tjcp.RunOn + } + return json.Marshal(objectMap) +} + +// TrackedResource the resource model definition for a ARM tracked top level resource +type TrackedResource struct { + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The Azure Region where the resource lives + Location *string `json:"location,omitempty"` + // ID - Fully qualified resource Id for the resource + ID *string `json:"id,omitempty"` + // Name - The name of the resource + Name *string `json:"name,omitempty"` + // Type - The type of the resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for TrackedResource. +func (tr TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tr.Tags != nil { + objectMap["tags"] = tr.Tags + } + if tr.Location != nil { + objectMap["location"] = tr.Location + } + if tr.ID != nil { + objectMap["id"] = tr.ID + } + if tr.Name != nil { + objectMap["name"] = tr.Name + } + if tr.Type != nil { + objectMap["type"] = tr.Type + } + return json.Marshal(objectMap) +} + +// TypeField information about a field of a type. +type TypeField struct { + // Name - Gets or sets the name of the field. + Name *string `json:"name,omitempty"` + // Type - Gets or sets the type of the field. + Type *string `json:"type,omitempty"` +} + +// TypeFieldListResult the response model for the list fields operation. +type TypeFieldListResult struct { + autorest.Response `json:"-"` + // Value - Gets or sets a list of fields. + Value *[]TypeField `json:"value,omitempty"` +} + +// UpdateConfiguration update specifc properties of the software update configuration. +type UpdateConfiguration struct { + // OperatingSystem - operating system of target machines. Possible values include: 'Windows', 'Linux' + OperatingSystem OperatingSystemType `json:"operatingSystem,omitempty"` + // Windows - Windows specific update configuration. + Windows *WindowsProperties `json:"windows,omitempty"` + // Linux - Linux specific update configuration. + Linux *LinuxProperties `json:"linux,omitempty"` + // Duration - Maximum time allowed for the software update configuration run. Duration needs to be specified using the format PT[n]H[n]M[n]S as per ISO8601 + Duration *string `json:"duration,omitempty"` + // AzureVirtualMachines - List of azure resource Ids for azure virtual machines targeted by the software update configuration. + AzureVirtualMachines *[]string `json:"azureVirtualMachines,omitempty"` + // NonAzureComputerNames - List of names of non-azure machines targeted by the software update configuration. + NonAzureComputerNames *[]string `json:"nonAzureComputerNames,omitempty"` + // Targets - Group targets for the software update configuration. + Targets *TargetProperties `json:"targets,omitempty"` +} + +// UpdateConfigurationMachineRunProperties software update configuration machine run properties. +type UpdateConfigurationMachineRunProperties struct { + // TargetComputer - name of the updated computer + TargetComputer *string `json:"targetComputer,omitempty"` + // TargetComputerType - type of the updated computer. + TargetComputerType *string `json:"targetComputerType,omitempty"` + // SoftwareUpdateConfiguration - software update configuration triggered this run + SoftwareUpdateConfiguration *UpdateConfigurationNavigation `json:"softwareUpdateConfiguration,omitempty"` + // Status - Status of the software update configuration machine run. + Status *string `json:"status,omitempty"` + // OsType - Operating system target of the software update configuration triggered this run + OsType *string `json:"osType,omitempty"` + // CorrelationID - correlation id of the software update configuration machine run + CorrelationID *uuid.UUID `json:"correlationId,omitempty"` + // SourceComputerID - source computer id of the software update configuration machine run + SourceComputerID *uuid.UUID `json:"sourceComputerId,omitempty"` + // StartTime - Start time of the software update configuration machine run. + StartTime *date.Time `json:"startTime,omitempty"` + // EndTime - End time of the software update configuration machine run. + EndTime *date.Time `json:"endTime,omitempty"` + // ConfiguredDuration - configured duration for the software update configuration run. + ConfiguredDuration *string `json:"configuredDuration,omitempty"` + // Job - Job associated with the software update configuration machine run + Job *JobNavigation `json:"job,omitempty"` + // CreationTime - Creation time of theresource, which only appears in the response. + CreationTime *date.Time `json:"creationTime,omitempty"` + // CreatedBy - createdBy property, which only appears in the response. + CreatedBy *string `json:"createdBy,omitempty"` + // LastModifiedTime - Last time resource was modified, which only appears in the response. + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + // LastModifiedBy - lastModifiedBy property, which only appears in the response. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` +} + +// UpdateConfigurationNavigation software update configuration Run Navigation model. +type UpdateConfigurationNavigation struct { + // Name - Name of the software update configuration triggered the software update configuration run + Name *string `json:"name,omitempty"` +} + +// Usage definition of Usage. +type Usage struct { + // ID - Gets or sets the id of the resource. + ID *string `json:"id,omitempty"` + // Name - Gets or sets the usage counter name. + Name *UsageCounterName `json:"name,omitempty"` + // Unit - Gets or sets the usage unit name. + Unit *string `json:"unit,omitempty"` + // CurrentValue - Gets or sets the current usage value. + CurrentValue *float64 `json:"currentValue,omitempty"` + // Limit - Gets or sets max limit. -1 for unlimited + Limit *int64 `json:"limit,omitempty"` + // ThrottleStatus - Gets or sets the throttle status. + ThrottleStatus *string `json:"throttleStatus,omitempty"` +} + +// UsageCounterName definition of usage counter name. +type UsageCounterName struct { + // Value - Gets or sets the usage counter name. + Value *string `json:"value,omitempty"` + // LocalizedValue - Gets or sets the localized usage counter name. + LocalizedValue *string `json:"localizedValue,omitempty"` +} + +// UsageListResult the response model for the get usage operation. +type UsageListResult struct { + autorest.Response `json:"-"` + // Value - Gets or sets usage. + Value *[]Usage `json:"value,omitempty"` +} + +// Variable definition of the varible. +type Variable struct { + autorest.Response `json:"-"` + // VariableProperties - Gets or sets the properties of the variable. + *VariableProperties `json:"properties,omitempty"` + // ID - Fully qualified resource Id for the resource + ID *string `json:"id,omitempty"` + // Name - The name of the resource + Name *string `json:"name,omitempty"` + // Type - The type of the resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Variable. +func (vVar Variable) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if vVar.VariableProperties != nil { + objectMap["properties"] = vVar.VariableProperties + } + if vVar.ID != nil { + objectMap["id"] = vVar.ID + } + if vVar.Name != nil { + objectMap["name"] = vVar.Name + } + if vVar.Type != nil { + objectMap["type"] = vVar.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Variable struct. +func (vVar *Variable) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var variableProperties VariableProperties + err = json.Unmarshal(*v, &variableProperties) + if err != nil { + return err + } + vVar.VariableProperties = &variableProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + vVar.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + vVar.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + vVar.Type = &typeVar + } + } + } + + return nil +} + +// VariableCreateOrUpdateParameters the parameters supplied to the create or update variable operation. +type VariableCreateOrUpdateParameters struct { + // Name - Gets or sets the name of the variable. + Name *string `json:"name,omitempty"` + // VariableCreateOrUpdateProperties - Gets or sets the properties of the variable. + *VariableCreateOrUpdateProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for VariableCreateOrUpdateParameters. +func (vcoup VariableCreateOrUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if vcoup.Name != nil { + objectMap["name"] = vcoup.Name + } + if vcoup.VariableCreateOrUpdateProperties != nil { + objectMap["properties"] = vcoup.VariableCreateOrUpdateProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for VariableCreateOrUpdateParameters struct. +func (vcoup *VariableCreateOrUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + vcoup.Name = &name + } + case "properties": + if v != nil { + var variableCreateOrUpdateProperties VariableCreateOrUpdateProperties + err = json.Unmarshal(*v, &variableCreateOrUpdateProperties) + if err != nil { + return err + } + vcoup.VariableCreateOrUpdateProperties = &variableCreateOrUpdateProperties + } + } + } + + return nil +} + +// VariableCreateOrUpdateProperties the properties of the create variable operation. +type VariableCreateOrUpdateProperties struct { + // Value - Gets or sets the value of the variable. + Value *string `json:"value,omitempty"` + // Description - Gets or sets the description of the variable. + Description *string `json:"description,omitempty"` + // IsEncrypted - Gets or sets the encrypted flag of the variable. + IsEncrypted *bool `json:"isEncrypted,omitempty"` +} + +// VariableListResult the response model for the list variables operation. +type VariableListResult struct { + autorest.Response `json:"-"` + // Value - Gets or sets a list of variables. + Value *[]Variable `json:"value,omitempty"` + // NextLink - Gets or sets the next link. + NextLink *string `json:"nextLink,omitempty"` +} + +// VariableListResultIterator provides access to a complete listing of Variable values. +type VariableListResultIterator struct { + i int + page VariableListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *VariableListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter VariableListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter VariableListResultIterator) Response() VariableListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter VariableListResultIterator) Value() Variable { + if !iter.page.NotDone() { + return Variable{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (vlr VariableListResult) IsEmpty() bool { + return vlr.Value == nil || len(*vlr.Value) == 0 +} + +// variableListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (vlr VariableListResult) variableListResultPreparer() (*http.Request, error) { + if vlr.NextLink == nil || len(to.String(vlr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(vlr.NextLink))) +} + +// VariableListResultPage contains a page of Variable values. +type VariableListResultPage struct { + fn func(VariableListResult) (VariableListResult, error) + vlr VariableListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *VariableListResultPage) Next() error { + next, err := page.fn(page.vlr) + if err != nil { + return err + } + page.vlr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page VariableListResultPage) NotDone() bool { + return !page.vlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page VariableListResultPage) Response() VariableListResult { + return page.vlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page VariableListResultPage) Values() []Variable { + if page.vlr.IsEmpty() { + return nil + } + return *page.vlr.Value +} + +// VariableProperties definition of the varible properties +type VariableProperties struct { + // Value - Gets or sets the value of the variable. + Value *string `json:"value,omitempty"` + // IsEncrypted - Gets or sets the encrypted flag of the variable. + IsEncrypted *bool `json:"isEncrypted,omitempty"` + // CreationTime - Gets or sets the creation time. + CreationTime *date.Time `json:"creationTime,omitempty"` + // LastModifiedTime - Gets or sets the last modified time. + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + // Description - Gets or sets the description. + Description *string `json:"description,omitempty"` +} + +// VariableUpdateParameters the parameters supplied to the update variable operation. +type VariableUpdateParameters struct { + // Name - Gets or sets the name of the variable. + Name *string `json:"name,omitempty"` + // VariableUpdateProperties - Gets or sets the value of the variable. + *VariableUpdateProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for VariableUpdateParameters. +func (vup VariableUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if vup.Name != nil { + objectMap["name"] = vup.Name + } + if vup.VariableUpdateProperties != nil { + objectMap["properties"] = vup.VariableUpdateProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for VariableUpdateParameters struct. +func (vup *VariableUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + vup.Name = &name + } + case "properties": + if v != nil { + var variableUpdateProperties VariableUpdateProperties + err = json.Unmarshal(*v, &variableUpdateProperties) + if err != nil { + return err + } + vup.VariableUpdateProperties = &variableUpdateProperties + } + } + } + + return nil +} + +// VariableUpdateProperties the properties of the update variable +type VariableUpdateProperties struct { + // Value - Gets or sets the value of the variable. + Value *string `json:"value,omitempty"` + // Description - Gets or sets the description of the variable. + Description *string `json:"description,omitempty"` +} + +// Watcher definition of the watcher type. +type Watcher struct { + autorest.Response `json:"-"` + // WatcherProperties - Gets or sets the watcher properties. + *WatcherProperties `json:"properties,omitempty"` + // Etag - Gets or sets the etag of the resource. + Etag *string `json:"etag,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The Azure Region where the resource lives + Location *string `json:"location,omitempty"` + // ID - Fully qualified resource Id for the resource + ID *string `json:"id,omitempty"` + // Name - The name of the resource + Name *string `json:"name,omitempty"` + // Type - The type of the resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Watcher. +func (w Watcher) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if w.WatcherProperties != nil { + objectMap["properties"] = w.WatcherProperties + } + if w.Etag != nil { + objectMap["etag"] = w.Etag + } + if w.Tags != nil { + objectMap["tags"] = w.Tags + } + if w.Location != nil { + objectMap["location"] = w.Location + } + if w.ID != nil { + objectMap["id"] = w.ID + } + if w.Name != nil { + objectMap["name"] = w.Name + } + if w.Type != nil { + objectMap["type"] = w.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Watcher struct. +func (w *Watcher) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var watcherProperties WatcherProperties + err = json.Unmarshal(*v, &watcherProperties) + if err != nil { + return err + } + w.WatcherProperties = &watcherProperties + } + case "etag": + if v != nil { + var etag string + err = json.Unmarshal(*v, &etag) + if err != nil { + return err + } + w.Etag = &etag + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + w.Tags = tags + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + w.Location = &location + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + w.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + w.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + w.Type = &typeVar + } + } + } + + return nil +} + +// WatcherListResult the response model for the list watcher operation. +type WatcherListResult struct { + autorest.Response `json:"-"` + // Value - Gets or sets a list of watchers. + Value *[]Watcher `json:"value,omitempty"` + // NextLink - Gets or sets the next link. + NextLink *string `json:"nextLink,omitempty"` +} + +// WatcherListResultIterator provides access to a complete listing of Watcher values. +type WatcherListResultIterator struct { + i int + page WatcherListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *WatcherListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter WatcherListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter WatcherListResultIterator) Response() WatcherListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter WatcherListResultIterator) Value() Watcher { + if !iter.page.NotDone() { + return Watcher{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (wlr WatcherListResult) IsEmpty() bool { + return wlr.Value == nil || len(*wlr.Value) == 0 +} + +// watcherListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (wlr WatcherListResult) watcherListResultPreparer() (*http.Request, error) { + if wlr.NextLink == nil || len(to.String(wlr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(wlr.NextLink))) +} + +// WatcherListResultPage contains a page of Watcher values. +type WatcherListResultPage struct { + fn func(WatcherListResult) (WatcherListResult, error) + wlr WatcherListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *WatcherListResultPage) Next() error { + next, err := page.fn(page.wlr) + if err != nil { + return err + } + page.wlr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page WatcherListResultPage) NotDone() bool { + return !page.wlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page WatcherListResultPage) Response() WatcherListResult { + return page.wlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page WatcherListResultPage) Values() []Watcher { + if page.wlr.IsEmpty() { + return nil + } + return *page.wlr.Value +} + +// WatcherProperties definition of the watcher properties +type WatcherProperties struct { + // ExecutionFrequencyInSeconds - Gets or sets the frequency at which the watcher is invoked. + ExecutionFrequencyInSeconds *int64 `json:"executionFrequencyInSeconds,omitempty"` + // ScriptName - Gets or sets the name of the script the watcher is attached to, i.e. the name of an existing runbook. + ScriptName *string `json:"scriptName,omitempty"` + // ScriptParameters - Gets or sets the parameters of the script. + ScriptParameters map[string]*string `json:"scriptParameters"` + // ScriptRunOn - Gets or sets the name of the hybrid worker group the watcher will run on. + ScriptRunOn *string `json:"scriptRunOn,omitempty"` + // Status - Gets the current status of the watcher. + Status *string `json:"status,omitempty"` + // CreationTime - Gets or sets the creation time. + CreationTime *date.Time `json:"creationTime,omitempty"` + // LastModifiedTime - Gets or sets the last modified time. + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + // LastModifiedBy - Details of the user who last modified the watcher. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + // Description - Gets or sets the description. + Description *string `json:"description,omitempty"` +} + +// MarshalJSON is the custom marshaler for WatcherProperties. +func (wp WatcherProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if wp.ExecutionFrequencyInSeconds != nil { + objectMap["executionFrequencyInSeconds"] = wp.ExecutionFrequencyInSeconds + } + if wp.ScriptName != nil { + objectMap["scriptName"] = wp.ScriptName + } + if wp.ScriptParameters != nil { + objectMap["scriptParameters"] = wp.ScriptParameters + } + if wp.ScriptRunOn != nil { + objectMap["scriptRunOn"] = wp.ScriptRunOn + } + if wp.Status != nil { + objectMap["status"] = wp.Status + } + if wp.CreationTime != nil { + objectMap["creationTime"] = wp.CreationTime + } + if wp.LastModifiedTime != nil { + objectMap["lastModifiedTime"] = wp.LastModifiedTime + } + if wp.LastModifiedBy != nil { + objectMap["lastModifiedBy"] = wp.LastModifiedBy + } + if wp.Description != nil { + objectMap["description"] = wp.Description + } + return json.Marshal(objectMap) +} + +// WatcherUpdateParameters ... +type WatcherUpdateParameters struct { + // WatcherUpdateProperties - Gets or sets the watcher update properties. + *WatcherUpdateProperties `json:"properties,omitempty"` + // Name - Gets or sets the name of the resource. + Name *string `json:"name,omitempty"` +} + +// MarshalJSON is the custom marshaler for WatcherUpdateParameters. +func (wup WatcherUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if wup.WatcherUpdateProperties != nil { + objectMap["properties"] = wup.WatcherUpdateProperties + } + if wup.Name != nil { + objectMap["name"] = wup.Name + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for WatcherUpdateParameters struct. +func (wup *WatcherUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var watcherUpdateProperties WatcherUpdateProperties + err = json.Unmarshal(*v, &watcherUpdateProperties) + if err != nil { + return err + } + wup.WatcherUpdateProperties = &watcherUpdateProperties + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + wup.Name = &name + } + } + } + + return nil +} + +// WatcherUpdateProperties the properties of the update watcher operation. +type WatcherUpdateProperties struct { + // ExecutionFrequencyInSeconds - Gets or sets the frequency at which the watcher is invoked. + ExecutionFrequencyInSeconds *int64 `json:"executionFrequencyInSeconds,omitempty"` +} + +// Webhook definition of the webhook type. +type Webhook struct { + autorest.Response `json:"-"` + // WebhookProperties - Gets or sets the webhook properties. + *WebhookProperties `json:"properties,omitempty"` + // ID - Fully qualified resource Id for the resource + ID *string `json:"id,omitempty"` + // Name - The name of the resource + Name *string `json:"name,omitempty"` + // Type - The type of the resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Webhook. +func (w Webhook) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if w.WebhookProperties != nil { + objectMap["properties"] = w.WebhookProperties + } + if w.ID != nil { + objectMap["id"] = w.ID + } + if w.Name != nil { + objectMap["name"] = w.Name + } + if w.Type != nil { + objectMap["type"] = w.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Webhook struct. +func (w *Webhook) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var webhookProperties WebhookProperties + err = json.Unmarshal(*v, &webhookProperties) + if err != nil { + return err + } + w.WebhookProperties = &webhookProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + w.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + w.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + w.Type = &typeVar + } + } + } + + return nil +} + +// WebhookCreateOrUpdateParameters the parameters supplied to the create or update webhook operation. +type WebhookCreateOrUpdateParameters struct { + // Name - Gets or sets the name of the webhook. + Name *string `json:"name,omitempty"` + // WebhookCreateOrUpdateProperties - Gets or sets the properties of the webhook. + *WebhookCreateOrUpdateProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for WebhookCreateOrUpdateParameters. +func (wcoup WebhookCreateOrUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if wcoup.Name != nil { + objectMap["name"] = wcoup.Name + } + if wcoup.WebhookCreateOrUpdateProperties != nil { + objectMap["properties"] = wcoup.WebhookCreateOrUpdateProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for WebhookCreateOrUpdateParameters struct. +func (wcoup *WebhookCreateOrUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + wcoup.Name = &name + } + case "properties": + if v != nil { + var webhookCreateOrUpdateProperties WebhookCreateOrUpdateProperties + err = json.Unmarshal(*v, &webhookCreateOrUpdateProperties) + if err != nil { + return err + } + wcoup.WebhookCreateOrUpdateProperties = &webhookCreateOrUpdateProperties + } + } + } + + return nil +} + +// WebhookCreateOrUpdateProperties the properties of the create webhook operation. +type WebhookCreateOrUpdateProperties struct { + // IsEnabled - Gets or sets the value of the enabled flag of webhook. + IsEnabled *bool `json:"isEnabled,omitempty"` + // URI - Gets or sets the uri. + URI *string `json:"uri,omitempty"` + // ExpiryTime - Gets or sets the expiry time. + ExpiryTime *date.Time `json:"expiryTime,omitempty"` + // Parameters - Gets or sets the parameters of the job. + Parameters map[string]*string `json:"parameters"` + // Runbook - Gets or sets the runbook. + Runbook *RunbookAssociationProperty `json:"runbook,omitempty"` + // RunOn - Gets or sets the name of the hybrid worker group the webhook job will run on. + RunOn *string `json:"runOn,omitempty"` +} + +// MarshalJSON is the custom marshaler for WebhookCreateOrUpdateProperties. +func (wcoup WebhookCreateOrUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if wcoup.IsEnabled != nil { + objectMap["isEnabled"] = wcoup.IsEnabled + } + if wcoup.URI != nil { + objectMap["uri"] = wcoup.URI + } + if wcoup.ExpiryTime != nil { + objectMap["expiryTime"] = wcoup.ExpiryTime + } + if wcoup.Parameters != nil { + objectMap["parameters"] = wcoup.Parameters + } + if wcoup.Runbook != nil { + objectMap["runbook"] = wcoup.Runbook + } + if wcoup.RunOn != nil { + objectMap["runOn"] = wcoup.RunOn + } + return json.Marshal(objectMap) +} + +// WebhookListResult the response model for the list webhook operation. +type WebhookListResult struct { + autorest.Response `json:"-"` + // Value - Gets or sets a list of webhooks. + Value *[]Webhook `json:"value,omitempty"` + // NextLink - Gets or sets the next link. + NextLink *string `json:"nextLink,omitempty"` +} + +// WebhookListResultIterator provides access to a complete listing of Webhook values. +type WebhookListResultIterator struct { + i int + page WebhookListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *WebhookListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter WebhookListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter WebhookListResultIterator) Response() WebhookListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter WebhookListResultIterator) Value() Webhook { + if !iter.page.NotDone() { + return Webhook{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (wlr WebhookListResult) IsEmpty() bool { + return wlr.Value == nil || len(*wlr.Value) == 0 +} + +// webhookListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (wlr WebhookListResult) webhookListResultPreparer() (*http.Request, error) { + if wlr.NextLink == nil || len(to.String(wlr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(wlr.NextLink))) +} + +// WebhookListResultPage contains a page of Webhook values. +type WebhookListResultPage struct { + fn func(WebhookListResult) (WebhookListResult, error) + wlr WebhookListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *WebhookListResultPage) Next() error { + next, err := page.fn(page.wlr) + if err != nil { + return err + } + page.wlr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page WebhookListResultPage) NotDone() bool { + return !page.wlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page WebhookListResultPage) Response() WebhookListResult { + return page.wlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page WebhookListResultPage) Values() []Webhook { + if page.wlr.IsEmpty() { + return nil + } + return *page.wlr.Value +} + +// WebhookProperties definition of the webhook properties +type WebhookProperties struct { + // IsEnabled - Gets or sets the value of the enabled flag of the webhook. + IsEnabled *bool `json:"isEnabled,omitempty"` + // URI - Gets or sets the webhook uri. + URI *string `json:"uri,omitempty"` + // ExpiryTime - Gets or sets the expiry time. + ExpiryTime *date.Time `json:"expiryTime,omitempty"` + // LastInvokedTime - Gets or sets the last invoked time. + LastInvokedTime *date.Time `json:"lastInvokedTime,omitempty"` + // Parameters - Gets or sets the parameters of the job that is created when the webhook calls the runbook it is associated with. + Parameters map[string]*string `json:"parameters"` + // Runbook - Gets or sets the runbook the webhook is associated with. + Runbook *RunbookAssociationProperty `json:"runbook,omitempty"` + // RunOn - Gets or sets the name of the hybrid worker group the webhook job will run on. + RunOn *string `json:"runOn,omitempty"` + // CreationTime - Gets or sets the creation time. + CreationTime *date.Time `json:"creationTime,omitempty"` + // LastModifiedTime - Gets or sets the last modified time. + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + // LastModifiedBy - Details of the user who last modified the Webhook + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + // Description - Gets or sets the description. + Description *string `json:"description,omitempty"` +} + +// MarshalJSON is the custom marshaler for WebhookProperties. +func (wp WebhookProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if wp.IsEnabled != nil { + objectMap["isEnabled"] = wp.IsEnabled + } + if wp.URI != nil { + objectMap["uri"] = wp.URI + } + if wp.ExpiryTime != nil { + objectMap["expiryTime"] = wp.ExpiryTime + } + if wp.LastInvokedTime != nil { + objectMap["lastInvokedTime"] = wp.LastInvokedTime + } + if wp.Parameters != nil { + objectMap["parameters"] = wp.Parameters + } + if wp.Runbook != nil { + objectMap["runbook"] = wp.Runbook + } + if wp.RunOn != nil { + objectMap["runOn"] = wp.RunOn + } + if wp.CreationTime != nil { + objectMap["creationTime"] = wp.CreationTime + } + if wp.LastModifiedTime != nil { + objectMap["lastModifiedTime"] = wp.LastModifiedTime + } + if wp.LastModifiedBy != nil { + objectMap["lastModifiedBy"] = wp.LastModifiedBy + } + if wp.Description != nil { + objectMap["description"] = wp.Description + } + return json.Marshal(objectMap) +} + +// WebhookUpdateParameters the parameters supplied to the update webhook operation. +type WebhookUpdateParameters struct { + // Name - Gets or sets the name of the webhook. + Name *string `json:"name,omitempty"` + // WebhookUpdateProperties - Gets or sets the value of the webhook. + *WebhookUpdateProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for WebhookUpdateParameters. +func (wup WebhookUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if wup.Name != nil { + objectMap["name"] = wup.Name + } + if wup.WebhookUpdateProperties != nil { + objectMap["properties"] = wup.WebhookUpdateProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for WebhookUpdateParameters struct. +func (wup *WebhookUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + wup.Name = &name + } + case "properties": + if v != nil { + var webhookUpdateProperties WebhookUpdateProperties + err = json.Unmarshal(*v, &webhookUpdateProperties) + if err != nil { + return err + } + wup.WebhookUpdateProperties = &webhookUpdateProperties + } + } + } + + return nil +} + +// WebhookUpdateProperties the properties of the update webhook. +type WebhookUpdateProperties struct { + // IsEnabled - Gets or sets the value of the enabled flag of webhook. + IsEnabled *bool `json:"isEnabled,omitempty"` + // RunOn - Gets or sets the name of the hybrid worker group the webhook job will run on. + RunOn *string `json:"runOn,omitempty"` + // Parameters - Gets or sets the parameters of the job. + Parameters map[string]*string `json:"parameters"` + // Description - Gets or sets the description of the webhook. + Description *string `json:"description,omitempty"` +} + +// MarshalJSON is the custom marshaler for WebhookUpdateProperties. +func (wup WebhookUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if wup.IsEnabled != nil { + objectMap["isEnabled"] = wup.IsEnabled + } + if wup.RunOn != nil { + objectMap["runOn"] = wup.RunOn + } + if wup.Parameters != nil { + objectMap["parameters"] = wup.Parameters + } + if wup.Description != nil { + objectMap["description"] = wup.Description + } + return json.Marshal(objectMap) +} + +// WindowsProperties windows specific update configuration. +type WindowsProperties struct { + // IncludedUpdateClassifications - Update classification included in the software update configuration. A comma separated string with required values. Possible values include: 'WindowsUpdateClassesUnclassified', 'WindowsUpdateClassesCritical', 'WindowsUpdateClassesSecurity', 'WindowsUpdateClassesUpdateRollup', 'WindowsUpdateClassesFeaturePack', 'WindowsUpdateClassesServicePack', 'WindowsUpdateClassesDefinition', 'WindowsUpdateClassesTools', 'WindowsUpdateClassesUpdates' + IncludedUpdateClassifications WindowsUpdateClasses `json:"includedUpdateClassifications,omitempty"` + // ExcludedKbNumbers - KB numbers excluded from the software update configuration. + ExcludedKbNumbers *[]string `json:"excludedKbNumbers,omitempty"` + // IncludedKbNumbers - KB numbers included from the software update configuration. + IncludedKbNumbers *[]string `json:"includedKbNumbers,omitempty"` + // RebootSetting - Reboot setting for the software update configuration. + RebootSetting *string `json:"rebootSetting,omitempty"` +} diff --git a/services/preview/automation/mgmt/2018-06-30-preview/automation/module.go b/services/preview/automation/mgmt/2018-06-30-preview/automation/module.go new file mode 100644 index 000000000000..5c7a761c1936 --- /dev/null +++ b/services/preview/automation/mgmt/2018-06-30-preview/automation/module.go @@ -0,0 +1,466 @@ +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" +) + +// ModuleClient is the automation Client +type ModuleClient struct { + BaseClient +} + +// NewModuleClient creates an instance of the ModuleClient client. +func NewModuleClient(subscriptionID string, countType1 CountType) ModuleClient { + return NewModuleClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewModuleClientWithBaseURI creates an instance of the ModuleClient client. +func NewModuleClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) ModuleClient { + return ModuleClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// CreateOrUpdate create or Update the module identified by module name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// moduleName - the name of module. +// parameters - the create or update parameters for module. +func (client ModuleClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, automationAccountName string, moduleName string, parameters ModuleCreateOrUpdateParameters) (result Module, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.ModuleCreateOrUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ModuleCreateOrUpdateProperties.ContentLink", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ModuleCreateOrUpdateProperties.ContentLink.ContentHash", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ModuleCreateOrUpdateProperties.ContentLink.ContentHash.Algorithm", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ModuleCreateOrUpdateProperties.ContentLink.ContentHash.Value", Name: validation.Null, Rule: true, Chain: nil}, + }}, + }}, + }}}}}); err != nil { + return result, validation.NewError("automation.ModuleClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, automationAccountName, moduleName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ModuleClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, moduleName string, parameters ModuleCreateOrUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "moduleName": autorest.Encode("path", moduleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ModuleClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ModuleClient) CreateOrUpdateResponder(resp *http.Response) (result Module, 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 delete the module by name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// moduleName - the module name. +func (client ModuleClient) Delete(ctx context.Context, resourceGroupName string, automationAccountName string, moduleName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.ModuleClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, automationAccountName, moduleName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ModuleClient) DeletePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, moduleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "moduleName": autorest.Encode("path", moduleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ModuleClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ModuleClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get retrieve the module identified by module name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// moduleName - the module name. +func (client ModuleClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string, moduleName string) (result Module, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.ModuleClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName, moduleName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ModuleClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, moduleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "moduleName": autorest.Encode("path", moduleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ModuleClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ModuleClient) GetResponder(resp *http.Response) (result Module, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of modules. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +func (client ModuleClient) ListByAutomationAccount(ctx context.Context, resourceGroupName string, automationAccountName string) (result ModuleListResultPage, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.ModuleClient", "ListByAutomationAccount", err.Error()) + } + + result.fn = client.listByAutomationAccountNextResults + req, err := client.ListByAutomationAccountPreparer(ctx, resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.mlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result.mlr, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client ModuleClient) ListByAutomationAccountPreparer(ctx context.Context, resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules", 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 ModuleClient) 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 ModuleClient) ListByAutomationAccountResponder(resp *http.Response) (result ModuleListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByAutomationAccountNextResults retrieves the next set of results, if any. +func (client ModuleClient) listByAutomationAccountNextResults(lastResults ModuleListResult) (result ModuleListResult, err error) { + req, err := lastResults.moduleListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.ModuleClient", "listByAutomationAccountNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.ModuleClient", "listByAutomationAccountNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "listByAutomationAccountNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByAutomationAccountComplete enumerates all values, automatically crossing page boundaries as required. +func (client ModuleClient) ListByAutomationAccountComplete(ctx context.Context, resourceGroupName string, automationAccountName string) (result ModuleListResultIterator, err error) { + result.page, err = client.ListByAutomationAccount(ctx, resourceGroupName, automationAccountName) + return +} + +// Update update the module identified by module name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// moduleName - the name of module. +// parameters - the update parameters for module. +func (client ModuleClient) Update(ctx context.Context, resourceGroupName string, automationAccountName string, moduleName string, parameters ModuleUpdateParameters) (result Module, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.ModuleClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, automationAccountName, moduleName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ModuleClient) UpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, moduleName string, parameters ModuleUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "moduleName": autorest.Encode("path", moduleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client ModuleClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ModuleClient) UpdateResponder(resp *http.Response) (result Module, 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/preview/automation/mgmt/2018-06-30-preview/automation/nodecountinformation.go b/services/preview/automation/mgmt/2018-06-30-preview/automation/nodecountinformation.go new file mode 100644 index 000000000000..4227722e39d2 --- /dev/null +++ b/services/preview/automation/mgmt/2018-06-30-preview/automation/nodecountinformation.go @@ -0,0 +1,117 @@ +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" +) + +// NodeCountInformationClient is the automation Client +type NodeCountInformationClient struct { + BaseClient +} + +// NewNodeCountInformationClient creates an instance of the NodeCountInformationClient client. +func NewNodeCountInformationClient(subscriptionID string, countType1 CountType) NodeCountInformationClient { + return NewNodeCountInformationClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewNodeCountInformationClientWithBaseURI creates an instance of the NodeCountInformationClient client. +func NewNodeCountInformationClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) NodeCountInformationClient { + return NodeCountInformationClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// Get retrieve counts for Dsc Nodes. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +func (client NodeCountInformationClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string) (result NodeCounts, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.NodeCountInformationClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.NodeCountInformationClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.NodeCountInformationClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.NodeCountInformationClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client NodeCountInformationClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "countType": autorest.Encode("path", client.CountType1), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-01-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodecounts/{countType}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client NodeCountInformationClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client NodeCountInformationClient) GetResponder(resp *http.Response) (result NodeCounts, 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/preview/automation/mgmt/2018-06-30-preview/automation/nodereports.go b/services/preview/automation/mgmt/2018-06-30-preview/automation/nodereports.go new file mode 100644 index 000000000000..a6c3428b4af9 --- /dev/null +++ b/services/preview/automation/mgmt/2018-06-30-preview/automation/nodereports.go @@ -0,0 +1,308 @@ +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" +) + +// NodeReportsClient is the automation Client +type NodeReportsClient struct { + BaseClient +} + +// NewNodeReportsClient creates an instance of the NodeReportsClient client. +func NewNodeReportsClient(subscriptionID string, countType1 CountType) NodeReportsClient { + return NewNodeReportsClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewNodeReportsClientWithBaseURI creates an instance of the NodeReportsClient client. +func NewNodeReportsClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) NodeReportsClient { + return NodeReportsClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// Get retrieve the Dsc node report data by node id and report id. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// nodeID - the Dsc node id. +// reportID - the report id. +func (client NodeReportsClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string, nodeID string, reportID string) (result DscNodeReport, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.NodeReportsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName, nodeID, reportID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.NodeReportsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.NodeReportsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.NodeReportsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client NodeReportsClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, nodeID string, reportID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "nodeId": autorest.Encode("path", nodeID), + "reportId": autorest.Encode("path", reportID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-01-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}/reports/{reportId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client NodeReportsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client NodeReportsClient) GetResponder(resp *http.Response) (result DscNodeReport, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetContent retrieve the Dsc node reports by node id and report id. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// nodeID - the Dsc node id. +// reportID - the report id. +func (client NodeReportsClient) GetContent(ctx context.Context, resourceGroupName string, automationAccountName string, nodeID string, reportID string) (result SetObject, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.NodeReportsClient", "GetContent", err.Error()) + } + + req, err := client.GetContentPreparer(ctx, resourceGroupName, automationAccountName, nodeID, reportID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.NodeReportsClient", "GetContent", nil, "Failure preparing request") + return + } + + resp, err := client.GetContentSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.NodeReportsClient", "GetContent", resp, "Failure sending request") + return + } + + result, err = client.GetContentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.NodeReportsClient", "GetContent", resp, "Failure responding to request") + } + + return +} + +// GetContentPreparer prepares the GetContent request. +func (client NodeReportsClient) GetContentPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, nodeID string, reportID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "nodeId": autorest.Encode("path", nodeID), + "reportId": autorest.Encode("path", reportID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-01-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}/reports/{reportId}/content", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetContentSender sends the GetContent request. The method will close the +// http.Response Body if it receives an error. +func (client NodeReportsClient) GetContentSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetContentResponder handles the response to the GetContent request. The method always +// closes the http.Response Body. +func (client NodeReportsClient) GetContentResponder(resp *http.Response) (result SetObject, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Value), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByNode retrieve the Dsc node report list by node id. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// nodeID - the parameters supplied to the list operation. +// filter - the filter to apply on the operation. +func (client NodeReportsClient) ListByNode(ctx context.Context, resourceGroupName string, automationAccountName string, nodeID string, filter string) (result DscNodeReportListResultPage, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.NodeReportsClient", "ListByNode", err.Error()) + } + + result.fn = client.listByNodeNextResults + req, err := client.ListByNodePreparer(ctx, resourceGroupName, automationAccountName, nodeID, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.NodeReportsClient", "ListByNode", nil, "Failure preparing request") + return + } + + resp, err := client.ListByNodeSender(req) + if err != nil { + result.dnrlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.NodeReportsClient", "ListByNode", resp, "Failure sending request") + return + } + + result.dnrlr, err = client.ListByNodeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.NodeReportsClient", "ListByNode", resp, "Failure responding to request") + } + + return +} + +// ListByNodePreparer prepares the ListByNode request. +func (client NodeReportsClient) ListByNodePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, nodeID string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "nodeId": autorest.Encode("path", nodeID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-01-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}/reports", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByNodeSender sends the ListByNode request. The method will close the +// http.Response Body if it receives an error. +func (client NodeReportsClient) ListByNodeSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByNodeResponder handles the response to the ListByNode request. The method always +// closes the http.Response Body. +func (client NodeReportsClient) ListByNodeResponder(resp *http.Response) (result DscNodeReportListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByNodeNextResults retrieves the next set of results, if any. +func (client NodeReportsClient) listByNodeNextResults(lastResults DscNodeReportListResult) (result DscNodeReportListResult, err error) { + req, err := lastResults.dscNodeReportListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.NodeReportsClient", "listByNodeNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByNodeSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.NodeReportsClient", "listByNodeNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByNodeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.NodeReportsClient", "listByNodeNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByNodeComplete enumerates all values, automatically crossing page boundaries as required. +func (client NodeReportsClient) ListByNodeComplete(ctx context.Context, resourceGroupName string, automationAccountName string, nodeID string, filter string) (result DscNodeReportListResultIterator, err error) { + result.page, err = client.ListByNode(ctx, resourceGroupName, automationAccountName, nodeID, filter) + return +} diff --git a/services/preview/automation/mgmt/2018-06-30-preview/automation/objectdatatypes.go b/services/preview/automation/mgmt/2018-06-30-preview/automation/objectdatatypes.go new file mode 100644 index 000000000000..6c6ebe8d3204 --- /dev/null +++ b/services/preview/automation/mgmt/2018-06-30-preview/automation/objectdatatypes.go @@ -0,0 +1,197 @@ +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" +) + +// ObjectDataTypesClient is the automation Client +type ObjectDataTypesClient struct { + BaseClient +} + +// NewObjectDataTypesClient creates an instance of the ObjectDataTypesClient client. +func NewObjectDataTypesClient(subscriptionID string, countType1 CountType) ObjectDataTypesClient { + return NewObjectDataTypesClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewObjectDataTypesClientWithBaseURI creates an instance of the ObjectDataTypesClient client. +func NewObjectDataTypesClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) ObjectDataTypesClient { + return ObjectDataTypesClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// ListFieldsByModuleAndType retrieve a list of fields of a given type identified by module name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// moduleName - the name of module. +// typeName - the name of type. +func (client ObjectDataTypesClient) ListFieldsByModuleAndType(ctx context.Context, resourceGroupName string, automationAccountName string, moduleName string, typeName string) (result TypeFieldListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.ObjectDataTypesClient", "ListFieldsByModuleAndType", err.Error()) + } + + req, err := client.ListFieldsByModuleAndTypePreparer(ctx, resourceGroupName, automationAccountName, moduleName, typeName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ObjectDataTypesClient", "ListFieldsByModuleAndType", nil, "Failure preparing request") + return + } + + resp, err := client.ListFieldsByModuleAndTypeSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ObjectDataTypesClient", "ListFieldsByModuleAndType", resp, "Failure sending request") + return + } + + result, err = client.ListFieldsByModuleAndTypeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ObjectDataTypesClient", "ListFieldsByModuleAndType", resp, "Failure responding to request") + } + + return +} + +// ListFieldsByModuleAndTypePreparer prepares the ListFieldsByModuleAndType request. +func (client ObjectDataTypesClient) ListFieldsByModuleAndTypePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, moduleName string, typeName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "moduleName": autorest.Encode("path", moduleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "typeName": autorest.Encode("path", typeName), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/objectDataTypes/{typeName}/fields", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListFieldsByModuleAndTypeSender sends the ListFieldsByModuleAndType request. The method will close the +// http.Response Body if it receives an error. +func (client ObjectDataTypesClient) ListFieldsByModuleAndTypeSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListFieldsByModuleAndTypeResponder handles the response to the ListFieldsByModuleAndType request. The method always +// closes the http.Response Body. +func (client ObjectDataTypesClient) ListFieldsByModuleAndTypeResponder(resp *http.Response) (result TypeFieldListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListFieldsByType retrieve a list of fields of a given type across all accessible modules. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// typeName - the name of type. +func (client ObjectDataTypesClient) ListFieldsByType(ctx context.Context, resourceGroupName string, automationAccountName string, typeName string) (result TypeFieldListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.ObjectDataTypesClient", "ListFieldsByType", err.Error()) + } + + req, err := client.ListFieldsByTypePreparer(ctx, resourceGroupName, automationAccountName, typeName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ObjectDataTypesClient", "ListFieldsByType", nil, "Failure preparing request") + return + } + + resp, err := client.ListFieldsByTypeSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ObjectDataTypesClient", "ListFieldsByType", resp, "Failure sending request") + return + } + + result, err = client.ListFieldsByTypeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ObjectDataTypesClient", "ListFieldsByType", resp, "Failure responding to request") + } + + return +} + +// ListFieldsByTypePreparer prepares the ListFieldsByType request. +func (client ObjectDataTypesClient) ListFieldsByTypePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, typeName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "typeName": autorest.Encode("path", typeName), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/objectDataTypes/{typeName}/fields", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListFieldsByTypeSender sends the ListFieldsByType request. The method will close the +// http.Response Body if it receives an error. +func (client ObjectDataTypesClient) ListFieldsByTypeSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListFieldsByTypeResponder handles the response to the ListFieldsByType request. The method always +// closes the http.Response Body. +func (client ObjectDataTypesClient) ListFieldsByTypeResponder(resp *http.Response) (result TypeFieldListResult, 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/preview/automation/mgmt/2018-06-30-preview/automation/operations.go b/services/preview/automation/mgmt/2018-06-30-preview/automation/operations.go new file mode 100644 index 000000000000..4423e8db5daf --- /dev/null +++ b/services/preview/automation/mgmt/2018-06-30-preview/automation/operations.go @@ -0,0 +1,98 @@ +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" + "net/http" +) + +// OperationsClient is the automation Client +type OperationsClient struct { + BaseClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string, countType1 CountType) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client. +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// List lists all of the available Automation REST API operations. +func (client OperationsClient) List(ctx context.Context) (result OperationListResult, err error) { + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.OperationsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.OperationsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Automation/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, 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/preview/automation/mgmt/2018-06-30-preview/automation/python2package.go b/services/preview/automation/mgmt/2018-06-30-preview/automation/python2package.go new file mode 100644 index 000000000000..0575eb83b6e9 --- /dev/null +++ b/services/preview/automation/mgmt/2018-06-30-preview/automation/python2package.go @@ -0,0 +1,466 @@ +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" +) + +// Python2PackageClient is the automation Client +type Python2PackageClient struct { + BaseClient +} + +// NewPython2PackageClient creates an instance of the Python2PackageClient client. +func NewPython2PackageClient(subscriptionID string, countType1 CountType) Python2PackageClient { + return NewPython2PackageClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewPython2PackageClientWithBaseURI creates an instance of the Python2PackageClient client. +func NewPython2PackageClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) Python2PackageClient { + return Python2PackageClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// CreateOrUpdate create or Update the python 2 package identified by package name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// packageName - the name of python package. +// parameters - the create or update parameters for python package. +func (client Python2PackageClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, automationAccountName string, packageName string, parameters PythonPackageCreateParameters) (result Module, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.PythonPackageCreateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.PythonPackageCreateProperties.ContentLink", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.PythonPackageCreateProperties.ContentLink.ContentHash", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.PythonPackageCreateProperties.ContentLink.ContentHash.Algorithm", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.PythonPackageCreateProperties.ContentLink.ContentHash.Value", Name: validation.Null, Rule: true, Chain: nil}, + }}, + }}, + }}}}}); err != nil { + return result, validation.NewError("automation.Python2PackageClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, automationAccountName, packageName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.Python2PackageClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.Python2PackageClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.Python2PackageClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client Python2PackageClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, packageName string, parameters PythonPackageCreateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "packageName": autorest.Encode("path", packageName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-30" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages/{packageName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client Python2PackageClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client Python2PackageClient) CreateOrUpdateResponder(resp *http.Response) (result Module, 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 delete the python 2 package by name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// packageName - the python package name. +func (client Python2PackageClient) Delete(ctx context.Context, resourceGroupName string, automationAccountName string, packageName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.Python2PackageClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, automationAccountName, packageName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.Python2PackageClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.Python2PackageClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.Python2PackageClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client Python2PackageClient) DeletePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, packageName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "packageName": autorest.Encode("path", packageName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-30" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages/{packageName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client Python2PackageClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client Python2PackageClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get retrieve the python 2 package identified by package name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// packageName - the python package name. +func (client Python2PackageClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string, packageName string) (result Module, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.Python2PackageClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName, packageName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.Python2PackageClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.Python2PackageClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.Python2PackageClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client Python2PackageClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, packageName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "packageName": autorest.Encode("path", packageName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-30" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages/{packageName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client Python2PackageClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client Python2PackageClient) GetResponder(resp *http.Response) (result Module, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of python 2 packages. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +func (client Python2PackageClient) ListByAutomationAccount(ctx context.Context, resourceGroupName string, automationAccountName string) (result ModuleListResultPage, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.Python2PackageClient", "ListByAutomationAccount", err.Error()) + } + + result.fn = client.listByAutomationAccountNextResults + req, err := client.ListByAutomationAccountPreparer(ctx, resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.Python2PackageClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.mlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.Python2PackageClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result.mlr, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.Python2PackageClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client Python2PackageClient) ListByAutomationAccountPreparer(ctx context.Context, resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-30" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages", 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 Python2PackageClient) 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 Python2PackageClient) ListByAutomationAccountResponder(resp *http.Response) (result ModuleListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByAutomationAccountNextResults retrieves the next set of results, if any. +func (client Python2PackageClient) listByAutomationAccountNextResults(lastResults ModuleListResult) (result ModuleListResult, err error) { + req, err := lastResults.moduleListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.Python2PackageClient", "listByAutomationAccountNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.Python2PackageClient", "listByAutomationAccountNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.Python2PackageClient", "listByAutomationAccountNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByAutomationAccountComplete enumerates all values, automatically crossing page boundaries as required. +func (client Python2PackageClient) ListByAutomationAccountComplete(ctx context.Context, resourceGroupName string, automationAccountName string) (result ModuleListResultIterator, err error) { + result.page, err = client.ListByAutomationAccount(ctx, resourceGroupName, automationAccountName) + return +} + +// Update update the python 2 package identified by package name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// packageName - the name of python package. +// parameters - the update parameters for python package. +func (client Python2PackageClient) Update(ctx context.Context, resourceGroupName string, automationAccountName string, packageName string, parameters PythonPackageUpdateParameters) (result Module, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.Python2PackageClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, automationAccountName, packageName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.Python2PackageClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.Python2PackageClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.Python2PackageClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client Python2PackageClient) UpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, packageName string, parameters PythonPackageUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "packageName": autorest.Encode("path", packageName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-30" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages/{packageName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client Python2PackageClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client Python2PackageClient) UpdateResponder(resp *http.Response) (result Module, 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/preview/automation/mgmt/2018-06-30-preview/automation/runbook.go b/services/preview/automation/mgmt/2018-06-30-preview/automation/runbook.go new file mode 100644 index 000000000000..1359d52c5840 --- /dev/null +++ b/services/preview/automation/mgmt/2018-06-30-preview/automation/runbook.go @@ -0,0 +1,631 @@ +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" +) + +// RunbookClient is the automation Client +type RunbookClient struct { + BaseClient +} + +// NewRunbookClient creates an instance of the RunbookClient client. +func NewRunbookClient(subscriptionID string, countType1 CountType) RunbookClient { + return NewRunbookClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewRunbookClientWithBaseURI creates an instance of the RunbookClient client. +func NewRunbookClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) RunbookClient { + return RunbookClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// CreateOrUpdate create the runbook identified by runbook name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// runbookName - the runbook name. +// parameters - the create or update parameters for runbook. Provide either content link for a published +// runbook or draft, not both. +func (client RunbookClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string, parameters RunbookCreateOrUpdateParameters) (result Runbook, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.RunbookCreateOrUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.RunbookCreateOrUpdateProperties.Draft", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.RunbookCreateOrUpdateProperties.Draft.DraftContentLink", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.RunbookCreateOrUpdateProperties.Draft.DraftContentLink.ContentHash", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.RunbookCreateOrUpdateProperties.Draft.DraftContentLink.ContentHash.Algorithm", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.RunbookCreateOrUpdateProperties.Draft.DraftContentLink.ContentHash.Value", Name: validation.Null, Rule: true, Chain: nil}, + }}, + }}, + }}, + {Target: "parameters.RunbookCreateOrUpdateProperties.PublishContentLink", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.RunbookCreateOrUpdateProperties.PublishContentLink.ContentHash", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.RunbookCreateOrUpdateProperties.PublishContentLink.ContentHash.Algorithm", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.RunbookCreateOrUpdateProperties.PublishContentLink.ContentHash.Value", Name: validation.Null, Rule: true, Chain: nil}, + }}, + }}, + }}}}}); err != nil { + return result, validation.NewError("automation.RunbookClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, automationAccountName, runbookName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client RunbookClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string, parameters RunbookCreateOrUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-30" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client RunbookClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client RunbookClient) CreateOrUpdateResponder(resp *http.Response) (result Runbook, 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 delete the runbook by name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// runbookName - the runbook name. +func (client RunbookClient) Delete(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.RunbookClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, automationAccountName, runbookName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client RunbookClient) DeletePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-30" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client RunbookClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client RunbookClient) 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 retrieve the runbook identified by runbook name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// runbookName - the runbook name. +func (client RunbookClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string) (result Runbook, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.RunbookClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName, runbookName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client RunbookClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-30" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client RunbookClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client RunbookClient) GetResponder(resp *http.Response) (result Runbook, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetContent retrieve the content of runbook identified by runbook name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// runbookName - the runbook name. +func (client RunbookClient) GetContent(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string) (result ReadCloser, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.RunbookClient", "GetContent", err.Error()) + } + + req, err := client.GetContentPreparer(ctx, resourceGroupName, automationAccountName, runbookName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "GetContent", nil, "Failure preparing request") + return + } + + resp, err := client.GetContentSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "GetContent", resp, "Failure sending request") + return + } + + result, err = client.GetContentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "GetContent", resp, "Failure responding to request") + } + + return +} + +// GetContentPreparer prepares the GetContent request. +func (client RunbookClient) GetContentPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-30" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/content", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetContentSender sends the GetContent request. The method will close the +// http.Response Body if it receives an error. +func (client RunbookClient) GetContentSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetContentResponder handles the response to the GetContent request. The method always +// closes the http.Response Body. +func (client RunbookClient) GetContentResponder(resp *http.Response) (result ReadCloser, err error) { + result.Value = &resp.Body + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK)) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of runbooks. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +func (client RunbookClient) ListByAutomationAccount(ctx context.Context, resourceGroupName string, automationAccountName string) (result RunbookListResultPage, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.RunbookClient", "ListByAutomationAccount", err.Error()) + } + + result.fn = client.listByAutomationAccountNextResults + req, err := client.ListByAutomationAccountPreparer(ctx, resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.rlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result.rlr, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client RunbookClient) ListByAutomationAccountPreparer(ctx context.Context, resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-30" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks", 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 RunbookClient) 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 RunbookClient) ListByAutomationAccountResponder(resp *http.Response) (result RunbookListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByAutomationAccountNextResults retrieves the next set of results, if any. +func (client RunbookClient) listByAutomationAccountNextResults(lastResults RunbookListResult) (result RunbookListResult, err error) { + req, err := lastResults.runbookListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.RunbookClient", "listByAutomationAccountNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.RunbookClient", "listByAutomationAccountNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "listByAutomationAccountNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByAutomationAccountComplete enumerates all values, automatically crossing page boundaries as required. +func (client RunbookClient) ListByAutomationAccountComplete(ctx context.Context, resourceGroupName string, automationAccountName string) (result RunbookListResultIterator, err error) { + result.page, err = client.ListByAutomationAccount(ctx, resourceGroupName, automationAccountName) + return +} + +// Publish publish runbook draft. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// runbookName - the parameters supplied to the publish runbook operation. +func (client RunbookClient) Publish(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string) (result RunbookPublishFuture, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.RunbookClient", "Publish", err.Error()) + } + + req, err := client.PublishPreparer(ctx, resourceGroupName, automationAccountName, runbookName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "Publish", nil, "Failure preparing request") + return + } + + result, err = client.PublishSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "Publish", result.Response(), "Failure sending request") + return + } + + return +} + +// PublishPreparer prepares the Publish request. +func (client RunbookClient) PublishPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-30" + 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}/runbooks/{runbookName}/publish", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// PublishSender sends the Publish request. The method will close the +// http.Response Body if it receives an error. +func (client RunbookClient) PublishSender(req *http.Request) (future RunbookPublishFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// PublishResponder handles the response to the Publish request. The method always +// closes the http.Response Body. +func (client RunbookClient) PublishResponder(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 update the runbook identified by runbook name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// runbookName - the runbook name. +// parameters - the update parameters for runbook. +func (client RunbookClient) Update(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string, parameters RunbookUpdateParameters) (result Runbook, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.RunbookClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, automationAccountName, runbookName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client RunbookClient) UpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string, parameters RunbookUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-30" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client RunbookClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client RunbookClient) UpdateResponder(resp *http.Response) (result Runbook, 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/preview/automation/mgmt/2018-06-30-preview/automation/runbookdraft.go b/services/preview/automation/mgmt/2018-06-30-preview/automation/runbookdraft.go new file mode 100644 index 000000000000..7f8f4b641a2b --- /dev/null +++ b/services/preview/automation/mgmt/2018-06-30-preview/automation/runbookdraft.go @@ -0,0 +1,356 @@ +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" + "io" + "net/http" +) + +// RunbookDraftClient is the automation Client +type RunbookDraftClient struct { + BaseClient +} + +// NewRunbookDraftClient creates an instance of the RunbookDraftClient client. +func NewRunbookDraftClient(subscriptionID string, countType1 CountType) RunbookDraftClient { + return NewRunbookDraftClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewRunbookDraftClientWithBaseURI creates an instance of the RunbookDraftClient client. +func NewRunbookDraftClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) RunbookDraftClient { + return RunbookDraftClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// Get retrieve the runbook draft identified by runbook name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// runbookName - the runbook name. +func (client RunbookDraftClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string) (result RunbookDraft, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.RunbookDraftClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName, runbookName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookDraftClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.RunbookDraftClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookDraftClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client RunbookDraftClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-30" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client RunbookDraftClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client RunbookDraftClient) GetResponder(resp *http.Response) (result RunbookDraft, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetContent retrieve the content of runbook draft identified by runbook name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// runbookName - the runbook name. +func (client RunbookDraftClient) GetContent(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string) (result ReadCloser, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.RunbookDraftClient", "GetContent", err.Error()) + } + + req, err := client.GetContentPreparer(ctx, resourceGroupName, automationAccountName, runbookName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookDraftClient", "GetContent", nil, "Failure preparing request") + return + } + + resp, err := client.GetContentSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.RunbookDraftClient", "GetContent", resp, "Failure sending request") + return + } + + result, err = client.GetContentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookDraftClient", "GetContent", resp, "Failure responding to request") + } + + return +} + +// GetContentPreparer prepares the GetContent request. +func (client RunbookDraftClient) GetContentPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-30" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/content", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetContentSender sends the GetContent request. The method will close the +// http.Response Body if it receives an error. +func (client RunbookDraftClient) GetContentSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetContentResponder handles the response to the GetContent request. The method always +// closes the http.Response Body. +func (client RunbookDraftClient) GetContentResponder(resp *http.Response) (result ReadCloser, err error) { + result.Value = &resp.Body + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK)) + result.Response = autorest.Response{Response: resp} + return +} + +// ReplaceContent replaces the runbook draft content. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// runbookName - the runbook name. +// runbookContent - the runbook draft content. +func (client RunbookDraftClient) ReplaceContent(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string, runbookContent io.ReadCloser) (result RunbookDraftReplaceContentFuture, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.RunbookDraftClient", "ReplaceContent", err.Error()) + } + + req, err := client.ReplaceContentPreparer(ctx, resourceGroupName, automationAccountName, runbookName, runbookContent) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookDraftClient", "ReplaceContent", nil, "Failure preparing request") + return + } + + result, err = client.ReplaceContentSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookDraftClient", "ReplaceContent", result.Response(), "Failure sending request") + return + } + + return +} + +// ReplaceContentPreparer prepares the ReplaceContent request. +func (client RunbookDraftClient) ReplaceContentPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string, runbookContent io.ReadCloser) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-30" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("text/powershell"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/content", pathParameters), + autorest.WithFile(runbookContent), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ReplaceContentSender sends the ReplaceContent request. The method will close the +// http.Response Body if it receives an error. +func (client RunbookDraftClient) ReplaceContentSender(req *http.Request) (future RunbookDraftReplaceContentFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// ReplaceContentResponder handles the response to the ReplaceContent request. The method always +// closes the http.Response Body. +func (client RunbookDraftClient) ReplaceContentResponder(resp *http.Response) (result ReadCloser, 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 +} + +// UndoEdit undo draft edit to last known published state identified by runbook name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// runbookName - the runbook name. +func (client RunbookDraftClient) UndoEdit(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string) (result RunbookDraftUndoEditResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.RunbookDraftClient", "UndoEdit", err.Error()) + } + + req, err := client.UndoEditPreparer(ctx, resourceGroupName, automationAccountName, runbookName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookDraftClient", "UndoEdit", nil, "Failure preparing request") + return + } + + resp, err := client.UndoEditSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.RunbookDraftClient", "UndoEdit", resp, "Failure sending request") + return + } + + result, err = client.UndoEditResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookDraftClient", "UndoEdit", resp, "Failure responding to request") + } + + return +} + +// UndoEditPreparer prepares the UndoEdit request. +func (client RunbookDraftClient) UndoEditPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-30" + 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}/runbooks/{runbookName}/draft/undoEdit", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UndoEditSender sends the UndoEdit request. The method will close the +// http.Response Body if it receives an error. +func (client RunbookDraftClient) UndoEditSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// UndoEditResponder handles the response to the UndoEdit request. The method always +// closes the http.Response Body. +func (client RunbookDraftClient) UndoEditResponder(resp *http.Response) (result RunbookDraftUndoEditResult, 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/preview/automation/mgmt/2018-06-30-preview/automation/schedule.go b/services/preview/automation/mgmt/2018-06-30-preview/automation/schedule.go new file mode 100644 index 000000000000..8856aaa45182 --- /dev/null +++ b/services/preview/automation/mgmt/2018-06-30-preview/automation/schedule.go @@ -0,0 +1,461 @@ +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" +) + +// ScheduleClient is the automation Client +type ScheduleClient struct { + BaseClient +} + +// NewScheduleClient creates an instance of the ScheduleClient client. +func NewScheduleClient(subscriptionID string, countType1 CountType) ScheduleClient { + return NewScheduleClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewScheduleClientWithBaseURI creates an instance of the ScheduleClient client. +func NewScheduleClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) ScheduleClient { + return ScheduleClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// CreateOrUpdate create a schedule. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// scheduleName - the schedule name. +// parameters - the parameters supplied to the create or update schedule operation. +func (client ScheduleClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, automationAccountName string, scheduleName string, parameters ScheduleCreateOrUpdateParameters) (result Schedule, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ScheduleCreateOrUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ScheduleCreateOrUpdateProperties.StartTime", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("automation.ScheduleClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, automationAccountName, scheduleName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ScheduleClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, scheduleName string, parameters ScheduleCreateOrUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scheduleName": autorest.Encode("path", scheduleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ScheduleClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ScheduleClient) CreateOrUpdateResponder(resp *http.Response) (result Schedule, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusConflict), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete the schedule identified by schedule name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// scheduleName - the schedule name. +func (client ScheduleClient) Delete(ctx context.Context, resourceGroupName string, automationAccountName string, scheduleName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.ScheduleClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, automationAccountName, scheduleName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ScheduleClient) DeletePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, scheduleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scheduleName": autorest.Encode("path", scheduleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ScheduleClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ScheduleClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get retrieve the schedule identified by schedule name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// scheduleName - the schedule name. +func (client ScheduleClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string, scheduleName string) (result Schedule, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.ScheduleClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName, scheduleName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ScheduleClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, scheduleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scheduleName": autorest.Encode("path", scheduleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ScheduleClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ScheduleClient) GetResponder(resp *http.Response) (result Schedule, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of schedules. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +func (client ScheduleClient) ListByAutomationAccount(ctx context.Context, resourceGroupName string, automationAccountName string) (result ScheduleListResultPage, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.ScheduleClient", "ListByAutomationAccount", err.Error()) + } + + result.fn = client.listByAutomationAccountNextResults + req, err := client.ListByAutomationAccountPreparer(ctx, resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.slr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result.slr, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client ScheduleClient) ListByAutomationAccountPreparer(ctx context.Context, resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules", 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 ScheduleClient) 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 ScheduleClient) ListByAutomationAccountResponder(resp *http.Response) (result ScheduleListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByAutomationAccountNextResults retrieves the next set of results, if any. +func (client ScheduleClient) listByAutomationAccountNextResults(lastResults ScheduleListResult) (result ScheduleListResult, err error) { + req, err := lastResults.scheduleListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.ScheduleClient", "listByAutomationAccountNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.ScheduleClient", "listByAutomationAccountNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "listByAutomationAccountNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByAutomationAccountComplete enumerates all values, automatically crossing page boundaries as required. +func (client ScheduleClient) ListByAutomationAccountComplete(ctx context.Context, resourceGroupName string, automationAccountName string) (result ScheduleListResultIterator, err error) { + result.page, err = client.ListByAutomationAccount(ctx, resourceGroupName, automationAccountName) + return +} + +// Update update the schedule identified by schedule name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// scheduleName - the schedule name. +// parameters - the parameters supplied to the update schedule operation. +func (client ScheduleClient) Update(ctx context.Context, resourceGroupName string, automationAccountName string, scheduleName string, parameters ScheduleUpdateParameters) (result Schedule, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.ScheduleClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, automationAccountName, scheduleName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ScheduleClient) UpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, scheduleName string, parameters ScheduleUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scheduleName": autorest.Encode("path", scheduleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client ScheduleClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ScheduleClient) UpdateResponder(resp *http.Response) (result Schedule, 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/preview/automation/mgmt/2018-06-30-preview/automation/softwareupdateconfigurationmachineruns.go b/services/preview/automation/mgmt/2018-06-30-preview/automation/softwareupdateconfigurationmachineruns.go new file mode 100644 index 000000000000..b1ca235ebd3c --- /dev/null +++ b/services/preview/automation/mgmt/2018-06-30-preview/automation/softwareupdateconfigurationmachineruns.go @@ -0,0 +1,219 @@ +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" + "github.com/satori/go.uuid" + "net/http" +) + +// SoftwareUpdateConfigurationMachineRunsClient is the automation Client +type SoftwareUpdateConfigurationMachineRunsClient struct { + BaseClient +} + +// NewSoftwareUpdateConfigurationMachineRunsClient creates an instance of the +// SoftwareUpdateConfigurationMachineRunsClient client. +func NewSoftwareUpdateConfigurationMachineRunsClient(subscriptionID string, countType1 CountType) SoftwareUpdateConfigurationMachineRunsClient { + return NewSoftwareUpdateConfigurationMachineRunsClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewSoftwareUpdateConfigurationMachineRunsClientWithBaseURI creates an instance of the +// SoftwareUpdateConfigurationMachineRunsClient client. +func NewSoftwareUpdateConfigurationMachineRunsClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) SoftwareUpdateConfigurationMachineRunsClient { + return SoftwareUpdateConfigurationMachineRunsClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// GetByID get a single software update configuration machine run by Id. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// softwareUpdateConfigurationMachineRunID - the Id of the software update configuration machine run. +// clientRequestID - identifies this specific client request. +func (client SoftwareUpdateConfigurationMachineRunsClient) GetByID(ctx context.Context, resourceGroupName string, automationAccountName string, softwareUpdateConfigurationMachineRunID uuid.UUID, clientRequestID string) (result SoftwareUpdateConfigurationMachineRun, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.SoftwareUpdateConfigurationMachineRunsClient", "GetByID", err.Error()) + } + + req, err := client.GetByIDPreparer(ctx, resourceGroupName, automationAccountName, softwareUpdateConfigurationMachineRunID, clientRequestID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationMachineRunsClient", "GetByID", nil, "Failure preparing request") + return + } + + resp, err := client.GetByIDSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationMachineRunsClient", "GetByID", resp, "Failure sending request") + return + } + + result, err = client.GetByIDResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationMachineRunsClient", "GetByID", resp, "Failure responding to request") + } + + return +} + +// GetByIDPreparer prepares the GetByID request. +func (client SoftwareUpdateConfigurationMachineRunsClient) GetByIDPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, softwareUpdateConfigurationMachineRunID uuid.UUID, clientRequestID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "softwareUpdateConfigurationMachineRunId": autorest.Encode("path", softwareUpdateConfigurationMachineRunID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-05-15-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.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationMachineRuns/{softwareUpdateConfigurationMachineRunId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if len(clientRequestID) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("clientRequestId", autorest.String(clientRequestID))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetByIDSender sends the GetByID request. The method will close the +// http.Response Body if it receives an error. +func (client SoftwareUpdateConfigurationMachineRunsClient) GetByIDSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetByIDResponder handles the response to the GetByID request. The method always +// closes the http.Response Body. +func (client SoftwareUpdateConfigurationMachineRunsClient) GetByIDResponder(resp *http.Response) (result SoftwareUpdateConfigurationMachineRun, 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 return list of software update configuration machine runs +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// clientRequestID - identifies this specific client request. +// filter - the filter to apply on the operation. You can use the following filters: 'properties/osType', +// 'properties/status', 'properties/startTime', and 'properties/softwareUpdateConfiguration/name' +// skip - number of entries you skip before returning results +// top - maximum number of entries returned in the results collection +func (client SoftwareUpdateConfigurationMachineRunsClient) List(ctx context.Context, resourceGroupName string, automationAccountName string, clientRequestID string, filter string, skip string, top string) (result SoftwareUpdateConfigurationMachineRunListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.SoftwareUpdateConfigurationMachineRunsClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, resourceGroupName, automationAccountName, clientRequestID, filter, skip, top) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationMachineRunsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationMachineRunsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationMachineRunsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client SoftwareUpdateConfigurationMachineRunsClient) ListPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, clientRequestID string, filter string, skip string, top string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-05-15-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if len(skip) > 0 { + queryParameters["$skip"] = autorest.Encode("query", skip) + } + if len(top) > 0 { + queryParameters["$top"] = autorest.Encode("query", top) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationMachineRuns", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if len(clientRequestID) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("clientRequestId", autorest.String(clientRequestID))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client SoftwareUpdateConfigurationMachineRunsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client SoftwareUpdateConfigurationMachineRunsClient) ListResponder(resp *http.Response) (result SoftwareUpdateConfigurationMachineRunListResult, 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/preview/automation/mgmt/2018-06-30-preview/automation/softwareupdateconfigurationruns.go b/services/preview/automation/mgmt/2018-06-30-preview/automation/softwareupdateconfigurationruns.go new file mode 100644 index 000000000000..51734e1edbec --- /dev/null +++ b/services/preview/automation/mgmt/2018-06-30-preview/automation/softwareupdateconfigurationruns.go @@ -0,0 +1,218 @@ +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" + "github.com/satori/go.uuid" + "net/http" +) + +// SoftwareUpdateConfigurationRunsClient is the automation Client +type SoftwareUpdateConfigurationRunsClient struct { + BaseClient +} + +// NewSoftwareUpdateConfigurationRunsClient creates an instance of the SoftwareUpdateConfigurationRunsClient client. +func NewSoftwareUpdateConfigurationRunsClient(subscriptionID string, countType1 CountType) SoftwareUpdateConfigurationRunsClient { + return NewSoftwareUpdateConfigurationRunsClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewSoftwareUpdateConfigurationRunsClientWithBaseURI creates an instance of the SoftwareUpdateConfigurationRunsClient +// client. +func NewSoftwareUpdateConfigurationRunsClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) SoftwareUpdateConfigurationRunsClient { + return SoftwareUpdateConfigurationRunsClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// GetByID get a single software update configuration Run by Id. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// softwareUpdateConfigurationRunID - the Id of the software update configuration run. +// clientRequestID - identifies this specific client request. +func (client SoftwareUpdateConfigurationRunsClient) GetByID(ctx context.Context, resourceGroupName string, automationAccountName string, softwareUpdateConfigurationRunID uuid.UUID, clientRequestID string) (result SoftwareUpdateConfigurationRun, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.SoftwareUpdateConfigurationRunsClient", "GetByID", err.Error()) + } + + req, err := client.GetByIDPreparer(ctx, resourceGroupName, automationAccountName, softwareUpdateConfigurationRunID, clientRequestID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationRunsClient", "GetByID", nil, "Failure preparing request") + return + } + + resp, err := client.GetByIDSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationRunsClient", "GetByID", resp, "Failure sending request") + return + } + + result, err = client.GetByIDResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationRunsClient", "GetByID", resp, "Failure responding to request") + } + + return +} + +// GetByIDPreparer prepares the GetByID request. +func (client SoftwareUpdateConfigurationRunsClient) GetByIDPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, softwareUpdateConfigurationRunID uuid.UUID, clientRequestID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "softwareUpdateConfigurationRunId": autorest.Encode("path", softwareUpdateConfigurationRunID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-05-15-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.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationRuns/{softwareUpdateConfigurationRunId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if len(clientRequestID) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("clientRequestId", autorest.String(clientRequestID))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetByIDSender sends the GetByID request. The method will close the +// http.Response Body if it receives an error. +func (client SoftwareUpdateConfigurationRunsClient) GetByIDSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetByIDResponder handles the response to the GetByID request. The method always +// closes the http.Response Body. +func (client SoftwareUpdateConfigurationRunsClient) GetByIDResponder(resp *http.Response) (result SoftwareUpdateConfigurationRun, 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 return list of software update configuration runs +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// clientRequestID - identifies this specific client request. +// filter - the filter to apply on the operation. You can use the following filters: 'properties/osType', +// 'properties/status', 'properties/startTime', and 'properties/softwareUpdateConfiguration/name' +// skip - number of entries you skip before returning results +// top - maximum number of entries returned in the results collection +func (client SoftwareUpdateConfigurationRunsClient) List(ctx context.Context, resourceGroupName string, automationAccountName string, clientRequestID string, filter string, skip string, top string) (result SoftwareUpdateConfigurationRunListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.SoftwareUpdateConfigurationRunsClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, resourceGroupName, automationAccountName, clientRequestID, filter, skip, top) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationRunsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationRunsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationRunsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client SoftwareUpdateConfigurationRunsClient) ListPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, clientRequestID string, filter string, skip string, top string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-05-15-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if len(skip) > 0 { + queryParameters["$skip"] = autorest.Encode("query", skip) + } + if len(top) > 0 { + queryParameters["$top"] = autorest.Encode("query", top) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationRuns", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if len(clientRequestID) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("clientRequestId", autorest.String(clientRequestID))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client SoftwareUpdateConfigurationRunsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client SoftwareUpdateConfigurationRunsClient) ListResponder(resp *http.Response) (result SoftwareUpdateConfigurationRunListResult, 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/preview/automation/mgmt/2018-06-30-preview/automation/softwareupdateconfigurations.go b/services/preview/automation/mgmt/2018-06-30-preview/automation/softwareupdateconfigurations.go new file mode 100644 index 000000000000..02991a282782 --- /dev/null +++ b/services/preview/automation/mgmt/2018-06-30-preview/automation/softwareupdateconfigurations.go @@ -0,0 +1,379 @@ +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" +) + +// SoftwareUpdateConfigurationsClient is the automation Client +type SoftwareUpdateConfigurationsClient struct { + BaseClient +} + +// NewSoftwareUpdateConfigurationsClient creates an instance of the SoftwareUpdateConfigurationsClient client. +func NewSoftwareUpdateConfigurationsClient(subscriptionID string, countType1 CountType) SoftwareUpdateConfigurationsClient { + return NewSoftwareUpdateConfigurationsClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewSoftwareUpdateConfigurationsClientWithBaseURI creates an instance of the SoftwareUpdateConfigurationsClient +// client. +func NewSoftwareUpdateConfigurationsClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) SoftwareUpdateConfigurationsClient { + return SoftwareUpdateConfigurationsClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// Create create a new software update configuration with the name given in the URI. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// softwareUpdateConfigurationName - the name of the software update configuration to be created. +// parameters - request body. +// clientRequestID - identifies this specific client request. +func (client SoftwareUpdateConfigurationsClient) Create(ctx context.Context, resourceGroupName string, automationAccountName string, softwareUpdateConfigurationName string, parameters SoftwareUpdateConfiguration, clientRequestID string) (result SoftwareUpdateConfiguration, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.SoftwareUpdateConfigurationProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.SoftwareUpdateConfigurationProperties.UpdateConfiguration", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.SoftwareUpdateConfigurationProperties.ScheduleInfo", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("automation.SoftwareUpdateConfigurationsClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, automationAccountName, softwareUpdateConfigurationName, parameters, clientRequestID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationsClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationsClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationsClient", "Create", resp, "Failure responding to request") + } + + return +} + +// CreatePreparer prepares the Create request. +func (client SoftwareUpdateConfigurationsClient) CreatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, softwareUpdateConfigurationName string, parameters SoftwareUpdateConfiguration, clientRequestID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "softwareUpdateConfigurationName": autorest.Encode("path", softwareUpdateConfigurationName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-05-15-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations/{softwareUpdateConfigurationName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + if len(clientRequestID) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("clientRequestId", autorest.String(clientRequestID))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client SoftwareUpdateConfigurationsClient) CreateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client SoftwareUpdateConfigurationsClient) CreateResponder(resp *http.Response) (result SoftwareUpdateConfiguration, 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 delete a specific software update configuration. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// softwareUpdateConfigurationName - the name of the software update configuration to be created. +// clientRequestID - identifies this specific client request. +func (client SoftwareUpdateConfigurationsClient) Delete(ctx context.Context, resourceGroupName string, automationAccountName string, softwareUpdateConfigurationName string, clientRequestID string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.SoftwareUpdateConfigurationsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, automationAccountName, softwareUpdateConfigurationName, clientRequestID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationsClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client SoftwareUpdateConfigurationsClient) DeletePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, softwareUpdateConfigurationName string, clientRequestID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "softwareUpdateConfigurationName": autorest.Encode("path", softwareUpdateConfigurationName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-05-15-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.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations/{softwareUpdateConfigurationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if len(clientRequestID) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("clientRequestId", autorest.String(clientRequestID))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client SoftwareUpdateConfigurationsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client SoftwareUpdateConfigurationsClient) 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 +} + +// GetByName get a single software update configuration by name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// softwareUpdateConfigurationName - the name of the software update configuration to be created. +// clientRequestID - identifies this specific client request. +func (client SoftwareUpdateConfigurationsClient) GetByName(ctx context.Context, resourceGroupName string, automationAccountName string, softwareUpdateConfigurationName string, clientRequestID string) (result SoftwareUpdateConfiguration, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.SoftwareUpdateConfigurationsClient", "GetByName", err.Error()) + } + + req, err := client.GetByNamePreparer(ctx, resourceGroupName, automationAccountName, softwareUpdateConfigurationName, clientRequestID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationsClient", "GetByName", nil, "Failure preparing request") + return + } + + resp, err := client.GetByNameSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationsClient", "GetByName", resp, "Failure sending request") + return + } + + result, err = client.GetByNameResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationsClient", "GetByName", resp, "Failure responding to request") + } + + return +} + +// GetByNamePreparer prepares the GetByName request. +func (client SoftwareUpdateConfigurationsClient) GetByNamePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, softwareUpdateConfigurationName string, clientRequestID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "softwareUpdateConfigurationName": autorest.Encode("path", softwareUpdateConfigurationName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-05-15-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.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations/{softwareUpdateConfigurationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if len(clientRequestID) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("clientRequestId", autorest.String(clientRequestID))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetByNameSender sends the GetByName request. The method will close the +// http.Response Body if it receives an error. +func (client SoftwareUpdateConfigurationsClient) GetByNameSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetByNameResponder handles the response to the GetByName request. The method always +// closes the http.Response Body. +func (client SoftwareUpdateConfigurationsClient) GetByNameResponder(resp *http.Response) (result SoftwareUpdateConfiguration, 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 get all software update configurations for the account. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// clientRequestID - identifies this specific client request. +// filter - the filter to apply on the operation. +func (client SoftwareUpdateConfigurationsClient) List(ctx context.Context, resourceGroupName string, automationAccountName string, clientRequestID string, filter string) (result SoftwareUpdateConfigurationListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.SoftwareUpdateConfigurationsClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, resourceGroupName, automationAccountName, clientRequestID, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SoftwareUpdateConfigurationsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client SoftwareUpdateConfigurationsClient) ListPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, clientRequestID string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-05-15-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if len(clientRequestID) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("clientRequestId", autorest.String(clientRequestID))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client SoftwareUpdateConfigurationsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client SoftwareUpdateConfigurationsClient) ListResponder(resp *http.Response) (result SoftwareUpdateConfigurationListResult, 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/preview/automation/mgmt/2018-06-30-preview/automation/sourcecontrol.go b/services/preview/automation/mgmt/2018-06-30-preview/automation/sourcecontrol.go new file mode 100644 index 000000000000..2ae0b1d991a8 --- /dev/null +++ b/services/preview/automation/mgmt/2018-06-30-preview/automation/sourcecontrol.go @@ -0,0 +1,478 @@ +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" +) + +// SourceControlClient is the automation Client +type SourceControlClient struct { + BaseClient +} + +// NewSourceControlClient creates an instance of the SourceControlClient client. +func NewSourceControlClient(subscriptionID string, countType1 CountType) SourceControlClient { + return NewSourceControlClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewSourceControlClientWithBaseURI creates an instance of the SourceControlClient client. +func NewSourceControlClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) SourceControlClient { + return SourceControlClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// CreateOrUpdate create a source control. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// sourceControlName - the source control name. +// parameters - the parameters supplied to the create or update source control operation. +func (client SourceControlClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, automationAccountName string, sourceControlName string, parameters SourceControlCreateOrUpdateParameters) (result SourceControl, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.SourceControlCreateOrUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.SourceControlCreateOrUpdateProperties.RepoURL", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.SourceControlCreateOrUpdateProperties.RepoURL", Name: validation.MaxLength, Rule: 2000, Chain: nil}}}, + {Target: "parameters.SourceControlCreateOrUpdateProperties.Branch", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.SourceControlCreateOrUpdateProperties.Branch", Name: validation.MaxLength, Rule: 255, Chain: nil}}}, + {Target: "parameters.SourceControlCreateOrUpdateProperties.FolderPath", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.SourceControlCreateOrUpdateProperties.FolderPath", Name: validation.MaxLength, Rule: 255, Chain: nil}}}, + {Target: "parameters.SourceControlCreateOrUpdateProperties.SecurityToken", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.SourceControlCreateOrUpdateProperties.SecurityToken.AccessToken", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.SourceControlCreateOrUpdateProperties.SecurityToken.AccessToken", Name: validation.MaxLength, Rule: 1024, Chain: nil}}}, + {Target: "parameters.SourceControlCreateOrUpdateProperties.SecurityToken.RefreshToken", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.SourceControlCreateOrUpdateProperties.SecurityToken.RefreshToken", Name: validation.MaxLength, Rule: 1024, Chain: nil}}}, + }}, + {Target: "parameters.SourceControlCreateOrUpdateProperties.Description", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.SourceControlCreateOrUpdateProperties.Description", Name: validation.MaxLength, Rule: 512, Chain: nil}}}, + }}}}}); err != nil { + return result, validation.NewError("automation.SourceControlClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, automationAccountName, sourceControlName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SourceControlClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.SourceControlClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SourceControlClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client SourceControlClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, sourceControlName string, parameters SourceControlCreateOrUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "sourceControlName": autorest.Encode("path", sourceControlName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-05-15-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client SourceControlClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client SourceControlClient) CreateOrUpdateResponder(resp *http.Response) (result SourceControl, 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 delete the source control. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// sourceControlName - the name of source control. +func (client SourceControlClient) Delete(ctx context.Context, resourceGroupName string, automationAccountName string, sourceControlName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.SourceControlClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, automationAccountName, sourceControlName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SourceControlClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.SourceControlClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SourceControlClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client SourceControlClient) DeletePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, sourceControlName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "sourceControlName": autorest.Encode("path", sourceControlName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-05-15-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.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client SourceControlClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client SourceControlClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get retrieve the source control identified by source control name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// sourceControlName - the name of source control. +func (client SourceControlClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string, sourceControlName string) (result SourceControl, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.SourceControlClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName, sourceControlName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SourceControlClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.SourceControlClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SourceControlClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client SourceControlClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, sourceControlName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "sourceControlName": autorest.Encode("path", sourceControlName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-05-15-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.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client SourceControlClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client SourceControlClient) GetResponder(resp *http.Response) (result SourceControl, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of source controls. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// filter - the filter to apply on the operation. +func (client SourceControlClient) ListByAutomationAccount(ctx context.Context, resourceGroupName string, automationAccountName string, filter string) (result SourceControlListResultPage, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.SourceControlClient", "ListByAutomationAccount", err.Error()) + } + + result.fn = client.listByAutomationAccountNextResults + req, err := client.ListByAutomationAccountPreparer(ctx, resourceGroupName, automationAccountName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SourceControlClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.sclr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.SourceControlClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result.sclr, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SourceControlClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client SourceControlClient) ListByAutomationAccountPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-05-15-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls", 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 SourceControlClient) 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 SourceControlClient) ListByAutomationAccountResponder(resp *http.Response) (result SourceControlListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByAutomationAccountNextResults retrieves the next set of results, if any. +func (client SourceControlClient) listByAutomationAccountNextResults(lastResults SourceControlListResult) (result SourceControlListResult, err error) { + req, err := lastResults.sourceControlListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.SourceControlClient", "listByAutomationAccountNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.SourceControlClient", "listByAutomationAccountNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SourceControlClient", "listByAutomationAccountNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByAutomationAccountComplete enumerates all values, automatically crossing page boundaries as required. +func (client SourceControlClient) ListByAutomationAccountComplete(ctx context.Context, resourceGroupName string, automationAccountName string, filter string) (result SourceControlListResultIterator, err error) { + result.page, err = client.ListByAutomationAccount(ctx, resourceGroupName, automationAccountName, filter) + return +} + +// Update update a source control. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// sourceControlName - the source control name. +// parameters - the parameters supplied to the update source control operation. +func (client SourceControlClient) Update(ctx context.Context, resourceGroupName string, automationAccountName string, sourceControlName string, parameters SourceControlUpdateParameters) (result SourceControl, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.SourceControlClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, automationAccountName, sourceControlName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SourceControlClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.SourceControlClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SourceControlClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client SourceControlClient) UpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, sourceControlName string, parameters SourceControlUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "sourceControlName": autorest.Encode("path", sourceControlName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-05-15-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client SourceControlClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client SourceControlClient) UpdateResponder(resp *http.Response) (result SourceControl, 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/preview/automation/mgmt/2018-06-30-preview/automation/sourcecontrolsyncjob.go b/services/preview/automation/mgmt/2018-06-30-preview/automation/sourcecontrolsyncjob.go new file mode 100644 index 000000000000..2b54a270d937 --- /dev/null +++ b/services/preview/automation/mgmt/2018-06-30-preview/automation/sourcecontrolsyncjob.go @@ -0,0 +1,317 @@ +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" + "github.com/satori/go.uuid" + "net/http" +) + +// SourceControlSyncJobClient is the automation Client +type SourceControlSyncJobClient struct { + BaseClient +} + +// NewSourceControlSyncJobClient creates an instance of the SourceControlSyncJobClient client. +func NewSourceControlSyncJobClient(subscriptionID string, countType1 CountType) SourceControlSyncJobClient { + return NewSourceControlSyncJobClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewSourceControlSyncJobClientWithBaseURI creates an instance of the SourceControlSyncJobClient client. +func NewSourceControlSyncJobClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) SourceControlSyncJobClient { + return SourceControlSyncJobClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// Create creates the sync job for a source control. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// sourceControlName - the source control name. +// sourceControlSyncJobID - the source control sync job id. +// parameters - the parameters supplied to the create source control sync job operation. +func (client SourceControlSyncJobClient) Create(ctx context.Context, resourceGroupName string, automationAccountName string, sourceControlName string, sourceControlSyncJobID uuid.UUID, parameters SourceControlSyncJobCreateParameters) (result SourceControlSyncJob, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.SourceControlSyncJobCreateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.SourceControlSyncJobCreateProperties.CommitID", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.SourceControlSyncJobCreateProperties.CommitID", Name: validation.MinLength, Rule: 0, Chain: nil}}}, + }}}}}); err != nil { + return result, validation.NewError("automation.SourceControlSyncJobClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, automationAccountName, sourceControlName, sourceControlSyncJobID, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SourceControlSyncJobClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.SourceControlSyncJobClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SourceControlSyncJobClient", "Create", resp, "Failure responding to request") + } + + return +} + +// CreatePreparer prepares the Create request. +func (client SourceControlSyncJobClient) CreatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, sourceControlName string, sourceControlSyncJobID uuid.UUID, parameters SourceControlSyncJobCreateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "sourceControlName": autorest.Encode("path", sourceControlName), + "sourceControlSyncJobId": autorest.Encode("path", sourceControlSyncJobID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-05-15-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs/{sourceControlSyncJobId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client SourceControlSyncJobClient) CreateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client SourceControlSyncJobClient) CreateResponder(resp *http.Response) (result SourceControlSyncJob, 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 +} + +// Get retrieve the source control sync job identified by job id. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// sourceControlName - the source control name. +// sourceControlSyncJobID - the source control sync job id. +func (client SourceControlSyncJobClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string, sourceControlName string, sourceControlSyncJobID uuid.UUID) (result SourceControlSyncJobByID, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.SourceControlSyncJobClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName, sourceControlName, sourceControlSyncJobID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SourceControlSyncJobClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.SourceControlSyncJobClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SourceControlSyncJobClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client SourceControlSyncJobClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, sourceControlName string, sourceControlSyncJobID uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "sourceControlName": autorest.Encode("path", sourceControlName), + "sourceControlSyncJobId": autorest.Encode("path", sourceControlSyncJobID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-05-15-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.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs/{sourceControlSyncJobId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client SourceControlSyncJobClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client SourceControlSyncJobClient) GetResponder(resp *http.Response) (result SourceControlSyncJobByID, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of source control sync jobs. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// sourceControlName - the source control name. +// filter - the filter to apply on the operation. +func (client SourceControlSyncJobClient) ListByAutomationAccount(ctx context.Context, resourceGroupName string, automationAccountName string, sourceControlName string, filter string) (result SourceControlSyncJobListResultPage, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.SourceControlSyncJobClient", "ListByAutomationAccount", err.Error()) + } + + result.fn = client.listByAutomationAccountNextResults + req, err := client.ListByAutomationAccountPreparer(ctx, resourceGroupName, automationAccountName, sourceControlName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SourceControlSyncJobClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.scsjlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.SourceControlSyncJobClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result.scsjlr, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SourceControlSyncJobClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client SourceControlSyncJobClient) ListByAutomationAccountPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, sourceControlName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "sourceControlName": autorest.Encode("path", sourceControlName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-05-15-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs", 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 SourceControlSyncJobClient) 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 SourceControlSyncJobClient) ListByAutomationAccountResponder(resp *http.Response) (result SourceControlSyncJobListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByAutomationAccountNextResults retrieves the next set of results, if any. +func (client SourceControlSyncJobClient) listByAutomationAccountNextResults(lastResults SourceControlSyncJobListResult) (result SourceControlSyncJobListResult, err error) { + req, err := lastResults.sourceControlSyncJobListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.SourceControlSyncJobClient", "listByAutomationAccountNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.SourceControlSyncJobClient", "listByAutomationAccountNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SourceControlSyncJobClient", "listByAutomationAccountNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByAutomationAccountComplete enumerates all values, automatically crossing page boundaries as required. +func (client SourceControlSyncJobClient) ListByAutomationAccountComplete(ctx context.Context, resourceGroupName string, automationAccountName string, sourceControlName string, filter string) (result SourceControlSyncJobListResultIterator, err error) { + result.page, err = client.ListByAutomationAccount(ctx, resourceGroupName, automationAccountName, sourceControlName, filter) + return +} diff --git a/services/preview/automation/mgmt/2018-06-30-preview/automation/sourcecontrolsyncjobstreams.go b/services/preview/automation/mgmt/2018-06-30-preview/automation/sourcecontrolsyncjobstreams.go new file mode 100644 index 000000000000..0b3376722aaf --- /dev/null +++ b/services/preview/automation/mgmt/2018-06-30-preview/automation/sourcecontrolsyncjobstreams.go @@ -0,0 +1,234 @@ +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" + "github.com/satori/go.uuid" + "net/http" +) + +// SourceControlSyncJobStreamsClient is the automation Client +type SourceControlSyncJobStreamsClient struct { + BaseClient +} + +// NewSourceControlSyncJobStreamsClient creates an instance of the SourceControlSyncJobStreamsClient client. +func NewSourceControlSyncJobStreamsClient(subscriptionID string, countType1 CountType) SourceControlSyncJobStreamsClient { + return NewSourceControlSyncJobStreamsClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewSourceControlSyncJobStreamsClientWithBaseURI creates an instance of the SourceControlSyncJobStreamsClient client. +func NewSourceControlSyncJobStreamsClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) SourceControlSyncJobStreamsClient { + return SourceControlSyncJobStreamsClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// Get retrieve a sync job stream identified by stream id. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// sourceControlName - the source control name. +// sourceControlSyncJobID - the source control sync job id. +// streamID - the id of the sync job stream. +func (client SourceControlSyncJobStreamsClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string, sourceControlName string, sourceControlSyncJobID uuid.UUID, streamID string) (result SourceControlSyncJobStreamByID, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.SourceControlSyncJobStreamsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName, sourceControlName, sourceControlSyncJobID, streamID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SourceControlSyncJobStreamsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.SourceControlSyncJobStreamsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SourceControlSyncJobStreamsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client SourceControlSyncJobStreamsClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, sourceControlName string, sourceControlSyncJobID uuid.UUID, streamID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "sourceControlName": autorest.Encode("path", sourceControlName), + "sourceControlSyncJobId": autorest.Encode("path", sourceControlSyncJobID), + "streamId": autorest.Encode("path", streamID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-05-15-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.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs/{sourceControlSyncJobId}/streams/{streamId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client SourceControlSyncJobStreamsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client SourceControlSyncJobStreamsClient) GetResponder(resp *http.Response) (result SourceControlSyncJobStreamByID, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListBySyncJob retrieve a list of sync job streams identified by sync job id. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// sourceControlName - the source control name. +// sourceControlSyncJobID - the source control sync job id. +// filter - the filter to apply on the operation. +func (client SourceControlSyncJobStreamsClient) ListBySyncJob(ctx context.Context, resourceGroupName string, automationAccountName string, sourceControlName string, sourceControlSyncJobID uuid.UUID, filter string) (result SourceControlSyncJobStreamsListBySyncJobPage, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.SourceControlSyncJobStreamsClient", "ListBySyncJob", err.Error()) + } + + result.fn = client.listBySyncJobNextResults + req, err := client.ListBySyncJobPreparer(ctx, resourceGroupName, automationAccountName, sourceControlName, sourceControlSyncJobID, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SourceControlSyncJobStreamsClient", "ListBySyncJob", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySyncJobSender(req) + if err != nil { + result.scsjslbsj.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.SourceControlSyncJobStreamsClient", "ListBySyncJob", resp, "Failure sending request") + return + } + + result.scsjslbsj, err = client.ListBySyncJobResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SourceControlSyncJobStreamsClient", "ListBySyncJob", resp, "Failure responding to request") + } + + return +} + +// ListBySyncJobPreparer prepares the ListBySyncJob request. +func (client SourceControlSyncJobStreamsClient) ListBySyncJobPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, sourceControlName string, sourceControlSyncJobID uuid.UUID, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "sourceControlName": autorest.Encode("path", sourceControlName), + "sourceControlSyncJobId": autorest.Encode("path", sourceControlSyncJobID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-05-15-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs/{sourceControlSyncJobId}/streams", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySyncJobSender sends the ListBySyncJob request. The method will close the +// http.Response Body if it receives an error. +func (client SourceControlSyncJobStreamsClient) ListBySyncJobSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListBySyncJobResponder handles the response to the ListBySyncJob request. The method always +// closes the http.Response Body. +func (client SourceControlSyncJobStreamsClient) ListBySyncJobResponder(resp *http.Response) (result SourceControlSyncJobStreamsListBySyncJob, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listBySyncJobNextResults retrieves the next set of results, if any. +func (client SourceControlSyncJobStreamsClient) listBySyncJobNextResults(lastResults SourceControlSyncJobStreamsListBySyncJob) (result SourceControlSyncJobStreamsListBySyncJob, err error) { + req, err := lastResults.sourceControlSyncJobStreamsListBySyncJobPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.SourceControlSyncJobStreamsClient", "listBySyncJobNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListBySyncJobSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.SourceControlSyncJobStreamsClient", "listBySyncJobNextResults", resp, "Failure sending next results request") + } + result, err = client.ListBySyncJobResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.SourceControlSyncJobStreamsClient", "listBySyncJobNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListBySyncJobComplete enumerates all values, automatically crossing page boundaries as required. +func (client SourceControlSyncJobStreamsClient) ListBySyncJobComplete(ctx context.Context, resourceGroupName string, automationAccountName string, sourceControlName string, sourceControlSyncJobID uuid.UUID, filter string) (result SourceControlSyncJobStreamsListBySyncJobIterator, err error) { + result.page, err = client.ListBySyncJob(ctx, resourceGroupName, automationAccountName, sourceControlName, sourceControlSyncJobID, filter) + return +} diff --git a/services/preview/automation/mgmt/2018-06-30-preview/automation/statistics.go b/services/preview/automation/mgmt/2018-06-30-preview/automation/statistics.go new file mode 100644 index 000000000000..a9c51ea07c08 --- /dev/null +++ b/services/preview/automation/mgmt/2018-06-30-preview/automation/statistics.go @@ -0,0 +1,120 @@ +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" +) + +// StatisticsClient is the automation Client +type StatisticsClient struct { + BaseClient +} + +// NewStatisticsClient creates an instance of the StatisticsClient client. +func NewStatisticsClient(subscriptionID string, countType1 CountType) StatisticsClient { + return NewStatisticsClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewStatisticsClientWithBaseURI creates an instance of the StatisticsClient client. +func NewStatisticsClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) StatisticsClient { + return StatisticsClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// ListByAutomationAccount retrieve the statistics for the account. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// filter - the filter to apply on the operation. +func (client StatisticsClient) ListByAutomationAccount(ctx context.Context, resourceGroupName string, automationAccountName string, filter string) (result StatisticsListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.StatisticsClient", "ListByAutomationAccount", err.Error()) + } + + req, err := client.ListByAutomationAccountPreparer(ctx, resourceGroupName, automationAccountName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.StatisticsClient", "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.StatisticsClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.StatisticsClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client StatisticsClient) ListByAutomationAccountPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/statistics", 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 StatisticsClient) 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 StatisticsClient) ListByAutomationAccountResponder(resp *http.Response) (result StatisticsListResult, 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/preview/automation/mgmt/2018-06-30-preview/automation/testjob.go b/services/preview/automation/mgmt/2018-06-30-preview/automation/testjob.go new file mode 100644 index 000000000000..01180ed38ffd --- /dev/null +++ b/services/preview/automation/mgmt/2018-06-30-preview/automation/testjob.go @@ -0,0 +1,426 @@ +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" +) + +// TestJobClient is the automation Client +type TestJobClient struct { + BaseClient +} + +// NewTestJobClient creates an instance of the TestJobClient client. +func NewTestJobClient(subscriptionID string, countType1 CountType) TestJobClient { + return NewTestJobClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewTestJobClientWithBaseURI creates an instance of the TestJobClient client. +func NewTestJobClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) TestJobClient { + return TestJobClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// Create create a test job of the runbook. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// runbookName - the parameters supplied to the create test job operation. +// parameters - the parameters supplied to the create test job operation. +func (client TestJobClient) Create(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string, parameters TestJobCreateParameters) (result TestJob, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.TestJobClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, automationAccountName, runbookName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.TestJobClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobClient", "Create", resp, "Failure responding to request") + } + + return +} + +// CreatePreparer prepares the Create request. +func (client TestJobClient) CreatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string, parameters TestJobCreateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-30" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client TestJobClient) CreateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client TestJobClient) CreateResponder(resp *http.Response) (result TestJob, 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 +} + +// Get retrieve the test job for the specified runbook. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// runbookName - the runbook name. +func (client TestJobClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string) (result TestJob, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.TestJobClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName, runbookName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.TestJobClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client TestJobClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-30" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client TestJobClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client TestJobClient) GetResponder(resp *http.Response) (result TestJob, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Resume resume the test job. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// runbookName - the runbook name. +func (client TestJobClient) Resume(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.TestJobClient", "Resume", err.Error()) + } + + req, err := client.ResumePreparer(ctx, resourceGroupName, automationAccountName, runbookName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobClient", "Resume", nil, "Failure preparing request") + return + } + + resp, err := client.ResumeSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.TestJobClient", "Resume", resp, "Failure sending request") + return + } + + result, err = client.ResumeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobClient", "Resume", resp, "Failure responding to request") + } + + return +} + +// ResumePreparer prepares the Resume request. +func (client TestJobClient) ResumePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-30" + 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}/runbooks/{runbookName}/draft/testJob/resume", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ResumeSender sends the Resume request. The method will close the +// http.Response Body if it receives an error. +func (client TestJobClient) ResumeSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ResumeResponder handles the response to the Resume request. The method always +// closes the http.Response Body. +func (client TestJobClient) ResumeResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Stop stop the test job. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// runbookName - the runbook name. +func (client TestJobClient) Stop(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.TestJobClient", "Stop", err.Error()) + } + + req, err := client.StopPreparer(ctx, resourceGroupName, automationAccountName, runbookName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobClient", "Stop", nil, "Failure preparing request") + return + } + + resp, err := client.StopSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.TestJobClient", "Stop", resp, "Failure sending request") + return + } + + result, err = client.StopResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobClient", "Stop", resp, "Failure responding to request") + } + + return +} + +// StopPreparer prepares the Stop request. +func (client TestJobClient) StopPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-30" + 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}/runbooks/{runbookName}/draft/testJob/stop", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// StopSender sends the Stop request. The method will close the +// http.Response Body if it receives an error. +func (client TestJobClient) StopSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// StopResponder handles the response to the Stop request. The method always +// closes the http.Response Body. +func (client TestJobClient) StopResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Suspend suspend the test job. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// runbookName - the runbook name. +func (client TestJobClient) Suspend(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.TestJobClient", "Suspend", err.Error()) + } + + req, err := client.SuspendPreparer(ctx, resourceGroupName, automationAccountName, runbookName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobClient", "Suspend", nil, "Failure preparing request") + return + } + + resp, err := client.SuspendSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.TestJobClient", "Suspend", resp, "Failure sending request") + return + } + + result, err = client.SuspendResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobClient", "Suspend", resp, "Failure responding to request") + } + + return +} + +// SuspendPreparer prepares the Suspend request. +func (client TestJobClient) SuspendPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-30" + 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}/runbooks/{runbookName}/draft/testJob/suspend", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// SuspendSender sends the Suspend request. The method will close the +// http.Response Body if it receives an error. +func (client TestJobClient) SuspendSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// SuspendResponder handles the response to the Suspend request. The method always +// closes the http.Response Body. +func (client TestJobClient) SuspendResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/services/preview/automation/mgmt/2018-06-30-preview/automation/testjobstreams.go b/services/preview/automation/mgmt/2018-06-30-preview/automation/testjobstreams.go new file mode 100644 index 000000000000..f26bb7fc9bba --- /dev/null +++ b/services/preview/automation/mgmt/2018-06-30-preview/automation/testjobstreams.go @@ -0,0 +1,229 @@ +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" +) + +// TestJobStreamsClient is the automation Client +type TestJobStreamsClient struct { + BaseClient +} + +// NewTestJobStreamsClient creates an instance of the TestJobStreamsClient client. +func NewTestJobStreamsClient(subscriptionID string, countType1 CountType) TestJobStreamsClient { + return NewTestJobStreamsClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewTestJobStreamsClientWithBaseURI creates an instance of the TestJobStreamsClient client. +func NewTestJobStreamsClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) TestJobStreamsClient { + return TestJobStreamsClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// Get retrieve a test job stream of the test job identified by runbook name and stream id. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// runbookName - the runbook name. +// jobStreamID - the job stream id. +func (client TestJobStreamsClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string, jobStreamID string) (result JobStream, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.TestJobStreamsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName, runbookName, jobStreamID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobStreamsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.TestJobStreamsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobStreamsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client TestJobStreamsClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string, jobStreamID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "jobStreamId": autorest.Encode("path", jobStreamID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-30" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/streams/{jobStreamId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client TestJobStreamsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client TestJobStreamsClient) GetResponder(resp *http.Response) (result JobStream, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByTestJob retrieve a list of test job streams identified by runbook name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// runbookName - the runbook name. +// filter - the filter to apply on the operation. +func (client TestJobStreamsClient) ListByTestJob(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string, filter string) (result JobStreamListResultPage, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.TestJobStreamsClient", "ListByTestJob", err.Error()) + } + + result.fn = client.listByTestJobNextResults + req, err := client.ListByTestJobPreparer(ctx, resourceGroupName, automationAccountName, runbookName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobStreamsClient", "ListByTestJob", nil, "Failure preparing request") + return + } + + resp, err := client.ListByTestJobSender(req) + if err != nil { + result.jslr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.TestJobStreamsClient", "ListByTestJob", resp, "Failure sending request") + return + } + + result.jslr, err = client.ListByTestJobResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobStreamsClient", "ListByTestJob", resp, "Failure responding to request") + } + + return +} + +// ListByTestJobPreparer prepares the ListByTestJob request. +func (client TestJobStreamsClient) ListByTestJobPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-30" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/streams", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByTestJobSender sends the ListByTestJob request. The method will close the +// http.Response Body if it receives an error. +func (client TestJobStreamsClient) ListByTestJobSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByTestJobResponder handles the response to the ListByTestJob request. The method always +// closes the http.Response Body. +func (client TestJobStreamsClient) ListByTestJobResponder(resp *http.Response) (result JobStreamListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByTestJobNextResults retrieves the next set of results, if any. +func (client TestJobStreamsClient) listByTestJobNextResults(lastResults JobStreamListResult) (result JobStreamListResult, err error) { + req, err := lastResults.jobStreamListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.TestJobStreamsClient", "listByTestJobNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByTestJobSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.TestJobStreamsClient", "listByTestJobNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByTestJobResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobStreamsClient", "listByTestJobNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByTestJobComplete enumerates all values, automatically crossing page boundaries as required. +func (client TestJobStreamsClient) ListByTestJobComplete(ctx context.Context, resourceGroupName string, automationAccountName string, runbookName string, filter string) (result JobStreamListResultIterator, err error) { + result.page, err = client.ListByTestJob(ctx, resourceGroupName, automationAccountName, runbookName, filter) + return +} diff --git a/services/preview/automation/mgmt/2018-06-30-preview/automation/usages.go b/services/preview/automation/mgmt/2018-06-30-preview/automation/usages.go new file mode 100644 index 000000000000..265bfaba03b1 --- /dev/null +++ b/services/preview/automation/mgmt/2018-06-30-preview/automation/usages.go @@ -0,0 +1,116 @@ +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" +) + +// UsagesClient is the automation Client +type UsagesClient struct { + BaseClient +} + +// NewUsagesClient creates an instance of the UsagesClient client. +func NewUsagesClient(subscriptionID string, countType1 CountType) UsagesClient { + return NewUsagesClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewUsagesClientWithBaseURI creates an instance of the UsagesClient client. +func NewUsagesClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) UsagesClient { + return UsagesClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// ListByAutomationAccount retrieve the usage for the account id. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +func (client UsagesClient) ListByAutomationAccount(ctx context.Context, resourceGroupName string, automationAccountName string) (result UsageListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.UsagesClient", "ListByAutomationAccount", err.Error()) + } + + req, err := client.ListByAutomationAccountPreparer(ctx, resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.UsagesClient", "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.UsagesClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.UsagesClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client UsagesClient) ListByAutomationAccountPreparer(ctx context.Context, resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/usages", 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 UsagesClient) 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 UsagesClient) ListByAutomationAccountResponder(resp *http.Response) (result UsageListResult, 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/preview/automation/mgmt/2018-06-30-preview/automation/variable.go b/services/preview/automation/mgmt/2018-06-30-preview/automation/variable.go new file mode 100644 index 000000000000..be7b4b91c5d3 --- /dev/null +++ b/services/preview/automation/mgmt/2018-06-30-preview/automation/variable.go @@ -0,0 +1,460 @@ +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" +) + +// VariableClient is the automation Client +type VariableClient struct { + BaseClient +} + +// NewVariableClient creates an instance of the VariableClient client. +func NewVariableClient(subscriptionID string, countType1 CountType) VariableClient { + return NewVariableClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewVariableClientWithBaseURI creates an instance of the VariableClient client. +func NewVariableClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) VariableClient { + return VariableClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// CreateOrUpdate create a variable. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// variableName - the variable name. +// parameters - the parameters supplied to the create or update variable operation. +func (client VariableClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, automationAccountName string, variableName string, parameters VariableCreateOrUpdateParameters) (result Variable, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.VariableCreateOrUpdateProperties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.VariableClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, automationAccountName, variableName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.VariableClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.VariableClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.VariableClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client VariableClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, variableName string, parameters VariableCreateOrUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "variableName": autorest.Encode("path", variableName), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client VariableClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client VariableClient) CreateOrUpdateResponder(resp *http.Response) (result Variable, 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 delete the variable. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// variableName - the name of variable. +func (client VariableClient) Delete(ctx context.Context, resourceGroupName string, automationAccountName string, variableName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.VariableClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, automationAccountName, variableName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.VariableClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.VariableClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.VariableClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client VariableClient) DeletePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, variableName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "variableName": autorest.Encode("path", variableName), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client VariableClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client VariableClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get retrieve the variable identified by variable name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// variableName - the name of variable. +func (client VariableClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string, variableName string) (result Variable, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.VariableClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName, variableName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.VariableClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.VariableClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.VariableClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client VariableClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, variableName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "variableName": autorest.Encode("path", variableName), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client VariableClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client VariableClient) GetResponder(resp *http.Response) (result Variable, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of variables. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +func (client VariableClient) ListByAutomationAccount(ctx context.Context, resourceGroupName string, automationAccountName string) (result VariableListResultPage, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.VariableClient", "ListByAutomationAccount", err.Error()) + } + + result.fn = client.listByAutomationAccountNextResults + req, err := client.ListByAutomationAccountPreparer(ctx, resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.VariableClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.vlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.VariableClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result.vlr, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.VariableClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client VariableClient) ListByAutomationAccountPreparer(ctx context.Context, resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables", 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 VariableClient) 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 VariableClient) ListByAutomationAccountResponder(resp *http.Response) (result VariableListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByAutomationAccountNextResults retrieves the next set of results, if any. +func (client VariableClient) listByAutomationAccountNextResults(lastResults VariableListResult) (result VariableListResult, err error) { + req, err := lastResults.variableListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.VariableClient", "listByAutomationAccountNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.VariableClient", "listByAutomationAccountNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.VariableClient", "listByAutomationAccountNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByAutomationAccountComplete enumerates all values, automatically crossing page boundaries as required. +func (client VariableClient) ListByAutomationAccountComplete(ctx context.Context, resourceGroupName string, automationAccountName string) (result VariableListResultIterator, err error) { + result.page, err = client.ListByAutomationAccount(ctx, resourceGroupName, automationAccountName) + return +} + +// Update update a variable. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// variableName - the variable name. +// parameters - the parameters supplied to the update variable operation. +func (client VariableClient) Update(ctx context.Context, resourceGroupName string, automationAccountName string, variableName string, parameters VariableUpdateParameters) (result Variable, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.VariableClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, automationAccountName, variableName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.VariableClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.VariableClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.VariableClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client VariableClient) UpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, variableName string, parameters VariableUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "variableName": autorest.Encode("path", variableName), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client VariableClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client VariableClient) UpdateResponder(resp *http.Response) (result Variable, 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/preview/automation/mgmt/2018-06-30-preview/automation/version.go b/services/preview/automation/mgmt/2018-06-30-preview/automation/version.go new file mode 100644 index 000000000000..1cab9406764b --- /dev/null +++ b/services/preview/automation/mgmt/2018-06-30-preview/automation/version.go @@ -0,0 +1,30 @@ +package automation + +import "github.com/Azure/azure-sdk-for-go/version" + +// 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. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + version.Number + " automation/2018-06-30-preview" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +} diff --git a/services/preview/automation/mgmt/2018-06-30-preview/automation/watcher.go b/services/preview/automation/mgmt/2018-06-30-preview/automation/watcher.go new file mode 100644 index 000000000000..0039c8775aa2 --- /dev/null +++ b/services/preview/automation/mgmt/2018-06-30-preview/automation/watcher.go @@ -0,0 +1,613 @@ +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" +) + +// WatcherClient is the automation Client +type WatcherClient struct { + BaseClient +} + +// NewWatcherClient creates an instance of the WatcherClient client. +func NewWatcherClient(subscriptionID string, countType1 CountType) WatcherClient { + return NewWatcherClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewWatcherClientWithBaseURI creates an instance of the WatcherClient client. +func NewWatcherClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) WatcherClient { + return WatcherClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// CreateOrUpdate create the watcher identified by watcher name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// watcherName - the watcher name. +// parameters - the create or update parameters for watcher. +func (client WatcherClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, automationAccountName string, watcherName string, parameters Watcher) (result Watcher, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.WatcherClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, automationAccountName, watcherName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WatcherClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.WatcherClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WatcherClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client WatcherClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, watcherName string, parameters Watcher) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "watcherName": autorest.Encode("path", watcherName), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client WatcherClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client WatcherClient) CreateOrUpdateResponder(resp *http.Response) (result Watcher, 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 delete the watcher by name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// watcherName - the watcher name. +func (client WatcherClient) Delete(ctx context.Context, resourceGroupName string, automationAccountName string, watcherName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.WatcherClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, automationAccountName, watcherName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WatcherClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.WatcherClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WatcherClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client WatcherClient) DeletePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, watcherName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "watcherName": autorest.Encode("path", watcherName), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client WatcherClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client WatcherClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get retrieve the watcher identified by watcher name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// watcherName - the watcher name. +func (client WatcherClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string, watcherName string) (result Watcher, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.WatcherClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName, watcherName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WatcherClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.WatcherClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WatcherClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client WatcherClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, watcherName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "watcherName": autorest.Encode("path", watcherName), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client WatcherClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client WatcherClient) GetResponder(resp *http.Response) (result Watcher, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of watchers. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// filter - the filter to apply on the operation. +func (client WatcherClient) ListByAutomationAccount(ctx context.Context, resourceGroupName string, automationAccountName string, filter string) (result WatcherListResultPage, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.WatcherClient", "ListByAutomationAccount", err.Error()) + } + + result.fn = client.listByAutomationAccountNextResults + req, err := client.ListByAutomationAccountPreparer(ctx, resourceGroupName, automationAccountName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WatcherClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.wlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.WatcherClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result.wlr, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WatcherClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client WatcherClient) ListByAutomationAccountPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers", 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 WatcherClient) 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 WatcherClient) ListByAutomationAccountResponder(resp *http.Response) (result WatcherListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByAutomationAccountNextResults retrieves the next set of results, if any. +func (client WatcherClient) listByAutomationAccountNextResults(lastResults WatcherListResult) (result WatcherListResult, err error) { + req, err := lastResults.watcherListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.WatcherClient", "listByAutomationAccountNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.WatcherClient", "listByAutomationAccountNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WatcherClient", "listByAutomationAccountNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByAutomationAccountComplete enumerates all values, automatically crossing page boundaries as required. +func (client WatcherClient) ListByAutomationAccountComplete(ctx context.Context, resourceGroupName string, automationAccountName string, filter string) (result WatcherListResultIterator, err error) { + result.page, err = client.ListByAutomationAccount(ctx, resourceGroupName, automationAccountName, filter) + return +} + +// Start resume the watcher identified by watcher name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// watcherName - the watcher name. +func (client WatcherClient) Start(ctx context.Context, resourceGroupName string, automationAccountName string, watcherName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.WatcherClient", "Start", err.Error()) + } + + req, err := client.StartPreparer(ctx, resourceGroupName, automationAccountName, watcherName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WatcherClient", "Start", nil, "Failure preparing request") + return + } + + resp, err := client.StartSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.WatcherClient", "Start", resp, "Failure sending request") + return + } + + result, err = client.StartResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WatcherClient", "Start", resp, "Failure responding to request") + } + + return +} + +// StartPreparer prepares the Start request. +func (client WatcherClient) StartPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, watcherName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "watcherName": autorest.Encode("path", watcherName), + } + + 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}/watchers/{watcherName}/start", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// StartSender sends the Start request. The method will close the +// http.Response Body if it receives an error. +func (client WatcherClient) StartSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// StartResponder handles the response to the Start request. The method always +// closes the http.Response Body. +func (client WatcherClient) StartResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Stop resume the watcher identified by watcher name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// watcherName - the watcher name. +func (client WatcherClient) Stop(ctx context.Context, resourceGroupName string, automationAccountName string, watcherName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.WatcherClient", "Stop", err.Error()) + } + + req, err := client.StopPreparer(ctx, resourceGroupName, automationAccountName, watcherName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WatcherClient", "Stop", nil, "Failure preparing request") + return + } + + resp, err := client.StopSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.WatcherClient", "Stop", resp, "Failure sending request") + return + } + + result, err = client.StopResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WatcherClient", "Stop", resp, "Failure responding to request") + } + + return +} + +// StopPreparer prepares the Stop request. +func (client WatcherClient) StopPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, watcherName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "watcherName": autorest.Encode("path", watcherName), + } + + 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}/watchers/{watcherName}/stop", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// StopSender sends the Stop request. The method will close the +// http.Response Body if it receives an error. +func (client WatcherClient) StopSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// StopResponder handles the response to the Stop request. The method always +// closes the http.Response Body. +func (client WatcherClient) StopResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Update update the watcher identified by watcher name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// watcherName - the watcher name. +// parameters - the update parameters for watcher. +func (client WatcherClient) Update(ctx context.Context, resourceGroupName string, automationAccountName string, watcherName string, parameters WatcherUpdateParameters) (result Watcher, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.WatcherClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, automationAccountName, watcherName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WatcherClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.WatcherClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WatcherClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client WatcherClient) UpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, watcherName string, parameters WatcherUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "watcherName": autorest.Encode("path", watcherName), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client WatcherClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client WatcherClient) UpdateResponder(resp *http.Response) (result Watcher, 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/preview/automation/mgmt/2018-06-30-preview/automation/webhook.go b/services/preview/automation/mgmt/2018-06-30-preview/automation/webhook.go new file mode 100644 index 000000000000..989daa4c5e47 --- /dev/null +++ b/services/preview/automation/mgmt/2018-06-30-preview/automation/webhook.go @@ -0,0 +1,539 @@ +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" +) + +// WebhookClient is the automation Client +type WebhookClient struct { + BaseClient +} + +// NewWebhookClient creates an instance of the WebhookClient client. +func NewWebhookClient(subscriptionID string, countType1 CountType) WebhookClient { + return NewWebhookClientWithBaseURI(DefaultBaseURI, subscriptionID, countType1) +} + +// NewWebhookClientWithBaseURI creates an instance of the WebhookClient client. +func NewWebhookClientWithBaseURI(baseURI string, subscriptionID string, countType1 CountType) WebhookClient { + return WebhookClient{NewWithBaseURI(baseURI, subscriptionID, countType1)} +} + +// CreateOrUpdate create the webhook identified by webhook name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// webhookName - the webhook name. +// parameters - the create or update parameters for webhook. +func (client WebhookClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, automationAccountName string, webhookName string, parameters WebhookCreateOrUpdateParameters) (result Webhook, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.WebhookCreateOrUpdateProperties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.WebhookClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, automationAccountName, webhookName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client WebhookClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, webhookName string, parameters WebhookCreateOrUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "webhookName": autorest.Encode("path", webhookName), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client WebhookClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client WebhookClient) CreateOrUpdateResponder(resp *http.Response) (result Webhook, 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 delete the webhook by name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// webhookName - the webhook name. +func (client WebhookClient) Delete(ctx context.Context, resourceGroupName string, automationAccountName string, webhookName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.WebhookClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, automationAccountName, webhookName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client WebhookClient) DeletePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, webhookName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "webhookName": autorest.Encode("path", webhookName), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client WebhookClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client WebhookClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// GenerateURI generates a Uri for use in creating a webhook. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +func (client WebhookClient) GenerateURI(ctx context.Context, resourceGroupName string, automationAccountName string) (result String, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.WebhookClient", "GenerateURI", err.Error()) + } + + req, err := client.GenerateURIPreparer(ctx, resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "GenerateURI", nil, "Failure preparing request") + return + } + + resp, err := client.GenerateURISender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "GenerateURI", resp, "Failure sending request") + return + } + + result, err = client.GenerateURIResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "GenerateURI", resp, "Failure responding to request") + } + + return +} + +// GenerateURIPreparer prepares the GenerateURI request. +func (client WebhookClient) GenerateURIPreparer(ctx context.Context, resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", 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}/webhooks/generateUri", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GenerateURISender sends the GenerateURI request. The method will close the +// http.Response Body if it receives an error. +func (client WebhookClient) GenerateURISender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GenerateURIResponder handles the response to the GenerateURI request. The method always +// closes the http.Response Body. +func (client WebhookClient) GenerateURIResponder(resp *http.Response) (result String, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Value), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get retrieve the webhook identified by webhook name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// webhookName - the webhook name. +func (client WebhookClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string, webhookName string) (result Webhook, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.WebhookClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName, webhookName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client WebhookClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, webhookName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "webhookName": autorest.Encode("path", webhookName), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client WebhookClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client WebhookClient) GetResponder(resp *http.Response) (result Webhook, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of webhooks. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// filter - the filter to apply on the operation. +func (client WebhookClient) ListByAutomationAccount(ctx context.Context, resourceGroupName string, automationAccountName string, filter string) (result WebhookListResultPage, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.WebhookClient", "ListByAutomationAccount", err.Error()) + } + + result.fn = client.listByAutomationAccountNextResults + req, err := client.ListByAutomationAccountPreparer(ctx, resourceGroupName, automationAccountName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.wlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result.wlr, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client WebhookClient) ListByAutomationAccountPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks", 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 WebhookClient) 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 WebhookClient) ListByAutomationAccountResponder(resp *http.Response) (result WebhookListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByAutomationAccountNextResults retrieves the next set of results, if any. +func (client WebhookClient) listByAutomationAccountNextResults(lastResults WebhookListResult) (result WebhookListResult, err error) { + req, err := lastResults.webhookListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.WebhookClient", "listByAutomationAccountNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.WebhookClient", "listByAutomationAccountNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "listByAutomationAccountNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByAutomationAccountComplete enumerates all values, automatically crossing page boundaries as required. +func (client WebhookClient) ListByAutomationAccountComplete(ctx context.Context, resourceGroupName string, automationAccountName string, filter string) (result WebhookListResultIterator, err error) { + result.page, err = client.ListByAutomationAccount(ctx, resourceGroupName, automationAccountName, filter) + return +} + +// Update update the webhook identified by webhook name. +// Parameters: +// resourceGroupName - name of an Azure Resource group. +// automationAccountName - the name of the automation account. +// webhookName - the webhook name. +// parameters - the update parameters for webhook. +func (client WebhookClient) Update(ctx context.Context, resourceGroupName string, automationAccountName string, webhookName string, parameters WebhookUpdateParameters) (result Webhook, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("automation.WebhookClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, automationAccountName, webhookName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client WebhookClient) UpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, webhookName string, parameters WebhookUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "webhookName": autorest.Encode("path", webhookName), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client WebhookClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client WebhookClient) UpdateResponder(resp *http.Response) (result Webhook, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +}