diff --git a/sdk/resourcemanager/scheduler/armscheduler/CHANGELOG.md b/sdk/resourcemanager/scheduler/armscheduler/CHANGELOG.md new file mode 100644 index 000000000000..f3d80a0b8362 --- /dev/null +++ b/sdk/resourcemanager/scheduler/armscheduler/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 0.1.0 (2021-10-26) + +- Initial preview release. diff --git a/sdk/resourcemanager/scheduler/armscheduler/LICENSE.txt b/sdk/resourcemanager/scheduler/armscheduler/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/scheduler/armscheduler/LICENSE.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) Microsoft Corporation. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/sdk/resourcemanager/scheduler/armscheduler/README.md b/sdk/resourcemanager/scheduler/armscheduler/README.md new file mode 100644 index 000000000000..faffae7cd5a4 --- /dev/null +++ b/sdk/resourcemanager/scheduler/armscheduler/README.md @@ -0,0 +1,76 @@ +# Azure Scheduler Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/scheduler/armscheduler)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/scheduler/armscheduler) + +The `armscheduler` module provides operations for working with Azure Scheduler. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/scheduler/armscheduler) + +# Getting started + +## Prerequisites + +- an [Azure subscription](https://azure.microsoft.com/free/) +- Go 1.13 or above + +## Install the package + +This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for versioning and dependency management. + +Install the Azure Scheduler module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/scheduler/armscheduler +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Scheduler. The `azidentity` module provides facilities for various ways of authenticating with Azure including client/secret, certificate, managed identity, and more. + +```go +cred, err := azidentity.NewDefaultAzureCredential(nil) +``` + +For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). + +## Connecting to Azure Scheduler + +Once you have a credential, create a connection to the desired ARM endpoint. The `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` package provides facilities for connecting with ARM endpoints including public and sovereign clouds as well as Azure Stack. + +```go +con := arm.NewDefaultConnection(cred, nil) +``` + +For more information on ARM connections, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). + +## Clients + +Azure Scheduler modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. Create one or more clients to access the APIs you require using your `arm.Connection`. + +```go +client := armscheduler.NewJobCollectionsClient(con, "") +``` + +## Provide Feedback + +If you encounter bugs or have suggestions, please +[open an issue](https://github.com/Azure/azure-sdk-for-go/issues) and assign the `Scheduler` label. + +# Contributing + +This project welcomes contributions and suggestions. Most contributions require +you to agree to a Contributor License Agreement (CLA) declaring that you have +the right to, and actually do, grant us the rights to use your contribution. +For details, visit [https://cla.microsoft.com](https://cla.microsoft.com). + +When you submit a pull request, a CLA-bot will automatically determine whether +you need to provide a CLA and decorate the PR appropriately (e.g., label, +comment). Simply follow the instructions provided by the bot. You will only +need to do this once across all repos using our CLA. + +This project has adopted the +[Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). +For more information, see the +[Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) +or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any +additional questions or comments. \ No newline at end of file diff --git a/sdk/resourcemanager/scheduler/armscheduler/autorest.md b/sdk/resourcemanager/scheduler/armscheduler/autorest.md new file mode 100644 index 000000000000..56b016db82cb --- /dev/null +++ b/sdk/resourcemanager/scheduler/armscheduler/autorest.md @@ -0,0 +1,12 @@ +### AutoRest Configuration + +> see https://aka.ms/autorest + +``` yaml +azure-arm: true +require: +- https://github.com/Azure/azure-rest-api-specs/blob/3c16aae50c7110e1aad241ac93995621d4093d46/specification/scheduler/resource-manager/readme.md +- https://github.com/Azure/azure-rest-api-specs/blob/3c16aae50c7110e1aad241ac93995621d4093d46/specification/scheduler/resource-manager/readme.go.md +license-header: MICROSOFT_MIT_NO_VERSION +module-version: 0.1.0 +``` \ No newline at end of file diff --git a/sdk/resourcemanager/scheduler/armscheduler/build.go b/sdk/resourcemanager/scheduler/armscheduler/build.go new file mode 100644 index 000000000000..9dc40495ea33 --- /dev/null +++ b/sdk/resourcemanager/scheduler/armscheduler/build.go @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +// This file enables 'go generate' to regenerate this specific SDK +//go:generate pwsh.exe ../../../../eng/scripts/build.ps1 -skipBuild -cleanGenerated -format -tidy -generate resourcemanager/scheduler/armscheduler + +package armscheduler diff --git a/sdk/resourcemanager/scheduler/armscheduler/ci.yml b/sdk/resourcemanager/scheduler/armscheduler/ci.yml new file mode 100644 index 000000000000..3b5e9596fa77 --- /dev/null +++ b/sdk/resourcemanager/scheduler/armscheduler/ci.yml @@ -0,0 +1,27 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. +trigger: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/scheduler/armscheduler/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/scheduler/armscheduler/ + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + ServiceDirectory: 'resourcemanager/scheduler/armscheduler' diff --git a/sdk/resourcemanager/scheduler/armscheduler/go.mod b/sdk/resourcemanager/scheduler/armscheduler/go.mod new file mode 100644 index 000000000000..12696170eaf6 --- /dev/null +++ b/sdk/resourcemanager/scheduler/armscheduler/go.mod @@ -0,0 +1,8 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/scheduler/armscheduler + +go 1.16 + +require ( + github.com/Azure/azure-sdk-for-go v58.2.0+incompatible + github.com/Azure/azure-sdk-for-go/sdk/azcore v0.19.0 +) diff --git a/sdk/resourcemanager/scheduler/armscheduler/go.sum b/sdk/resourcemanager/scheduler/armscheduler/go.sum new file mode 100644 index 000000000000..c8ff7a2143ad --- /dev/null +++ b/sdk/resourcemanager/scheduler/armscheduler/go.sum @@ -0,0 +1,30 @@ +github.com/Azure/azure-sdk-for-go v58.2.0+incompatible h1:iCb2tuoEm3N7ZpUDOvu1Yxl1B3iOVDmaD6weaRuIPzs= +github.com/Azure/azure-sdk-for-go v58.2.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.19.0 h1:lhSJz9RMbJcTgxifR1hUNJnn6CNYtbgEDtQV22/9RBA= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.19.0/go.mod h1:h6H6c8enJmmocHUbLiiGY6sx7f9i+X3m1CHdd5c6Rdw= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.7.0 h1:v9p9TfTbf7AwNb5NYQt7hI41IfPoLFiFkLtb+bmGjT0= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.7.0/go.mod h1:yqy467j36fJxcRV2TzfVZ1pCb5vxm4BtZPUdYWe/Xo8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ= +github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +golang.org/x/net v0.0.0-20210610132358-84b48f89b13b h1:k+E048sYJHyVnsr1GDrRZWQ32D2C7lWs9JRc0bel53A= +golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/resourcemanager/scheduler/armscheduler/go_mod_tidy_hack.go b/sdk/resourcemanager/scheduler/armscheduler/go_mod_tidy_hack.go new file mode 100644 index 000000000000..4cfe3183febf --- /dev/null +++ b/sdk/resourcemanager/scheduler/armscheduler/go_mod_tidy_hack.go @@ -0,0 +1,13 @@ +//go:build modhack +// +build modhack + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +// This file, and the github.com/Azure/azure-sdk-for-go import, won't actually become part of +// the resultant binary. + +package armscheduler + +// Necessary for safely adding multi-module repo. See: https://github.com/golang/go/wiki/Modules#is-it-possible-to-add-a-module-to-a-multi-module-repository +import _ "github.com/Azure/azure-sdk-for-go" diff --git a/sdk/resourcemanager/scheduler/armscheduler/zz_generated_constants.go b/sdk/resourcemanager/scheduler/armscheduler/zz_generated_constants.go new file mode 100644 index 000000000000..887a1399a2ba --- /dev/null +++ b/sdk/resourcemanager/scheduler/armscheduler/zz_generated_constants.go @@ -0,0 +1,338 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armscheduler + +const ( + module = "armscheduler" + version = "v0.1.0" +) + +type DayOfWeek string + +const ( + DayOfWeekSunday DayOfWeek = "Sunday" + DayOfWeekMonday DayOfWeek = "Monday" + DayOfWeekTuesday DayOfWeek = "Tuesday" + DayOfWeekWednesday DayOfWeek = "Wednesday" + DayOfWeekThursday DayOfWeek = "Thursday" + DayOfWeekFriday DayOfWeek = "Friday" + DayOfWeekSaturday DayOfWeek = "Saturday" +) + +// PossibleDayOfWeekValues returns the possible values for the DayOfWeek const type. +func PossibleDayOfWeekValues() []DayOfWeek { + return []DayOfWeek{ + DayOfWeekSunday, + DayOfWeekMonday, + DayOfWeekTuesday, + DayOfWeekWednesday, + DayOfWeekThursday, + DayOfWeekFriday, + DayOfWeekSaturday, + } +} + +// ToPtr returns a *DayOfWeek pointing to the current value. +func (c DayOfWeek) ToPtr() *DayOfWeek { + return &c +} + +// HTTPAuthenticationType - Gets or sets the HTTP authentication type. +type HTTPAuthenticationType string + +const ( + HTTPAuthenticationTypeNotSpecified HTTPAuthenticationType = "NotSpecified" + HTTPAuthenticationTypeClientCertificate HTTPAuthenticationType = "ClientCertificate" + HTTPAuthenticationTypeActiveDirectoryOAuth HTTPAuthenticationType = "ActiveDirectoryOAuth" + HTTPAuthenticationTypeBasic HTTPAuthenticationType = "Basic" +) + +// PossibleHTTPAuthenticationTypeValues returns the possible values for the HTTPAuthenticationType const type. +func PossibleHTTPAuthenticationTypeValues() []HTTPAuthenticationType { + return []HTTPAuthenticationType{ + HTTPAuthenticationTypeNotSpecified, + HTTPAuthenticationTypeClientCertificate, + HTTPAuthenticationTypeActiveDirectoryOAuth, + HTTPAuthenticationTypeBasic, + } +} + +// ToPtr returns a *HTTPAuthenticationType pointing to the current value. +func (c HTTPAuthenticationType) ToPtr() *HTTPAuthenticationType { + return &c +} + +// JobActionType - Gets or sets the job action type. +type JobActionType string + +const ( + JobActionTypeHTTP JobActionType = "Http" + JobActionTypeHTTPS JobActionType = "Https" + JobActionTypeStorageQueue JobActionType = "StorageQueue" + JobActionTypeServiceBusQueue JobActionType = "ServiceBusQueue" + JobActionTypeServiceBusTopic JobActionType = "ServiceBusTopic" +) + +// PossibleJobActionTypeValues returns the possible values for the JobActionType const type. +func PossibleJobActionTypeValues() []JobActionType { + return []JobActionType{ + JobActionTypeHTTP, + JobActionTypeHTTPS, + JobActionTypeStorageQueue, + JobActionTypeServiceBusQueue, + JobActionTypeServiceBusTopic, + } +} + +// ToPtr returns a *JobActionType pointing to the current value. +func (c JobActionType) ToPtr() *JobActionType { + return &c +} + +// JobCollectionState - Gets or sets the state. +type JobCollectionState string + +const ( + JobCollectionStateEnabled JobCollectionState = "Enabled" + JobCollectionStateDisabled JobCollectionState = "Disabled" + JobCollectionStateSuspended JobCollectionState = "Suspended" + JobCollectionStateDeleted JobCollectionState = "Deleted" +) + +// PossibleJobCollectionStateValues returns the possible values for the JobCollectionState const type. +func PossibleJobCollectionStateValues() []JobCollectionState { + return []JobCollectionState{ + JobCollectionStateEnabled, + JobCollectionStateDisabled, + JobCollectionStateSuspended, + JobCollectionStateDeleted, + } +} + +// ToPtr returns a *JobCollectionState pointing to the current value. +func (c JobCollectionState) ToPtr() *JobCollectionState { + return &c +} + +// JobExecutionStatus - Gets the job execution status. +type JobExecutionStatus string + +const ( + JobExecutionStatusCompleted JobExecutionStatus = "Completed" + JobExecutionStatusFailed JobExecutionStatus = "Failed" + JobExecutionStatusPostponed JobExecutionStatus = "Postponed" +) + +// PossibleJobExecutionStatusValues returns the possible values for the JobExecutionStatus const type. +func PossibleJobExecutionStatusValues() []JobExecutionStatus { + return []JobExecutionStatus{ + JobExecutionStatusCompleted, + JobExecutionStatusFailed, + JobExecutionStatusPostponed, + } +} + +// ToPtr returns a *JobExecutionStatus pointing to the current value. +func (c JobExecutionStatus) ToPtr() *JobExecutionStatus { + return &c +} + +// JobHistoryActionName - Gets the job history action name. +type JobHistoryActionName string + +const ( + JobHistoryActionNameMainAction JobHistoryActionName = "MainAction" + JobHistoryActionNameErrorAction JobHistoryActionName = "ErrorAction" +) + +// PossibleJobHistoryActionNameValues returns the possible values for the JobHistoryActionName const type. +func PossibleJobHistoryActionNameValues() []JobHistoryActionName { + return []JobHistoryActionName{ + JobHistoryActionNameMainAction, + JobHistoryActionNameErrorAction, + } +} + +// ToPtr returns a *JobHistoryActionName pointing to the current value. +func (c JobHistoryActionName) ToPtr() *JobHistoryActionName { + return &c +} + +// JobScheduleDay - Gets or sets the day. Must be one of monday, tuesday, wednesday, thursday, friday, saturday, sunday. +type JobScheduleDay string + +const ( + JobScheduleDayMonday JobScheduleDay = "Monday" + JobScheduleDayTuesday JobScheduleDay = "Tuesday" + JobScheduleDayWednesday JobScheduleDay = "Wednesday" + JobScheduleDayThursday JobScheduleDay = "Thursday" + JobScheduleDayFriday JobScheduleDay = "Friday" + JobScheduleDaySaturday JobScheduleDay = "Saturday" + JobScheduleDaySunday JobScheduleDay = "Sunday" +) + +// PossibleJobScheduleDayValues returns the possible values for the JobScheduleDay const type. +func PossibleJobScheduleDayValues() []JobScheduleDay { + return []JobScheduleDay{ + JobScheduleDayMonday, + JobScheduleDayTuesday, + JobScheduleDayWednesday, + JobScheduleDayThursday, + JobScheduleDayFriday, + JobScheduleDaySaturday, + JobScheduleDaySunday, + } +} + +// ToPtr returns a *JobScheduleDay pointing to the current value. +func (c JobScheduleDay) ToPtr() *JobScheduleDay { + return &c +} + +// JobState - Gets or set the job state. +type JobState string + +const ( + JobStateEnabled JobState = "Enabled" + JobStateDisabled JobState = "Disabled" + JobStateFaulted JobState = "Faulted" + JobStateCompleted JobState = "Completed" +) + +// PossibleJobStateValues returns the possible values for the JobState const type. +func PossibleJobStateValues() []JobState { + return []JobState{ + JobStateEnabled, + JobStateDisabled, + JobStateFaulted, + JobStateCompleted, + } +} + +// ToPtr returns a *JobState pointing to the current value. +func (c JobState) ToPtr() *JobState { + return &c +} + +// RecurrenceFrequency - Gets or sets the frequency of recurrence (second, minute, hour, day, week, month). +type RecurrenceFrequency string + +const ( + RecurrenceFrequencyMinute RecurrenceFrequency = "Minute" + RecurrenceFrequencyHour RecurrenceFrequency = "Hour" + RecurrenceFrequencyDay RecurrenceFrequency = "Day" + RecurrenceFrequencyWeek RecurrenceFrequency = "Week" + RecurrenceFrequencyMonth RecurrenceFrequency = "Month" +) + +// PossibleRecurrenceFrequencyValues returns the possible values for the RecurrenceFrequency const type. +func PossibleRecurrenceFrequencyValues() []RecurrenceFrequency { + return []RecurrenceFrequency{ + RecurrenceFrequencyMinute, + RecurrenceFrequencyHour, + RecurrenceFrequencyDay, + RecurrenceFrequencyWeek, + RecurrenceFrequencyMonth, + } +} + +// ToPtr returns a *RecurrenceFrequency pointing to the current value. +func (c RecurrenceFrequency) ToPtr() *RecurrenceFrequency { + return &c +} + +// RetryType - Gets or sets the retry strategy to be used. +type RetryType string + +const ( + RetryTypeNone RetryType = "None" + RetryTypeFixed RetryType = "Fixed" +) + +// PossibleRetryTypeValues returns the possible values for the RetryType const type. +func PossibleRetryTypeValues() []RetryType { + return []RetryType{ + RetryTypeNone, + RetryTypeFixed, + } +} + +// ToPtr returns a *RetryType pointing to the current value. +func (c RetryType) ToPtr() *RetryType { + return &c +} + +// SKUDefinition - Gets or set the SKU. +type SKUDefinition string + +const ( + SKUDefinitionStandard SKUDefinition = "Standard" + SKUDefinitionFree SKUDefinition = "Free" + SKUDefinitionP10Premium SKUDefinition = "P10Premium" + SKUDefinitionP20Premium SKUDefinition = "P20Premium" +) + +// PossibleSKUDefinitionValues returns the possible values for the SKUDefinition const type. +func PossibleSKUDefinitionValues() []SKUDefinition { + return []SKUDefinition{ + SKUDefinitionStandard, + SKUDefinitionFree, + SKUDefinitionP10Premium, + SKUDefinitionP20Premium, + } +} + +// ToPtr returns a *SKUDefinition pointing to the current value. +func (c SKUDefinition) ToPtr() *SKUDefinition { + return &c +} + +// ServiceBusAuthenticationType - Gets or sets the authentication type. +type ServiceBusAuthenticationType string + +const ( + ServiceBusAuthenticationTypeNotSpecified ServiceBusAuthenticationType = "NotSpecified" + ServiceBusAuthenticationTypeSharedAccessKey ServiceBusAuthenticationType = "SharedAccessKey" +) + +// PossibleServiceBusAuthenticationTypeValues returns the possible values for the ServiceBusAuthenticationType const type. +func PossibleServiceBusAuthenticationTypeValues() []ServiceBusAuthenticationType { + return []ServiceBusAuthenticationType{ + ServiceBusAuthenticationTypeNotSpecified, + ServiceBusAuthenticationTypeSharedAccessKey, + } +} + +// ToPtr returns a *ServiceBusAuthenticationType pointing to the current value. +func (c ServiceBusAuthenticationType) ToPtr() *ServiceBusAuthenticationType { + return &c +} + +// ServiceBusTransportType - Gets or sets the transport type. +type ServiceBusTransportType string + +const ( + ServiceBusTransportTypeNotSpecified ServiceBusTransportType = "NotSpecified" + ServiceBusTransportTypeNetMessaging ServiceBusTransportType = "NetMessaging" + ServiceBusTransportTypeAMQP ServiceBusTransportType = "AMQP" +) + +// PossibleServiceBusTransportTypeValues returns the possible values for the ServiceBusTransportType const type. +func PossibleServiceBusTransportTypeValues() []ServiceBusTransportType { + return []ServiceBusTransportType{ + ServiceBusTransportTypeNotSpecified, + ServiceBusTransportTypeNetMessaging, + ServiceBusTransportTypeAMQP, + } +} + +// ToPtr returns a *ServiceBusTransportType pointing to the current value. +func (c ServiceBusTransportType) ToPtr() *ServiceBusTransportType { + return &c +} diff --git a/sdk/resourcemanager/scheduler/armscheduler/zz_generated_jobcollections_client.go b/sdk/resourcemanager/scheduler/armscheduler/zz_generated_jobcollections_client.go new file mode 100644 index 000000000000..298ea82dd6a7 --- /dev/null +++ b/sdk/resourcemanager/scheduler/armscheduler/zz_generated_jobcollections_client.go @@ -0,0 +1,559 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armscheduler + +import ( + "context" + "errors" + "net/http" + "net/url" + "strings" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" +) + +// JobCollectionsClient contains the methods for the JobCollections group. +// Don't use this type directly, use NewJobCollectionsClient() instead. +type JobCollectionsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewJobCollectionsClient creates a new instance of JobCollectionsClient with the specified values. +func NewJobCollectionsClient(con *arm.Connection, subscriptionID string) *JobCollectionsClient { + return &JobCollectionsClient{ep: con.Endpoint(), pl: con.NewPipeline(module, version), subscriptionID: subscriptionID} +} + +// CreateOrUpdate - Provisions a new job collection or updates an existing job collection. +// If the operation fails it returns a generic error. +func (client *JobCollectionsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, jobCollectionName string, jobCollection JobCollectionDefinition, options *JobCollectionsCreateOrUpdateOptions) (JobCollectionsCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, jobCollectionName, jobCollection, options) + if err != nil { + return JobCollectionsCreateOrUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return JobCollectionsCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return JobCollectionsCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *JobCollectionsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, jobCollectionName string, jobCollection JobCollectionDefinition, options *JobCollectionsCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Scheduler/jobCollections/{jobCollectionName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if jobCollectionName == "" { + return nil, errors.New("parameter jobCollectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{jobCollectionName}", url.PathEscape(jobCollectionName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2016-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json, text/json") + return req, runtime.MarshalAsJSON(req, jobCollection) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *JobCollectionsClient) createOrUpdateHandleResponse(resp *http.Response) (JobCollectionsCreateOrUpdateResponse, error) { + result := JobCollectionsCreateOrUpdateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.JobCollectionDefinition); err != nil { + return JobCollectionsCreateOrUpdateResponse{}, err + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *JobCollectionsClient) createOrUpdateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + if len(body) == 0 { + return runtime.NewResponseError(errors.New(resp.Status), resp) + } + return runtime.NewResponseError(errors.New(string(body)), resp) +} + +// BeginDelete - Deletes a job collection. +// If the operation fails it returns a generic error. +func (client *JobCollectionsClient) BeginDelete(ctx context.Context, resourceGroupName string, jobCollectionName string, options *JobCollectionsBeginDeleteOptions) (JobCollectionsDeletePollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, jobCollectionName, options) + if err != nil { + return JobCollectionsDeletePollerResponse{}, err + } + result := JobCollectionsDeletePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("JobCollectionsClient.Delete", "", resp, client.pl, client.deleteHandleError) + if err != nil { + return JobCollectionsDeletePollerResponse{}, err + } + result.Poller = &JobCollectionsDeletePoller{ + pt: pt, + } + return result, nil +} + +// Delete - Deletes a job collection. +// If the operation fails it returns a generic error. +func (client *JobCollectionsClient) deleteOperation(ctx context.Context, resourceGroupName string, jobCollectionName string, options *JobCollectionsBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, jobCollectionName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { + return nil, client.deleteHandleError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *JobCollectionsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, jobCollectionName string, options *JobCollectionsBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Scheduler/jobCollections/{jobCollectionName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if jobCollectionName == "" { + return nil, errors.New("parameter jobCollectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{jobCollectionName}", url.PathEscape(jobCollectionName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2016-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *JobCollectionsClient) deleteHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + if len(body) == 0 { + return runtime.NewResponseError(errors.New(resp.Status), resp) + } + return runtime.NewResponseError(errors.New(string(body)), resp) +} + +// BeginDisable - Disables all of the jobs in the job collection. +// If the operation fails it returns a generic error. +func (client *JobCollectionsClient) BeginDisable(ctx context.Context, resourceGroupName string, jobCollectionName string, options *JobCollectionsBeginDisableOptions) (JobCollectionsDisablePollerResponse, error) { + resp, err := client.disable(ctx, resourceGroupName, jobCollectionName, options) + if err != nil { + return JobCollectionsDisablePollerResponse{}, err + } + result := JobCollectionsDisablePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("JobCollectionsClient.Disable", "", resp, client.pl, client.disableHandleError) + if err != nil { + return JobCollectionsDisablePollerResponse{}, err + } + result.Poller = &JobCollectionsDisablePoller{ + pt: pt, + } + return result, nil +} + +// Disable - Disables all of the jobs in the job collection. +// If the operation fails it returns a generic error. +func (client *JobCollectionsClient) disable(ctx context.Context, resourceGroupName string, jobCollectionName string, options *JobCollectionsBeginDisableOptions) (*http.Response, error) { + req, err := client.disableCreateRequest(ctx, resourceGroupName, jobCollectionName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { + return nil, client.disableHandleError(resp) + } + return resp, nil +} + +// disableCreateRequest creates the Disable request. +func (client *JobCollectionsClient) disableCreateRequest(ctx context.Context, resourceGroupName string, jobCollectionName string, options *JobCollectionsBeginDisableOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Scheduler/jobCollections/{jobCollectionName}/disable" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if jobCollectionName == "" { + return nil, errors.New("parameter jobCollectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{jobCollectionName}", url.PathEscape(jobCollectionName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2016-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + return req, nil +} + +// disableHandleError handles the Disable error response. +func (client *JobCollectionsClient) disableHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + if len(body) == 0 { + return runtime.NewResponseError(errors.New(resp.Status), resp) + } + return runtime.NewResponseError(errors.New(string(body)), resp) +} + +// BeginEnable - Enables all of the jobs in the job collection. +// If the operation fails it returns a generic error. +func (client *JobCollectionsClient) BeginEnable(ctx context.Context, resourceGroupName string, jobCollectionName string, options *JobCollectionsBeginEnableOptions) (JobCollectionsEnablePollerResponse, error) { + resp, err := client.enable(ctx, resourceGroupName, jobCollectionName, options) + if err != nil { + return JobCollectionsEnablePollerResponse{}, err + } + result := JobCollectionsEnablePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("JobCollectionsClient.Enable", "", resp, client.pl, client.enableHandleError) + if err != nil { + return JobCollectionsEnablePollerResponse{}, err + } + result.Poller = &JobCollectionsEnablePoller{ + pt: pt, + } + return result, nil +} + +// Enable - Enables all of the jobs in the job collection. +// If the operation fails it returns a generic error. +func (client *JobCollectionsClient) enable(ctx context.Context, resourceGroupName string, jobCollectionName string, options *JobCollectionsBeginEnableOptions) (*http.Response, error) { + req, err := client.enableCreateRequest(ctx, resourceGroupName, jobCollectionName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { + return nil, client.enableHandleError(resp) + } + return resp, nil +} + +// enableCreateRequest creates the Enable request. +func (client *JobCollectionsClient) enableCreateRequest(ctx context.Context, resourceGroupName string, jobCollectionName string, options *JobCollectionsBeginEnableOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Scheduler/jobCollections/{jobCollectionName}/enable" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if jobCollectionName == "" { + return nil, errors.New("parameter jobCollectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{jobCollectionName}", url.PathEscape(jobCollectionName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2016-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + return req, nil +} + +// enableHandleError handles the Enable error response. +func (client *JobCollectionsClient) enableHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + if len(body) == 0 { + return runtime.NewResponseError(errors.New(resp.Status), resp) + } + return runtime.NewResponseError(errors.New(string(body)), resp) +} + +// Get - Gets a job collection. +// If the operation fails it returns a generic error. +func (client *JobCollectionsClient) Get(ctx context.Context, resourceGroupName string, jobCollectionName string, options *JobCollectionsGetOptions) (JobCollectionsGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, jobCollectionName, options) + if err != nil { + return JobCollectionsGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return JobCollectionsGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return JobCollectionsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *JobCollectionsClient) getCreateRequest(ctx context.Context, resourceGroupName string, jobCollectionName string, options *JobCollectionsGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Scheduler/jobCollections/{jobCollectionName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if jobCollectionName == "" { + return nil, errors.New("parameter jobCollectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{jobCollectionName}", url.PathEscape(jobCollectionName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2016-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json, text/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *JobCollectionsClient) getHandleResponse(resp *http.Response) (JobCollectionsGetResponse, error) { + result := JobCollectionsGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.JobCollectionDefinition); err != nil { + return JobCollectionsGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *JobCollectionsClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + if len(body) == 0 { + return runtime.NewResponseError(errors.New(resp.Status), resp) + } + return runtime.NewResponseError(errors.New(string(body)), resp) +} + +// ListByResourceGroup - Gets all job collections under specified resource group. +// If the operation fails it returns a generic error. +func (client *JobCollectionsClient) ListByResourceGroup(resourceGroupName string, options *JobCollectionsListByResourceGroupOptions) *JobCollectionsListByResourceGroupPager { + return &JobCollectionsListByResourceGroupPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + }, + advancer: func(ctx context.Context, resp JobCollectionsListByResourceGroupResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.JobCollectionListResult.NextLink) + }, + } +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *JobCollectionsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *JobCollectionsListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Scheduler/jobCollections" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2016-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json, text/json") + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *JobCollectionsClient) listByResourceGroupHandleResponse(resp *http.Response) (JobCollectionsListByResourceGroupResponse, error) { + result := JobCollectionsListByResourceGroupResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.JobCollectionListResult); err != nil { + return JobCollectionsListByResourceGroupResponse{}, err + } + return result, nil +} + +// listByResourceGroupHandleError handles the ListByResourceGroup error response. +func (client *JobCollectionsClient) listByResourceGroupHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + if len(body) == 0 { + return runtime.NewResponseError(errors.New(resp.Status), resp) + } + return runtime.NewResponseError(errors.New(string(body)), resp) +} + +// ListBySubscription - Gets all job collections under specified subscription. +// If the operation fails it returns a generic error. +func (client *JobCollectionsClient) ListBySubscription(options *JobCollectionsListBySubscriptionOptions) *JobCollectionsListBySubscriptionPager { + return &JobCollectionsListBySubscriptionPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listBySubscriptionCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp JobCollectionsListBySubscriptionResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.JobCollectionListResult.NextLink) + }, + } +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *JobCollectionsClient) listBySubscriptionCreateRequest(ctx context.Context, options *JobCollectionsListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Scheduler/jobCollections" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2016-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json, text/json") + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *JobCollectionsClient) listBySubscriptionHandleResponse(resp *http.Response) (JobCollectionsListBySubscriptionResponse, error) { + result := JobCollectionsListBySubscriptionResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.JobCollectionListResult); err != nil { + return JobCollectionsListBySubscriptionResponse{}, err + } + return result, nil +} + +// listBySubscriptionHandleError handles the ListBySubscription error response. +func (client *JobCollectionsClient) listBySubscriptionHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + if len(body) == 0 { + return runtime.NewResponseError(errors.New(resp.Status), resp) + } + return runtime.NewResponseError(errors.New(string(body)), resp) +} + +// Patch - Patches an existing job collection. +// If the operation fails it returns a generic error. +func (client *JobCollectionsClient) Patch(ctx context.Context, resourceGroupName string, jobCollectionName string, jobCollection JobCollectionDefinition, options *JobCollectionsPatchOptions) (JobCollectionsPatchResponse, error) { + req, err := client.patchCreateRequest(ctx, resourceGroupName, jobCollectionName, jobCollection, options) + if err != nil { + return JobCollectionsPatchResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return JobCollectionsPatchResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return JobCollectionsPatchResponse{}, client.patchHandleError(resp) + } + return client.patchHandleResponse(resp) +} + +// patchCreateRequest creates the Patch request. +func (client *JobCollectionsClient) patchCreateRequest(ctx context.Context, resourceGroupName string, jobCollectionName string, jobCollection JobCollectionDefinition, options *JobCollectionsPatchOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Scheduler/jobCollections/{jobCollectionName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if jobCollectionName == "" { + return nil, errors.New("parameter jobCollectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{jobCollectionName}", url.PathEscape(jobCollectionName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2016-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json, text/json") + return req, runtime.MarshalAsJSON(req, jobCollection) +} + +// patchHandleResponse handles the Patch response. +func (client *JobCollectionsClient) patchHandleResponse(resp *http.Response) (JobCollectionsPatchResponse, error) { + result := JobCollectionsPatchResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.JobCollectionDefinition); err != nil { + return JobCollectionsPatchResponse{}, err + } + return result, nil +} + +// patchHandleError handles the Patch error response. +func (client *JobCollectionsClient) patchHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + if len(body) == 0 { + return runtime.NewResponseError(errors.New(resp.Status), resp) + } + return runtime.NewResponseError(errors.New(string(body)), resp) +} diff --git a/sdk/resourcemanager/scheduler/armscheduler/zz_generated_jobs_client.go b/sdk/resourcemanager/scheduler/armscheduler/zz_generated_jobs_client.go new file mode 100644 index 000000000000..b891fa1593b1 --- /dev/null +++ b/sdk/resourcemanager/scheduler/armscheduler/zz_generated_jobs_client.go @@ -0,0 +1,499 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armscheduler + +import ( + "context" + "errors" + "net/http" + "net/url" + "strconv" + "strings" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" +) + +// JobsClient contains the methods for the Jobs group. +// Don't use this type directly, use NewJobsClient() instead. +type JobsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewJobsClient creates a new instance of JobsClient with the specified values. +func NewJobsClient(con *arm.Connection, subscriptionID string) *JobsClient { + return &JobsClient{ep: con.Endpoint(), pl: con.NewPipeline(module, version), subscriptionID: subscriptionID} +} + +// CreateOrUpdate - Provisions a new job or updates an existing job. +// If the operation fails it returns a generic error. +func (client *JobsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, jobCollectionName string, jobName string, job JobDefinition, options *JobsCreateOrUpdateOptions) (JobsCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, jobCollectionName, jobName, job, options) + if err != nil { + return JobsCreateOrUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return JobsCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return JobsCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *JobsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, jobCollectionName string, jobName string, job JobDefinition, options *JobsCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Scheduler/jobCollections/{jobCollectionName}/jobs/{jobName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if jobCollectionName == "" { + return nil, errors.New("parameter jobCollectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{jobCollectionName}", url.PathEscape(jobCollectionName)) + if jobName == "" { + return nil, errors.New("parameter jobName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{jobName}", url.PathEscape(jobName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2016-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json, text/json") + return req, runtime.MarshalAsJSON(req, job) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *JobsClient) createOrUpdateHandleResponse(resp *http.Response) (JobsCreateOrUpdateResponse, error) { + result := JobsCreateOrUpdateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.JobDefinition); err != nil { + return JobsCreateOrUpdateResponse{}, err + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *JobsClient) createOrUpdateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + if len(body) == 0 { + return runtime.NewResponseError(errors.New(resp.Status), resp) + } + return runtime.NewResponseError(errors.New(string(body)), resp) +} + +// Delete - Deletes a job. +// If the operation fails it returns a generic error. +func (client *JobsClient) Delete(ctx context.Context, resourceGroupName string, jobCollectionName string, jobName string, options *JobsDeleteOptions) (JobsDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, jobCollectionName, jobName, options) + if err != nil { + return JobsDeleteResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return JobsDeleteResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return JobsDeleteResponse{}, client.deleteHandleError(resp) + } + return JobsDeleteResponse{RawResponse: resp}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *JobsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, jobCollectionName string, jobName string, options *JobsDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Scheduler/jobCollections/{jobCollectionName}/jobs/{jobName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if jobCollectionName == "" { + return nil, errors.New("parameter jobCollectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{jobCollectionName}", url.PathEscape(jobCollectionName)) + if jobName == "" { + return nil, errors.New("parameter jobName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{jobName}", url.PathEscape(jobName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2016-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *JobsClient) deleteHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + if len(body) == 0 { + return runtime.NewResponseError(errors.New(resp.Status), resp) + } + return runtime.NewResponseError(errors.New(string(body)), resp) +} + +// Get - Gets a job. +// If the operation fails it returns a generic error. +func (client *JobsClient) Get(ctx context.Context, resourceGroupName string, jobCollectionName string, jobName string, options *JobsGetOptions) (JobsGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, jobCollectionName, jobName, options) + if err != nil { + return JobsGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return JobsGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return JobsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *JobsClient) getCreateRequest(ctx context.Context, resourceGroupName string, jobCollectionName string, jobName string, options *JobsGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Scheduler/jobCollections/{jobCollectionName}/jobs/{jobName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if jobCollectionName == "" { + return nil, errors.New("parameter jobCollectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{jobCollectionName}", url.PathEscape(jobCollectionName)) + if jobName == "" { + return nil, errors.New("parameter jobName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{jobName}", url.PathEscape(jobName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2016-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json, text/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *JobsClient) getHandleResponse(resp *http.Response) (JobsGetResponse, error) { + result := JobsGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.JobDefinition); err != nil { + return JobsGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *JobsClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + if len(body) == 0 { + return runtime.NewResponseError(errors.New(resp.Status), resp) + } + return runtime.NewResponseError(errors.New(string(body)), resp) +} + +// List - Lists all jobs under the specified job collection. +// If the operation fails it returns a generic error. +func (client *JobsClient) List(resourceGroupName string, jobCollectionName string, options *JobsListOptions) *JobsListPager { + return &JobsListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, jobCollectionName, options) + }, + advancer: func(ctx context.Context, resp JobsListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.JobListResult.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *JobsClient) listCreateRequest(ctx context.Context, resourceGroupName string, jobCollectionName string, options *JobsListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Scheduler/jobCollections/{jobCollectionName}/jobs" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if jobCollectionName == "" { + return nil, errors.New("parameter jobCollectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{jobCollectionName}", url.PathEscape(jobCollectionName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2016-03-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + if options != nil && options.Skip != nil { + reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) + } + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json, text/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *JobsClient) listHandleResponse(resp *http.Response) (JobsListResponse, error) { + result := JobsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.JobListResult); err != nil { + return JobsListResponse{}, err + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *JobsClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + if len(body) == 0 { + return runtime.NewResponseError(errors.New(resp.Status), resp) + } + return runtime.NewResponseError(errors.New(string(body)), resp) +} + +// ListJobHistory - Lists job history. +// If the operation fails it returns a generic error. +func (client *JobsClient) ListJobHistory(resourceGroupName string, jobCollectionName string, jobName string, options *JobsListJobHistoryOptions) *JobsListJobHistoryPager { + return &JobsListJobHistoryPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listJobHistoryCreateRequest(ctx, resourceGroupName, jobCollectionName, jobName, options) + }, + advancer: func(ctx context.Context, resp JobsListJobHistoryResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.JobHistoryListResult.NextLink) + }, + } +} + +// listJobHistoryCreateRequest creates the ListJobHistory request. +func (client *JobsClient) listJobHistoryCreateRequest(ctx context.Context, resourceGroupName string, jobCollectionName string, jobName string, options *JobsListJobHistoryOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Scheduler/jobCollections/{jobCollectionName}/jobs/{jobName}/history" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if jobCollectionName == "" { + return nil, errors.New("parameter jobCollectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{jobCollectionName}", url.PathEscape(jobCollectionName)) + if jobName == "" { + return nil, errors.New("parameter jobName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{jobName}", url.PathEscape(jobName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2016-03-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + if options != nil && options.Skip != nil { + reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) + } + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json, text/json") + return req, nil +} + +// listJobHistoryHandleResponse handles the ListJobHistory response. +func (client *JobsClient) listJobHistoryHandleResponse(resp *http.Response) (JobsListJobHistoryResponse, error) { + result := JobsListJobHistoryResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.JobHistoryListResult); err != nil { + return JobsListJobHistoryResponse{}, err + } + return result, nil +} + +// listJobHistoryHandleError handles the ListJobHistory error response. +func (client *JobsClient) listJobHistoryHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + if len(body) == 0 { + return runtime.NewResponseError(errors.New(resp.Status), resp) + } + return runtime.NewResponseError(errors.New(string(body)), resp) +} + +// Patch - Patches an existing job. +// If the operation fails it returns a generic error. +func (client *JobsClient) Patch(ctx context.Context, resourceGroupName string, jobCollectionName string, jobName string, job JobDefinition, options *JobsPatchOptions) (JobsPatchResponse, error) { + req, err := client.patchCreateRequest(ctx, resourceGroupName, jobCollectionName, jobName, job, options) + if err != nil { + return JobsPatchResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return JobsPatchResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return JobsPatchResponse{}, client.patchHandleError(resp) + } + return client.patchHandleResponse(resp) +} + +// patchCreateRequest creates the Patch request. +func (client *JobsClient) patchCreateRequest(ctx context.Context, resourceGroupName string, jobCollectionName string, jobName string, job JobDefinition, options *JobsPatchOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Scheduler/jobCollections/{jobCollectionName}/jobs/{jobName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if jobCollectionName == "" { + return nil, errors.New("parameter jobCollectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{jobCollectionName}", url.PathEscape(jobCollectionName)) + if jobName == "" { + return nil, errors.New("parameter jobName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{jobName}", url.PathEscape(jobName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2016-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json, text/json") + return req, runtime.MarshalAsJSON(req, job) +} + +// patchHandleResponse handles the Patch response. +func (client *JobsClient) patchHandleResponse(resp *http.Response) (JobsPatchResponse, error) { + result := JobsPatchResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.JobDefinition); err != nil { + return JobsPatchResponse{}, err + } + return result, nil +} + +// patchHandleError handles the Patch error response. +func (client *JobsClient) patchHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + if len(body) == 0 { + return runtime.NewResponseError(errors.New(resp.Status), resp) + } + return runtime.NewResponseError(errors.New(string(body)), resp) +} + +// Run - Runs a job. +// If the operation fails it returns a generic error. +func (client *JobsClient) Run(ctx context.Context, resourceGroupName string, jobCollectionName string, jobName string, options *JobsRunOptions) (JobsRunResponse, error) { + req, err := client.runCreateRequest(ctx, resourceGroupName, jobCollectionName, jobName, options) + if err != nil { + return JobsRunResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return JobsRunResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return JobsRunResponse{}, client.runHandleError(resp) + } + return JobsRunResponse{RawResponse: resp}, nil +} + +// runCreateRequest creates the Run request. +func (client *JobsClient) runCreateRequest(ctx context.Context, resourceGroupName string, jobCollectionName string, jobName string, options *JobsRunOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Scheduler/jobCollections/{jobCollectionName}/jobs/{jobName}/run" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if jobCollectionName == "" { + return nil, errors.New("parameter jobCollectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{jobCollectionName}", url.PathEscape(jobCollectionName)) + if jobName == "" { + return nil, errors.New("parameter jobName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{jobName}", url.PathEscape(jobName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2016-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + return req, nil +} + +// runHandleError handles the Run error response. +func (client *JobsClient) runHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + if len(body) == 0 { + return runtime.NewResponseError(errors.New(resp.Status), resp) + } + return runtime.NewResponseError(errors.New(string(body)), resp) +} diff --git a/sdk/resourcemanager/scheduler/armscheduler/zz_generated_models.go b/sdk/resourcemanager/scheduler/armscheduler/zz_generated_models.go new file mode 100644 index 000000000000..611b482b2427 --- /dev/null +++ b/sdk/resourcemanager/scheduler/armscheduler/zz_generated_models.go @@ -0,0 +1,1127 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armscheduler + +import ( + "encoding/json" + "reflect" + "time" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore" +) + +type BasicAuthentication struct { + HTTPAuthentication + // Gets or sets the password, return value will always be empty. + Password *string `json:"password,omitempty"` + + // Gets or sets the username. + Username *string `json:"username,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type BasicAuthentication. +func (b BasicAuthentication) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + b.HTTPAuthentication.marshalInternal(objectMap, HTTPAuthenticationTypeBasic) + populate(objectMap, "password", b.Password) + populate(objectMap, "username", b.Username) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BasicAuthentication. +func (b *BasicAuthentication) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "password": + err = unpopulate(val, &b.Password) + delete(rawMsg, key) + case "username": + err = unpopulate(val, &b.Username) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := b.HTTPAuthentication.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +type ClientCertAuthentication struct { + HTTPAuthentication + // Gets or sets the certificate expiration date. + CertificateExpirationDate *time.Time `json:"certificateExpirationDate,omitempty"` + + // Gets or sets the certificate subject name. + CertificateSubjectName *string `json:"certificateSubjectName,omitempty"` + + // Gets or sets the certificate thumbprint. + CertificateThumbprint *string `json:"certificateThumbprint,omitempty"` + + // Gets or sets the certificate password, return value will always be empty. + Password *string `json:"password,omitempty"` + + // Gets or sets the pfx certificate. Accepts certification in base64 encoding, return value will always be empty. + Pfx *string `json:"pfx,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ClientCertAuthentication. +func (c ClientCertAuthentication) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + c.HTTPAuthentication.marshalInternal(objectMap, HTTPAuthenticationTypeClientCertificate) + populate(objectMap, "certificateExpirationDate", (*timeRFC3339)(c.CertificateExpirationDate)) + populate(objectMap, "certificateSubjectName", c.CertificateSubjectName) + populate(objectMap, "certificateThumbprint", c.CertificateThumbprint) + populate(objectMap, "password", c.Password) + populate(objectMap, "pfx", c.Pfx) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ClientCertAuthentication. +func (c *ClientCertAuthentication) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "certificateExpirationDate": + var aux timeRFC3339 + err = unpopulate(val, &aux) + c.CertificateExpirationDate = (*time.Time)(&aux) + delete(rawMsg, key) + case "certificateSubjectName": + err = unpopulate(val, &c.CertificateSubjectName) + delete(rawMsg, key) + case "certificateThumbprint": + err = unpopulate(val, &c.CertificateThumbprint) + delete(rawMsg, key) + case "password": + err = unpopulate(val, &c.Password) + delete(rawMsg, key) + case "pfx": + err = unpopulate(val, &c.Pfx) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := c.HTTPAuthentication.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// HTTPAuthenticationClassification provides polymorphic access to related types. +// Call the interface's GetHTTPAuthentication() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *BasicAuthentication, *ClientCertAuthentication, *HTTPAuthentication, *OAuthAuthentication +type HTTPAuthenticationClassification interface { + // GetHTTPAuthentication returns the HTTPAuthentication content of the underlying type. + GetHTTPAuthentication() *HTTPAuthentication +} + +type HTTPAuthentication struct { + // REQUIRED; Gets or sets the HTTP authentication type. + Type *HTTPAuthenticationType `json:"type,omitempty"` +} + +// GetHTTPAuthentication implements the HTTPAuthenticationClassification interface for type HTTPAuthentication. +func (h *HTTPAuthentication) GetHTTPAuthentication() *HTTPAuthentication { return h } + +// UnmarshalJSON implements the json.Unmarshaller interface for type HTTPAuthentication. +func (h *HTTPAuthentication) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + return h.unmarshalInternal(rawMsg) +} + +func (h HTTPAuthentication) marshalInternal(objectMap map[string]interface{}, discValue HTTPAuthenticationType) { + h.Type = &discValue + objectMap["type"] = h.Type +} + +func (h *HTTPAuthentication) unmarshalInternal(rawMsg map[string]json.RawMessage) error { + for key, val := range rawMsg { + var err error + switch key { + case "type": + err = unpopulate(val, &h.Type) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +type HTTPRequest struct { + // Gets or sets the authentication method of the request. + Authentication HTTPAuthenticationClassification `json:"authentication,omitempty"` + + // Gets or sets the request body. + Body *string `json:"body,omitempty"` + + // Gets or sets the headers. + Headers map[string]*string `json:"headers,omitempty"` + + // Gets or sets the method of the request. + Method *string `json:"method,omitempty"` + + // Gets or sets the URI of the request. + URI *string `json:"uri,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type HTTPRequest. +func (h HTTPRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "authentication", h.Authentication) + populate(objectMap, "body", h.Body) + populate(objectMap, "headers", h.Headers) + populate(objectMap, "method", h.Method) + populate(objectMap, "uri", h.URI) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type HTTPRequest. +func (h *HTTPRequest) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "authentication": + h.Authentication, err = unmarshalHTTPAuthenticationClassification(val) + delete(rawMsg, key) + case "body": + err = unpopulate(val, &h.Body) + delete(rawMsg, key) + case "headers": + err = unpopulate(val, &h.Headers) + delete(rawMsg, key) + case "method": + err = unpopulate(val, &h.Method) + delete(rawMsg, key) + case "uri": + err = unpopulate(val, &h.URI) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +type JobAction struct { + // Gets or sets the error action. + ErrorAction *JobErrorAction `json:"errorAction,omitempty"` + + // Gets or sets the storage queue message. + QueueMessage *StorageQueueMessage `json:"queueMessage,omitempty"` + + // Gets or sets the http requests. + Request *HTTPRequest `json:"request,omitempty"` + + // Gets or sets the retry policy. + RetryPolicy *RetryPolicy `json:"retryPolicy,omitempty"` + + // Gets or sets the service bus queue message. + ServiceBusQueueMessage *ServiceBusQueueMessage `json:"serviceBusQueueMessage,omitempty"` + + // Gets or sets the service bus topic message. + ServiceBusTopicMessage *ServiceBusTopicMessage `json:"serviceBusTopicMessage,omitempty"` + + // Gets or sets the job action type. + Type *JobActionType `json:"type,omitempty"` +} + +type JobCollectionDefinition struct { + // Gets or sets the storage account location. + Location *string `json:"location,omitempty"` + + // Gets or sets the job collection resource name. + Name *string `json:"name,omitempty"` + + // Gets or sets the job collection properties. + Properties *JobCollectionProperties `json:"properties,omitempty"` + + // Gets or sets the tags. + Tags map[string]*string `json:"tags,omitempty"` + + // READ-ONLY; Gets the job collection resource identifier. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; Gets the job collection resource type. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type JobCollectionDefinition. +func (j JobCollectionDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", j.ID) + populate(objectMap, "location", j.Location) + populate(objectMap, "name", j.Name) + populate(objectMap, "properties", j.Properties) + populate(objectMap, "tags", j.Tags) + populate(objectMap, "type", j.Type) + return json.Marshal(objectMap) +} + +type JobCollectionListResult struct { + // Gets or sets the URL to get the next set of job collections. + NextLink *string `json:"nextLink,omitempty"` + + // READ-ONLY; Gets the job collections. + Value []*JobCollectionDefinition `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type JobCollectionListResult. +func (j JobCollectionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", j.NextLink) + populate(objectMap, "value", j.Value) + return json.Marshal(objectMap) +} + +type JobCollectionProperties struct { + // Gets or sets the job collection quota. + Quota *JobCollectionQuota `json:"quota,omitempty"` + + // Gets or sets the SKU. + SKU *SKU `json:"sku,omitempty"` + + // Gets or sets the state. + State *JobCollectionState `json:"state,omitempty"` +} + +type JobCollectionQuota struct { + // Gets or set the maximum job count. + MaxJobCount *int32 `json:"maxJobCount,omitempty"` + + // Gets or sets the maximum job occurrence. + MaxJobOccurrence *int32 `json:"maxJobOccurrence,omitempty"` + + // Gets or set the maximum recurrence. + MaxRecurrence *JobMaxRecurrence `json:"maxRecurrence,omitempty"` +} + +// JobCollectionsBeginDeleteOptions contains the optional parameters for the JobCollections.BeginDelete method. +type JobCollectionsBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// JobCollectionsBeginDisableOptions contains the optional parameters for the JobCollections.BeginDisable method. +type JobCollectionsBeginDisableOptions struct { + // placeholder for future optional parameters +} + +// JobCollectionsBeginEnableOptions contains the optional parameters for the JobCollections.BeginEnable method. +type JobCollectionsBeginEnableOptions struct { + // placeholder for future optional parameters +} + +// JobCollectionsCreateOrUpdateOptions contains the optional parameters for the JobCollections.CreateOrUpdate method. +type JobCollectionsCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// JobCollectionsGetOptions contains the optional parameters for the JobCollections.Get method. +type JobCollectionsGetOptions struct { + // placeholder for future optional parameters +} + +// JobCollectionsListByResourceGroupOptions contains the optional parameters for the JobCollections.ListByResourceGroup method. +type JobCollectionsListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// JobCollectionsListBySubscriptionOptions contains the optional parameters for the JobCollections.ListBySubscription method. +type JobCollectionsListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// JobCollectionsPatchOptions contains the optional parameters for the JobCollections.Patch method. +type JobCollectionsPatchOptions struct { + // placeholder for future optional parameters +} + +type JobDefinition struct { + // Gets or sets the job properties. + Properties *JobProperties `json:"properties,omitempty"` + + // READ-ONLY; Gets the job resource identifier. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; Gets the job resource name. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Gets the job resource type. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type JobDefinition. +func (j JobDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", j.ID) + populate(objectMap, "name", j.Name) + populate(objectMap, "properties", j.Properties) + populate(objectMap, "type", j.Type) + return json.Marshal(objectMap) +} + +type JobErrorAction struct { + // Gets or sets the storage queue message. + QueueMessage *StorageQueueMessage `json:"queueMessage,omitempty"` + + // Gets or sets the http requests. + Request *HTTPRequest `json:"request,omitempty"` + + // Gets or sets the retry policy. + RetryPolicy *RetryPolicy `json:"retryPolicy,omitempty"` + + // Gets or sets the service bus queue message. + ServiceBusQueueMessage *ServiceBusQueueMessage `json:"serviceBusQueueMessage,omitempty"` + + // Gets or sets the service bus topic message. + ServiceBusTopicMessage *ServiceBusTopicMessage `json:"serviceBusTopicMessage,omitempty"` + + // Gets or sets the job error action type. + Type *JobActionType `json:"type,omitempty"` +} + +type JobHistoryDefinition struct { + // READ-ONLY; Gets the job history identifier. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; Gets the job history name. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Gets or sets the job history properties. + Properties *JobHistoryDefinitionProperties `json:"properties,omitempty" azure:"ro"` + + // READ-ONLY; Gets the job history resource type. + Type *string `json:"type,omitempty" azure:"ro"` +} + +type JobHistoryDefinitionProperties struct { + // READ-ONLY; Gets the job history action name. + ActionName *JobHistoryActionName `json:"actionName,omitempty" azure:"ro"` + + // READ-ONLY; Gets the end time for this job. + EndTime *time.Time `json:"endTime,omitempty" azure:"ro"` + + // READ-ONLY; Gets the expected execution time for this job. + ExpectedExecutionTime *time.Time `json:"expectedExecutionTime,omitempty" azure:"ro"` + + // READ-ONLY; Gets the message for the job history. + Message *string `json:"message,omitempty" azure:"ro"` + + // READ-ONLY; Gets the repeat count for the job. + RepeatCount *int32 `json:"repeatCount,omitempty" azure:"ro"` + + // READ-ONLY; Gets the retry count for job. + RetryCount *int32 `json:"retryCount,omitempty" azure:"ro"` + + // READ-ONLY; Gets the start time for this job. + StartTime *time.Time `json:"startTime,omitempty" azure:"ro"` + + // READ-ONLY; Gets the job history status. + Status *JobExecutionStatus `json:"status,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type JobHistoryDefinitionProperties. +func (j JobHistoryDefinitionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "actionName", j.ActionName) + populate(objectMap, "endTime", (*timeRFC3339)(j.EndTime)) + populate(objectMap, "expectedExecutionTime", (*timeRFC3339)(j.ExpectedExecutionTime)) + populate(objectMap, "message", j.Message) + populate(objectMap, "repeatCount", j.RepeatCount) + populate(objectMap, "retryCount", j.RetryCount) + populate(objectMap, "startTime", (*timeRFC3339)(j.StartTime)) + populate(objectMap, "status", j.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type JobHistoryDefinitionProperties. +func (j *JobHistoryDefinitionProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "actionName": + err = unpopulate(val, &j.ActionName) + delete(rawMsg, key) + case "endTime": + var aux timeRFC3339 + err = unpopulate(val, &aux) + j.EndTime = (*time.Time)(&aux) + delete(rawMsg, key) + case "expectedExecutionTime": + var aux timeRFC3339 + err = unpopulate(val, &aux) + j.ExpectedExecutionTime = (*time.Time)(&aux) + delete(rawMsg, key) + case "message": + err = unpopulate(val, &j.Message) + delete(rawMsg, key) + case "repeatCount": + err = unpopulate(val, &j.RepeatCount) + delete(rawMsg, key) + case "retryCount": + err = unpopulate(val, &j.RetryCount) + delete(rawMsg, key) + case "startTime": + var aux timeRFC3339 + err = unpopulate(val, &aux) + j.StartTime = (*time.Time)(&aux) + delete(rawMsg, key) + case "status": + err = unpopulate(val, &j.Status) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +type JobHistoryFilter struct { + // Gets or sets the job execution status. + Status *JobExecutionStatus `json:"status,omitempty"` +} + +type JobHistoryListResult struct { + // Gets or sets the URL to get the next set of job histories. + NextLink *string `json:"nextLink,omitempty"` + + // Gets or sets the job histories under job. + Value []*JobHistoryDefinition `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type JobHistoryListResult. +func (j JobHistoryListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", j.NextLink) + populate(objectMap, "value", j.Value) + return json.Marshal(objectMap) +} + +type JobListResult struct { + // Gets or sets the URL to get the next set of jobs. + NextLink *string `json:"nextLink,omitempty"` + + // Gets or sets all jobs under job collection. + Value []*JobDefinition `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type JobListResult. +func (j JobListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", j.NextLink) + populate(objectMap, "value", j.Value) + return json.Marshal(objectMap) +} + +type JobMaxRecurrence struct { + // Gets or sets the frequency of recurrence (second, minute, hour, day, week, month). + Frequency *RecurrenceFrequency `json:"frequency,omitempty"` + + // Gets or sets the interval between retries. + Interval *int32 `json:"interval,omitempty"` +} + +type JobProperties struct { + // Gets or sets the job action. + Action *JobAction `json:"action,omitempty"` + + // Gets or sets the job recurrence. + Recurrence *JobRecurrence `json:"recurrence,omitempty"` + + // Gets or sets the job start time. + StartTime *time.Time `json:"startTime,omitempty"` + + // Gets or set the job state. + State *JobState `json:"state,omitempty"` + + // READ-ONLY; Gets the job status. + Status *JobStatus `json:"status,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type JobProperties. +func (j JobProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "action", j.Action) + populate(objectMap, "recurrence", j.Recurrence) + populate(objectMap, "startTime", (*timeRFC3339)(j.StartTime)) + populate(objectMap, "state", j.State) + populate(objectMap, "status", j.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type JobProperties. +func (j *JobProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "action": + err = unpopulate(val, &j.Action) + delete(rawMsg, key) + case "recurrence": + err = unpopulate(val, &j.Recurrence) + delete(rawMsg, key) + case "startTime": + var aux timeRFC3339 + err = unpopulate(val, &aux) + j.StartTime = (*time.Time)(&aux) + delete(rawMsg, key) + case "state": + err = unpopulate(val, &j.State) + delete(rawMsg, key) + case "status": + err = unpopulate(val, &j.Status) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +type JobRecurrence struct { + // Gets or sets the maximum number of times that the job should run. + Count *int32 `json:"count,omitempty"` + + // Gets or sets the time at which the job will complete. + EndTime *time.Time `json:"endTime,omitempty"` + + // Gets or sets the frequency of recurrence (second, minute, hour, day, week, month). + Frequency *RecurrenceFrequency `json:"frequency,omitempty"` + + // Gets or sets the interval between retries. + Interval *int32 `json:"interval,omitempty"` + Schedule *JobRecurrenceSchedule `json:"schedule,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type JobRecurrence. +func (j JobRecurrence) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "count", j.Count) + populate(objectMap, "endTime", (*timeRFC3339)(j.EndTime)) + populate(objectMap, "frequency", j.Frequency) + populate(objectMap, "interval", j.Interval) + populate(objectMap, "schedule", j.Schedule) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type JobRecurrence. +func (j *JobRecurrence) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "count": + err = unpopulate(val, &j.Count) + delete(rawMsg, key) + case "endTime": + var aux timeRFC3339 + err = unpopulate(val, &aux) + j.EndTime = (*time.Time)(&aux) + delete(rawMsg, key) + case "frequency": + err = unpopulate(val, &j.Frequency) + delete(rawMsg, key) + case "interval": + err = unpopulate(val, &j.Interval) + delete(rawMsg, key) + case "schedule": + err = unpopulate(val, &j.Schedule) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +type JobRecurrenceSchedule struct { + // Gets or sets the hours of the day that the job should execute at. + Hours []*int32 `json:"hours,omitempty"` + + // Gets or sets the minutes of the hour that the job should execute at. + Minutes []*int32 `json:"minutes,omitempty"` + + // Gets or sets the days of the month that the job should execute on. Must be between 1 and 31. + MonthDays []*int32 `json:"monthDays,omitempty"` + + // Gets or sets the occurrences of days within a month. + MonthlyOccurrences []*JobRecurrenceScheduleMonthlyOccurrence `json:"monthlyOccurrences,omitempty"` + + // Gets or sets the days of the week that the job should execute on. + WeekDays []*DayOfWeek `json:"weekDays,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type JobRecurrenceSchedule. +func (j JobRecurrenceSchedule) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "hours", j.Hours) + populate(objectMap, "minutes", j.Minutes) + populate(objectMap, "monthDays", j.MonthDays) + populate(objectMap, "monthlyOccurrences", j.MonthlyOccurrences) + populate(objectMap, "weekDays", j.WeekDays) + return json.Marshal(objectMap) +} + +type JobRecurrenceScheduleMonthlyOccurrence struct { + // Gets or sets the day. Must be one of monday, tuesday, wednesday, thursday, friday, saturday, sunday. + Day *JobScheduleDay `json:"day,omitempty"` + + // Gets or sets the occurrence. Must be between -5 and 5. + Occurrence *int32 `json:"Occurrence,omitempty"` +} + +type JobStateFilter struct { + // Gets or sets the job state. + State *JobState `json:"state,omitempty"` +} + +type JobStatus struct { + // READ-ONLY; Gets the number of times this job has executed. + ExecutionCount *int32 `json:"executionCount,omitempty" azure:"ro"` + + // READ-ONLY; Gets the number of times this job has failed. + FailureCount *int32 `json:"failureCount,omitempty" azure:"ro"` + + // READ-ONLY; Gets the number of faulted occurrences (occurrences that were retried and failed as many times as the retry policy states). + FaultedCount *int32 `json:"faultedCount,omitempty" azure:"ro"` + + // READ-ONLY; Gets the time the last occurrence executed in ISO-8601 format. Could be empty if job has not run yet. + LastExecutionTime *time.Time `json:"lastExecutionTime,omitempty" azure:"ro"` + + // READ-ONLY; Gets the time of the next occurrence in ISO-8601 format. Could be empty if the job is completed. + NextExecutionTime *time.Time `json:"nextExecutionTime,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type JobStatus. +func (j JobStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "executionCount", j.ExecutionCount) + populate(objectMap, "failureCount", j.FailureCount) + populate(objectMap, "faultedCount", j.FaultedCount) + populate(objectMap, "lastExecutionTime", (*timeRFC3339)(j.LastExecutionTime)) + populate(objectMap, "nextExecutionTime", (*timeRFC3339)(j.NextExecutionTime)) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type JobStatus. +func (j *JobStatus) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "executionCount": + err = unpopulate(val, &j.ExecutionCount) + delete(rawMsg, key) + case "failureCount": + err = unpopulate(val, &j.FailureCount) + delete(rawMsg, key) + case "faultedCount": + err = unpopulate(val, &j.FaultedCount) + delete(rawMsg, key) + case "lastExecutionTime": + var aux timeRFC3339 + err = unpopulate(val, &aux) + j.LastExecutionTime = (*time.Time)(&aux) + delete(rawMsg, key) + case "nextExecutionTime": + var aux timeRFC3339 + err = unpopulate(val, &aux) + j.NextExecutionTime = (*time.Time)(&aux) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// JobsCreateOrUpdateOptions contains the optional parameters for the Jobs.CreateOrUpdate method. +type JobsCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// JobsDeleteOptions contains the optional parameters for the Jobs.Delete method. +type JobsDeleteOptions struct { + // placeholder for future optional parameters +} + +// JobsGetOptions contains the optional parameters for the Jobs.Get method. +type JobsGetOptions struct { + // placeholder for future optional parameters +} + +// JobsListJobHistoryOptions contains the optional parameters for the Jobs.ListJobHistory method. +type JobsListJobHistoryOptions struct { + // The filter to apply on the job state. + Filter *string + // The (0-based) index of the job history list from which to begin requesting entries. + Skip *int32 + // the number of job history to request, in the of range of [1..100]. + Top *int32 +} + +// JobsListOptions contains the optional parameters for the Jobs.List method. +type JobsListOptions struct { + // The filter to apply on the job state. + Filter *string + // The (0-based) index of the job history list from which to begin requesting entries. + Skip *int32 + // The number of jobs to request, in the of range of [1..100]. + Top *int32 +} + +// JobsPatchOptions contains the optional parameters for the Jobs.Patch method. +type JobsPatchOptions struct { + // placeholder for future optional parameters +} + +// JobsRunOptions contains the optional parameters for the Jobs.Run method. +type JobsRunOptions struct { + // placeholder for future optional parameters +} + +type OAuthAuthentication struct { + HTTPAuthentication + // Gets or sets the audience. + Audience *string `json:"audience,omitempty"` + + // Gets or sets the client identifier. + ClientID *string `json:"clientId,omitempty"` + + // Gets or sets the secret, return value will always be empty. + Secret *string `json:"secret,omitempty"` + + // Gets or sets the tenant. + Tenant *string `json:"tenant,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type OAuthAuthentication. +func (o OAuthAuthentication) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + o.HTTPAuthentication.marshalInternal(objectMap, HTTPAuthenticationTypeActiveDirectoryOAuth) + populate(objectMap, "audience", o.Audience) + populate(objectMap, "clientId", o.ClientID) + populate(objectMap, "secret", o.Secret) + populate(objectMap, "tenant", o.Tenant) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OAuthAuthentication. +func (o *OAuthAuthentication) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "audience": + err = unpopulate(val, &o.Audience) + delete(rawMsg, key) + case "clientId": + err = unpopulate(val, &o.ClientID) + delete(rawMsg, key) + case "secret": + err = unpopulate(val, &o.Secret) + delete(rawMsg, key) + case "tenant": + err = unpopulate(val, &o.Tenant) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := o.HTTPAuthentication.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +type RetryPolicy struct { + // Gets or sets the number of times a retry should be attempted. + RetryCount *int32 `json:"retryCount,omitempty"` + + // Gets or sets the retry interval between retries, specify duration in ISO 8601 format. + RetryInterval *string `json:"retryInterval,omitempty"` + + // Gets or sets the retry strategy to be used. + RetryType *RetryType `json:"retryType,omitempty"` +} + +type SKU struct { + // Gets or set the SKU. + Name *SKUDefinition `json:"name,omitempty"` +} + +type ServiceBusAuthentication struct { + // Gets or sets the SAS key. + SasKey *string `json:"sasKey,omitempty"` + + // Gets or sets the SAS key name. + SasKeyName *string `json:"sasKeyName,omitempty"` + + // Gets or sets the authentication type. + Type *ServiceBusAuthenticationType `json:"type,omitempty"` +} + +type ServiceBusBrokeredMessageProperties struct { + // Gets or sets the content type. + ContentType *string `json:"contentType,omitempty"` + + // Gets or sets the correlation ID. + CorrelationID *string `json:"correlationId,omitempty"` + + // Gets or sets the force persistence. + ForcePersistence *bool `json:"forcePersistence,omitempty"` + + // Gets or sets the label. + Label *string `json:"label,omitempty"` + + // Gets or sets the message ID. + MessageID *string `json:"messageId,omitempty"` + + // Gets or sets the partition key. + PartitionKey *string `json:"partitionKey,omitempty"` + + // Gets or sets the reply to. + ReplyTo *string `json:"replyTo,omitempty"` + + // Gets or sets the reply to session ID. + ReplyToSessionID *string `json:"replyToSessionId,omitempty"` + + // Gets or sets the scheduled enqueue time UTC. + ScheduledEnqueueTimeUTC *time.Time `json:"scheduledEnqueueTimeUtc,omitempty"` + + // Gets or sets the session ID. + SessionID *string `json:"sessionId,omitempty"` + + // Gets or sets the time to live. + TimeToLive *string `json:"timeToLive,omitempty"` + + // Gets or sets the to. + To *string `json:"to,omitempty"` + + // Gets or sets the via partition key. + ViaPartitionKey *string `json:"viaPartitionKey,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ServiceBusBrokeredMessageProperties. +func (s ServiceBusBrokeredMessageProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "contentType", s.ContentType) + populate(objectMap, "correlationId", s.CorrelationID) + populate(objectMap, "forcePersistence", s.ForcePersistence) + populate(objectMap, "label", s.Label) + populate(objectMap, "messageId", s.MessageID) + populate(objectMap, "partitionKey", s.PartitionKey) + populate(objectMap, "replyTo", s.ReplyTo) + populate(objectMap, "replyToSessionId", s.ReplyToSessionID) + populate(objectMap, "scheduledEnqueueTimeUtc", (*timeRFC3339)(s.ScheduledEnqueueTimeUTC)) + populate(objectMap, "sessionId", s.SessionID) + populate(objectMap, "timeToLive", s.TimeToLive) + populate(objectMap, "to", s.To) + populate(objectMap, "viaPartitionKey", s.ViaPartitionKey) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServiceBusBrokeredMessageProperties. +func (s *ServiceBusBrokeredMessageProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "contentType": + err = unpopulate(val, &s.ContentType) + delete(rawMsg, key) + case "correlationId": + err = unpopulate(val, &s.CorrelationID) + delete(rawMsg, key) + case "forcePersistence": + err = unpopulate(val, &s.ForcePersistence) + delete(rawMsg, key) + case "label": + err = unpopulate(val, &s.Label) + delete(rawMsg, key) + case "messageId": + err = unpopulate(val, &s.MessageID) + delete(rawMsg, key) + case "partitionKey": + err = unpopulate(val, &s.PartitionKey) + delete(rawMsg, key) + case "replyTo": + err = unpopulate(val, &s.ReplyTo) + delete(rawMsg, key) + case "replyToSessionId": + err = unpopulate(val, &s.ReplyToSessionID) + delete(rawMsg, key) + case "scheduledEnqueueTimeUtc": + var aux timeRFC3339 + err = unpopulate(val, &aux) + s.ScheduledEnqueueTimeUTC = (*time.Time)(&aux) + delete(rawMsg, key) + case "sessionId": + err = unpopulate(val, &s.SessionID) + delete(rawMsg, key) + case "timeToLive": + err = unpopulate(val, &s.TimeToLive) + delete(rawMsg, key) + case "to": + err = unpopulate(val, &s.To) + delete(rawMsg, key) + case "viaPartitionKey": + err = unpopulate(val, &s.ViaPartitionKey) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +type ServiceBusMessage struct { + // Gets or sets the Service Bus authentication. + Authentication *ServiceBusAuthentication `json:"authentication,omitempty"` + + // Gets or sets the brokered message properties. + BrokeredMessageProperties *ServiceBusBrokeredMessageProperties `json:"brokeredMessageProperties,omitempty"` + + // Gets or sets the custom message properties. + CustomMessageProperties map[string]*string `json:"customMessageProperties,omitempty"` + + // Gets or sets the message. + Message *string `json:"message,omitempty"` + + // Gets or sets the namespace. + Namespace *string `json:"namespace,omitempty"` + + // Gets or sets the transport type. + TransportType *ServiceBusTransportType `json:"transportType,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ServiceBusMessage. +func (s ServiceBusMessage) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + s.marshalInternal(objectMap) + return json.Marshal(objectMap) +} + +func (s ServiceBusMessage) marshalInternal(objectMap map[string]interface{}) { + populate(objectMap, "authentication", s.Authentication) + populate(objectMap, "brokeredMessageProperties", s.BrokeredMessageProperties) + populate(objectMap, "customMessageProperties", s.CustomMessageProperties) + populate(objectMap, "message", s.Message) + populate(objectMap, "namespace", s.Namespace) + populate(objectMap, "transportType", s.TransportType) +} + +type ServiceBusQueueMessage struct { + ServiceBusMessage + // Gets or sets the queue name. + QueueName *string `json:"queueName,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ServiceBusQueueMessage. +func (s ServiceBusQueueMessage) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + s.ServiceBusMessage.marshalInternal(objectMap) + populate(objectMap, "queueName", s.QueueName) + return json.Marshal(objectMap) +} + +type ServiceBusTopicMessage struct { + ServiceBusMessage + // Gets or sets the topic path. + TopicPath *string `json:"topicPath,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ServiceBusTopicMessage. +func (s ServiceBusTopicMessage) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + s.ServiceBusMessage.marshalInternal(objectMap) + populate(objectMap, "topicPath", s.TopicPath) + return json.Marshal(objectMap) +} + +type StorageQueueMessage struct { + // Gets or sets the message. + Message *string `json:"message,omitempty"` + + // Gets or sets the queue name. + QueueName *string `json:"queueName,omitempty"` + + // Gets or sets the SAS key. + SasToken *string `json:"sasToken,omitempty"` + + // Gets or sets the storage account name. + StorageAccount *string `json:"storageAccount,omitempty"` +} + +func populate(m map[string]interface{}, k string, v interface{}) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, v interface{}) error { + if data == nil { + return nil + } + return json.Unmarshal(data, v) +} diff --git a/sdk/resourcemanager/scheduler/armscheduler/zz_generated_pagers.go b/sdk/resourcemanager/scheduler/armscheduler/zz_generated_pagers.go new file mode 100644 index 000000000000..26d06fea06aa --- /dev/null +++ b/sdk/resourcemanager/scheduler/armscheduler/zz_generated_pagers.go @@ -0,0 +1,234 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armscheduler + +import ( + "context" + "net/http" + "reflect" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" +) + +// JobCollectionsListByResourceGroupPager provides operations for iterating over paged responses. +type JobCollectionsListByResourceGroupPager struct { + client *JobCollectionsClient + current JobCollectionsListByResourceGroupResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, JobCollectionsListByResourceGroupResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *JobCollectionsListByResourceGroupPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *JobCollectionsListByResourceGroupPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.JobCollectionListResult.NextLink == nil || len(*p.current.JobCollectionListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listByResourceGroupHandleError(resp) + return false + } + result, err := p.client.listByResourceGroupHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current JobCollectionsListByResourceGroupResponse page. +func (p *JobCollectionsListByResourceGroupPager) PageResponse() JobCollectionsListByResourceGroupResponse { + return p.current +} + +// JobCollectionsListBySubscriptionPager provides operations for iterating over paged responses. +type JobCollectionsListBySubscriptionPager struct { + client *JobCollectionsClient + current JobCollectionsListBySubscriptionResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, JobCollectionsListBySubscriptionResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *JobCollectionsListBySubscriptionPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *JobCollectionsListBySubscriptionPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.JobCollectionListResult.NextLink == nil || len(*p.current.JobCollectionListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listBySubscriptionHandleError(resp) + return false + } + result, err := p.client.listBySubscriptionHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current JobCollectionsListBySubscriptionResponse page. +func (p *JobCollectionsListBySubscriptionPager) PageResponse() JobCollectionsListBySubscriptionResponse { + return p.current +} + +// JobsListJobHistoryPager provides operations for iterating over paged responses. +type JobsListJobHistoryPager struct { + client *JobsClient + current JobsListJobHistoryResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, JobsListJobHistoryResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *JobsListJobHistoryPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *JobsListJobHistoryPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.JobHistoryListResult.NextLink == nil || len(*p.current.JobHistoryListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listJobHistoryHandleError(resp) + return false + } + result, err := p.client.listJobHistoryHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current JobsListJobHistoryResponse page. +func (p *JobsListJobHistoryPager) PageResponse() JobsListJobHistoryResponse { + return p.current +} + +// JobsListPager provides operations for iterating over paged responses. +type JobsListPager struct { + client *JobsClient + current JobsListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, JobsListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *JobsListPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *JobsListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.JobListResult.NextLink == nil || len(*p.current.JobListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listHandleError(resp) + return false + } + result, err := p.client.listHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current JobsListResponse page. +func (p *JobsListPager) PageResponse() JobsListResponse { + return p.current +} diff --git a/sdk/resourcemanager/scheduler/armscheduler/zz_generated_pollers.go b/sdk/resourcemanager/scheduler/armscheduler/zz_generated_pollers.go new file mode 100644 index 000000000000..c309bc6d2385 --- /dev/null +++ b/sdk/resourcemanager/scheduler/armscheduler/zz_generated_pollers.go @@ -0,0 +1,145 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armscheduler + +import ( + "context" + "net/http" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore" +) + +// JobCollectionsDeletePoller provides polling facilities until the operation reaches a terminal state. +type JobCollectionsDeletePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *JobCollectionsDeletePoller) Done() bool { + return p.pt.Done() +} + +// Poll fetches the latest state of the LRO. It returns an HTTP response or error. +// If the LRO has completed successfully, the poller's state is updated and the HTTP +// response is returned. +// If the LRO has completed with failure or was cancelled, the poller's state is +// updated and the error is returned. +// If the LRO has not reached a terminal state, the poller's state is updated and +// the latest HTTP response is returned. +// If Poll fails, the poller's state is unmodified and the error is returned. +// Calling Poll on an LRO that has reached a terminal state will return the final +// HTTP response or error. +func (p *JobCollectionsDeletePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +// FinalResponse performs a final GET to the service and returns the final response +// for the polling operation. If there is an error performing the final GET then an error is returned. +// If the final GET succeeded then the final JobCollectionsDeleteResponse will be returned. +func (p *JobCollectionsDeletePoller) FinalResponse(ctx context.Context) (JobCollectionsDeleteResponse, error) { + respType := JobCollectionsDeleteResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return JobCollectionsDeleteResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ResumeToken returns a value representing the poller that can be used to resume +// the LRO at a later time. ResumeTokens are unique per service operation. +func (p *JobCollectionsDeletePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// JobCollectionsDisablePoller provides polling facilities until the operation reaches a terminal state. +type JobCollectionsDisablePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *JobCollectionsDisablePoller) Done() bool { + return p.pt.Done() +} + +// Poll fetches the latest state of the LRO. It returns an HTTP response or error. +// If the LRO has completed successfully, the poller's state is updated and the HTTP +// response is returned. +// If the LRO has completed with failure or was cancelled, the poller's state is +// updated and the error is returned. +// If the LRO has not reached a terminal state, the poller's state is updated and +// the latest HTTP response is returned. +// If Poll fails, the poller's state is unmodified and the error is returned. +// Calling Poll on an LRO that has reached a terminal state will return the final +// HTTP response or error. +func (p *JobCollectionsDisablePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +// FinalResponse performs a final GET to the service and returns the final response +// for the polling operation. If there is an error performing the final GET then an error is returned. +// If the final GET succeeded then the final JobCollectionsDisableResponse will be returned. +func (p *JobCollectionsDisablePoller) FinalResponse(ctx context.Context) (JobCollectionsDisableResponse, error) { + respType := JobCollectionsDisableResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return JobCollectionsDisableResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ResumeToken returns a value representing the poller that can be used to resume +// the LRO at a later time. ResumeTokens are unique per service operation. +func (p *JobCollectionsDisablePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// JobCollectionsEnablePoller provides polling facilities until the operation reaches a terminal state. +type JobCollectionsEnablePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *JobCollectionsEnablePoller) Done() bool { + return p.pt.Done() +} + +// Poll fetches the latest state of the LRO. It returns an HTTP response or error. +// If the LRO has completed successfully, the poller's state is updated and the HTTP +// response is returned. +// If the LRO has completed with failure or was cancelled, the poller's state is +// updated and the error is returned. +// If the LRO has not reached a terminal state, the poller's state is updated and +// the latest HTTP response is returned. +// If Poll fails, the poller's state is unmodified and the error is returned. +// Calling Poll on an LRO that has reached a terminal state will return the final +// HTTP response or error. +func (p *JobCollectionsEnablePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +// FinalResponse performs a final GET to the service and returns the final response +// for the polling operation. If there is an error performing the final GET then an error is returned. +// If the final GET succeeded then the final JobCollectionsEnableResponse will be returned. +func (p *JobCollectionsEnablePoller) FinalResponse(ctx context.Context) (JobCollectionsEnableResponse, error) { + respType := JobCollectionsEnableResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return JobCollectionsEnableResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ResumeToken returns a value representing the poller that can be used to resume +// the LRO at a later time. ResumeTokens are unique per service operation. +func (p *JobCollectionsEnablePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} diff --git a/sdk/resourcemanager/scheduler/armscheduler/zz_generated_polymorphic_helpers.go b/sdk/resourcemanager/scheduler/armscheduler/zz_generated_polymorphic_helpers.go new file mode 100644 index 000000000000..f3c94bd8044f --- /dev/null +++ b/sdk/resourcemanager/scheduler/armscheduler/zz_generated_polymorphic_helpers.go @@ -0,0 +1,52 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armscheduler + +import "encoding/json" + +func unmarshalHTTPAuthenticationClassification(rawMsg json.RawMessage) (HTTPAuthenticationClassification, error) { + if rawMsg == nil { + return nil, nil + } + var m map[string]interface{} + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b HTTPAuthenticationClassification + switch m["type"] { + case string(HTTPAuthenticationTypeActiveDirectoryOAuth): + b = &OAuthAuthentication{} + case string(HTTPAuthenticationTypeBasic): + b = &BasicAuthentication{} + case string(HTTPAuthenticationTypeClientCertificate): + b = &ClientCertAuthentication{} + default: + b = &HTTPAuthentication{} + } + return b, json.Unmarshal(rawMsg, b) +} + +func unmarshalHTTPAuthenticationClassificationArray(rawMsg json.RawMessage) ([]HTTPAuthenticationClassification, error) { + if rawMsg == nil { + return nil, nil + } + var rawMessages []json.RawMessage + if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { + return nil, err + } + fArray := make([]HTTPAuthenticationClassification, len(rawMessages)) + for index, rawMessage := range rawMessages { + f, err := unmarshalHTTPAuthenticationClassification(rawMessage) + if err != nil { + return nil, err + } + fArray[index] = f + } + return fArray, nil +} diff --git a/sdk/resourcemanager/scheduler/armscheduler/zz_generated_response_types.go b/sdk/resourcemanager/scheduler/armscheduler/zz_generated_response_types.go new file mode 100644 index 000000000000..e70272ba2999 --- /dev/null +++ b/sdk/resourcemanager/scheduler/armscheduler/zz_generated_response_types.go @@ -0,0 +1,281 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armscheduler + +import ( + "context" + "net/http" + "time" + + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" +) + +// JobCollectionsCreateOrUpdateResponse contains the response from method JobCollections.CreateOrUpdate. +type JobCollectionsCreateOrUpdateResponse struct { + JobCollectionsCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// JobCollectionsCreateOrUpdateResult contains the result from method JobCollections.CreateOrUpdate. +type JobCollectionsCreateOrUpdateResult struct { + JobCollectionDefinition +} + +// JobCollectionsDeletePollerResponse contains the response from method JobCollections.Delete. +type JobCollectionsDeletePollerResponse struct { + // Poller contains an initialized poller. + Poller *JobCollectionsDeletePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. +func (l JobCollectionsDeletePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (JobCollectionsDeleteResponse, error) { + respType := JobCollectionsDeleteResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a JobCollectionsDeletePollerResponse from the provided client and resume token. +func (l *JobCollectionsDeletePollerResponse) Resume(ctx context.Context, client *JobCollectionsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("JobCollectionsClient.Delete", token, client.pl, client.deleteHandleError) + if err != nil { + return err + } + poller := &JobCollectionsDeletePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// JobCollectionsDeleteResponse contains the response from method JobCollections.Delete. +type JobCollectionsDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// JobCollectionsDisablePollerResponse contains the response from method JobCollections.Disable. +type JobCollectionsDisablePollerResponse struct { + // Poller contains an initialized poller. + Poller *JobCollectionsDisablePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. +func (l JobCollectionsDisablePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (JobCollectionsDisableResponse, error) { + respType := JobCollectionsDisableResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a JobCollectionsDisablePollerResponse from the provided client and resume token. +func (l *JobCollectionsDisablePollerResponse) Resume(ctx context.Context, client *JobCollectionsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("JobCollectionsClient.Disable", token, client.pl, client.disableHandleError) + if err != nil { + return err + } + poller := &JobCollectionsDisablePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// JobCollectionsDisableResponse contains the response from method JobCollections.Disable. +type JobCollectionsDisableResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// JobCollectionsEnablePollerResponse contains the response from method JobCollections.Enable. +type JobCollectionsEnablePollerResponse struct { + // Poller contains an initialized poller. + Poller *JobCollectionsEnablePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. +func (l JobCollectionsEnablePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (JobCollectionsEnableResponse, error) { + respType := JobCollectionsEnableResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a JobCollectionsEnablePollerResponse from the provided client and resume token. +func (l *JobCollectionsEnablePollerResponse) Resume(ctx context.Context, client *JobCollectionsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("JobCollectionsClient.Enable", token, client.pl, client.enableHandleError) + if err != nil { + return err + } + poller := &JobCollectionsEnablePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// JobCollectionsEnableResponse contains the response from method JobCollections.Enable. +type JobCollectionsEnableResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// JobCollectionsGetResponse contains the response from method JobCollections.Get. +type JobCollectionsGetResponse struct { + JobCollectionsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// JobCollectionsGetResult contains the result from method JobCollections.Get. +type JobCollectionsGetResult struct { + JobCollectionDefinition +} + +// JobCollectionsListByResourceGroupResponse contains the response from method JobCollections.ListByResourceGroup. +type JobCollectionsListByResourceGroupResponse struct { + JobCollectionsListByResourceGroupResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// JobCollectionsListByResourceGroupResult contains the result from method JobCollections.ListByResourceGroup. +type JobCollectionsListByResourceGroupResult struct { + JobCollectionListResult +} + +// JobCollectionsListBySubscriptionResponse contains the response from method JobCollections.ListBySubscription. +type JobCollectionsListBySubscriptionResponse struct { + JobCollectionsListBySubscriptionResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// JobCollectionsListBySubscriptionResult contains the result from method JobCollections.ListBySubscription. +type JobCollectionsListBySubscriptionResult struct { + JobCollectionListResult +} + +// JobCollectionsPatchResponse contains the response from method JobCollections.Patch. +type JobCollectionsPatchResponse struct { + JobCollectionsPatchResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// JobCollectionsPatchResult contains the result from method JobCollections.Patch. +type JobCollectionsPatchResult struct { + JobCollectionDefinition +} + +// JobsCreateOrUpdateResponse contains the response from method Jobs.CreateOrUpdate. +type JobsCreateOrUpdateResponse struct { + JobsCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// JobsCreateOrUpdateResult contains the result from method Jobs.CreateOrUpdate. +type JobsCreateOrUpdateResult struct { + JobDefinition +} + +// JobsDeleteResponse contains the response from method Jobs.Delete. +type JobsDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// JobsGetResponse contains the response from method Jobs.Get. +type JobsGetResponse struct { + JobsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// JobsGetResult contains the result from method Jobs.Get. +type JobsGetResult struct { + JobDefinition +} + +// JobsListJobHistoryResponse contains the response from method Jobs.ListJobHistory. +type JobsListJobHistoryResponse struct { + JobsListJobHistoryResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// JobsListJobHistoryResult contains the result from method Jobs.ListJobHistory. +type JobsListJobHistoryResult struct { + JobHistoryListResult +} + +// JobsListResponse contains the response from method Jobs.List. +type JobsListResponse struct { + JobsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// JobsListResult contains the result from method Jobs.List. +type JobsListResult struct { + JobListResult +} + +// JobsPatchResponse contains the response from method Jobs.Patch. +type JobsPatchResponse struct { + JobsPatchResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// JobsPatchResult contains the result from method Jobs.Patch. +type JobsPatchResult struct { + JobDefinition +} + +// JobsRunResponse contains the response from method Jobs.Run. +type JobsRunResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} diff --git a/sdk/resourcemanager/scheduler/armscheduler/zz_generated_time_rfc3339.go b/sdk/resourcemanager/scheduler/armscheduler/zz_generated_time_rfc3339.go new file mode 100644 index 000000000000..597cad4bd6e3 --- /dev/null +++ b/sdk/resourcemanager/scheduler/armscheduler/zz_generated_time_rfc3339.go @@ -0,0 +1,58 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armscheduler + +import ( + "regexp" + "strings" + "time" +) + +const ( + utcLayoutJSON = `"2006-01-02T15:04:05.999999999"` + utcLayout = "2006-01-02T15:04:05.999999999" + rfc3339JSON = `"` + time.RFC3339Nano + `"` +) + +// Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. +var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) + +type timeRFC3339 time.Time + +func (t timeRFC3339) MarshalJSON() (json []byte, err error) { + tt := time.Time(t) + return tt.MarshalJSON() +} + +func (t timeRFC3339) MarshalText() (text []byte, err error) { + tt := time.Time(t) + return tt.MarshalText() +} + +func (t *timeRFC3339) UnmarshalJSON(data []byte) error { + layout := utcLayoutJSON + if tzOffsetRegex.Match(data) { + layout = rfc3339JSON + } + return t.Parse(layout, string(data)) +} + +func (t *timeRFC3339) UnmarshalText(data []byte) (err error) { + layout := utcLayout + if tzOffsetRegex.Match(data) { + layout = time.RFC3339Nano + } + return t.Parse(layout, string(data)) +} + +func (t *timeRFC3339) Parse(layout, value string) error { + p, err := time.Parse(layout, strings.ToUpper(value)) + *t = timeRFC3339(p) + return err +}