From 44868f92be8d5bcabca967a68ee81e3a0b73afc7 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Mon, 2 Sep 2019 02:54:47 +0000 Subject: [PATCH] Generated from be2943341d08ab5972e4d2385b1860d34ee61f59 Fix bad namespace in service maintenance --- .../mgmt/maintenance/maintenanceapi/models.go | 28 + .../maintenance/mgmt/maintenance/models.go | 130 ++++ .../maintenance/applyupdates.go | 377 ++++++++++++ .../2018-06-01-preview/maintenance/client.go | 51 ++ .../maintenance/configurationassignments.go | 553 +++++++++++++++++ .../maintenance/configurations.go | 427 +++++++++++++ .../maintenance/maintenanceapi/interfaces.go | 71 +++ .../2018-06-01-preview/maintenance/models.go | 581 ++++++++++++++++++ .../maintenance/operations.go | 109 ++++ .../2018-06-01-preview/maintenance/updates.go | 207 +++++++ .../2018-06-01-preview/maintenance/version.go | 30 + 11 files changed, 2564 insertions(+) create mode 100644 profiles/preview/preview/maintenance/mgmt/maintenance/maintenanceapi/models.go create mode 100644 profiles/preview/preview/maintenance/mgmt/maintenance/models.go create mode 100644 services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/applyupdates.go create mode 100644 services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/client.go create mode 100644 services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/configurationassignments.go create mode 100644 services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/configurations.go create mode 100644 services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/maintenanceapi/interfaces.go create mode 100644 services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/models.go create mode 100644 services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/operations.go create mode 100644 services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/updates.go create mode 100644 services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/version.go diff --git a/profiles/preview/preview/maintenance/mgmt/maintenance/maintenanceapi/models.go b/profiles/preview/preview/maintenance/mgmt/maintenance/maintenanceapi/models.go new file mode 100644 index 000000000000..9aae9dd8b0d4 --- /dev/null +++ b/profiles/preview/preview/maintenance/mgmt/maintenance/maintenanceapi/models.go @@ -0,0 +1,28 @@ +// +build go1.9 + +// Copyright 2019 Microsoft Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// This code was auto-generated by: +// github.com/Azure/azure-sdk-for-go/tools/profileBuilder + +package maintenanceapi + +import original "github.com/Azure/azure-sdk-for-go/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/maintenanceapi" + +type ApplyUpdatesClientAPI = original.ApplyUpdatesClientAPI +type ConfigurationAssignmentsClientAPI = original.ConfigurationAssignmentsClientAPI +type ConfigurationsClientAPI = original.ConfigurationsClientAPI +type OperationsClientAPI = original.OperationsClientAPI +type UpdatesClientAPI = original.UpdatesClientAPI diff --git a/profiles/preview/preview/maintenance/mgmt/maintenance/models.go b/profiles/preview/preview/maintenance/mgmt/maintenance/models.go new file mode 100644 index 000000000000..873254c688c5 --- /dev/null +++ b/profiles/preview/preview/maintenance/mgmt/maintenance/models.go @@ -0,0 +1,130 @@ +// +build go1.9 + +// Copyright 2019 Microsoft Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// This code was auto-generated by: +// github.com/Azure/azure-sdk-for-go/tools/profileBuilder + +package maintenance + +import original "github.com/Azure/azure-sdk-for-go/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance" + +const ( + DefaultBaseURI = original.DefaultBaseURI +) + +type ImpactType = original.ImpactType + +const ( + Freeze ImpactType = original.Freeze + None ImpactType = original.None + Redeploy ImpactType = original.Redeploy + Restart ImpactType = original.Restart +) + +type Scope = original.Scope + +const ( + ScopeAll Scope = original.ScopeAll + ScopeHost Scope = original.ScopeHost + ScopeInResource Scope = original.ScopeInResource + ScopeResource Scope = original.ScopeResource +) + +type UpdateStatus = original.UpdateStatus + +const ( + Completed UpdateStatus = original.Completed + InProgress UpdateStatus = original.InProgress + Pending UpdateStatus = original.Pending + RetryLater UpdateStatus = original.RetryLater + RetryNow UpdateStatus = original.RetryNow +) + +type ApplyUpdate = original.ApplyUpdate +type ApplyUpdateProperties = original.ApplyUpdateProperties +type ApplyUpdatesClient = original.ApplyUpdatesClient +type BaseClient = original.BaseClient +type Configuration = original.Configuration +type ConfigurationAssignment = original.ConfigurationAssignment +type ConfigurationAssignmentProperties = original.ConfigurationAssignmentProperties +type ConfigurationAssignmentsClient = original.ConfigurationAssignmentsClient +type ConfigurationProperties = original.ConfigurationProperties +type ConfigurationsClient = original.ConfigurationsClient +type Error = original.Error +type ErrorDetails = original.ErrorDetails +type ListConfigurationAssignmentsResult = original.ListConfigurationAssignmentsResult +type ListMaintenanceConfigurationsResult = original.ListMaintenanceConfigurationsResult +type ListUpdatesResult = original.ListUpdatesResult +type Operation = original.Operation +type OperationInfo = original.OperationInfo +type OperationsClient = original.OperationsClient +type OperationsListResult = original.OperationsListResult +type Resource = original.Resource +type Update = original.Update +type UpdateProperties = original.UpdateProperties +type UpdatesClient = original.UpdatesClient + +func New(subscriptionID string) BaseClient { + return original.New(subscriptionID) +} +func NewApplyUpdatesClient(subscriptionID string) ApplyUpdatesClient { + return original.NewApplyUpdatesClient(subscriptionID) +} +func NewApplyUpdatesClientWithBaseURI(baseURI string, subscriptionID string) ApplyUpdatesClient { + return original.NewApplyUpdatesClientWithBaseURI(baseURI, subscriptionID) +} +func NewConfigurationAssignmentsClient(subscriptionID string) ConfigurationAssignmentsClient { + return original.NewConfigurationAssignmentsClient(subscriptionID) +} +func NewConfigurationAssignmentsClientWithBaseURI(baseURI string, subscriptionID string) ConfigurationAssignmentsClient { + return original.NewConfigurationAssignmentsClientWithBaseURI(baseURI, subscriptionID) +} +func NewConfigurationsClient(subscriptionID string) ConfigurationsClient { + return original.NewConfigurationsClient(subscriptionID) +} +func NewConfigurationsClientWithBaseURI(baseURI string, subscriptionID string) ConfigurationsClient { + return original.NewConfigurationsClientWithBaseURI(baseURI, subscriptionID) +} +func NewOperationsClient(subscriptionID string) OperationsClient { + return original.NewOperationsClient(subscriptionID) +} +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return original.NewOperationsClientWithBaseURI(baseURI, subscriptionID) +} +func NewUpdatesClient(subscriptionID string) UpdatesClient { + return original.NewUpdatesClient(subscriptionID) +} +func NewUpdatesClientWithBaseURI(baseURI string, subscriptionID string) UpdatesClient { + return original.NewUpdatesClientWithBaseURI(baseURI, subscriptionID) +} +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return original.NewWithBaseURI(baseURI, subscriptionID) +} +func PossibleImpactTypeValues() []ImpactType { + return original.PossibleImpactTypeValues() +} +func PossibleScopeValues() []Scope { + return original.PossibleScopeValues() +} +func PossibleUpdateStatusValues() []UpdateStatus { + return original.PossibleUpdateStatusValues() +} +func UserAgent() string { + return original.UserAgent() + " profiles/preview" +} +func Version() string { + return original.Version() +} diff --git a/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/applyupdates.go b/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/applyupdates.go new file mode 100644 index 000000000000..522184b9d626 --- /dev/null +++ b/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/applyupdates.go @@ -0,0 +1,377 @@ +package maintenance + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ApplyUpdatesClient is the azure Maintenance Management Client +type ApplyUpdatesClient struct { + BaseClient +} + +// NewApplyUpdatesClient creates an instance of the ApplyUpdatesClient client. +func NewApplyUpdatesClient(subscriptionID string) ApplyUpdatesClient { + return NewApplyUpdatesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewApplyUpdatesClientWithBaseURI creates an instance of the ApplyUpdatesClient client. +func NewApplyUpdatesClientWithBaseURI(baseURI string, subscriptionID string) ApplyUpdatesClient { + return ApplyUpdatesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate apply maintenance updates to resource +// Parameters: +// resourceGroupName - resource group name +// providerName - resource provider name +// resourceType - resource type +// resourceName - resource identifier +func (client ApplyUpdatesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string) (result ApplyUpdate, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplyUpdatesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, providerName, resourceType, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.ApplyUpdatesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "maintenance.ApplyUpdatesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.ApplyUpdatesClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ApplyUpdatesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "providerName": autorest.Encode("path", providerName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "resourceType": autorest.Encode("path", resourceType), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/applyUpdates/default", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ApplyUpdatesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ApplyUpdatesClient) CreateOrUpdateResponder(resp *http.Response) (result ApplyUpdate, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateOrUpdateParent apply maintenance updates to resource with parent +// Parameters: +// resourceGroupName - resource group name +// providerName - resource provider name +// resourceParentType - resource parent type +// resourceParentName - resource parent identifier +// resourceType - resource type +// resourceName - resource identifier +func (client ApplyUpdatesClient) CreateOrUpdateParent(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string) (result ApplyUpdate, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplyUpdatesClient.CreateOrUpdateParent") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdateParentPreparer(ctx, resourceGroupName, providerName, resourceParentType, resourceParentName, resourceType, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.ApplyUpdatesClient", "CreateOrUpdateParent", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateParentSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "maintenance.ApplyUpdatesClient", "CreateOrUpdateParent", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateParentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.ApplyUpdatesClient", "CreateOrUpdateParent", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdateParentPreparer prepares the CreateOrUpdateParent request. +func (client ApplyUpdatesClient) CreateOrUpdateParentPreparer(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "providerName": autorest.Encode("path", providerName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "resourceParentName": autorest.Encode("path", resourceParentName), + "resourceParentType": autorest.Encode("path", resourceParentType), + "resourceType": autorest.Encode("path", resourceType), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/applyUpdates/default", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateParentSender sends the CreateOrUpdateParent request. The method will close the +// http.Response Body if it receives an error. +func (client ApplyUpdatesClient) CreateOrUpdateParentSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// CreateOrUpdateParentResponder handles the response to the CreateOrUpdateParent request. The method always +// closes the http.Response Body. +func (client ApplyUpdatesClient) CreateOrUpdateParentResponder(resp *http.Response) (result ApplyUpdate, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get track maintenance updates to resource +// Parameters: +// resourceGroupName - resource group name +// providerName - resource provider name +// resourceType - resource type +// resourceName - resource identifier +// applyUpdateName - applyUpdate Id +func (client ApplyUpdatesClient) Get(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string, applyUpdateName string) (result ApplyUpdate, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplyUpdatesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, providerName, resourceType, resourceName, applyUpdateName) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.ApplyUpdatesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "maintenance.ApplyUpdatesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.ApplyUpdatesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ApplyUpdatesClient) GetPreparer(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string, applyUpdateName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applyUpdateName": autorest.Encode("path", applyUpdateName), + "providerName": autorest.Encode("path", providerName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "resourceType": autorest.Encode("path", resourceType), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/applyUpdates/{applyUpdateName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ApplyUpdatesClient) GetSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ApplyUpdatesClient) GetResponder(resp *http.Response) (result ApplyUpdate, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetParent track maintenance updates to resource with parent +// Parameters: +// resourceGroupName - resource group name +// resourceParentType - resource parent type +// resourceParentName - resource parent identifier +// providerName - resource provider name +// resourceType - resource type +// resourceName - resource identifier +// applyUpdateName - applyUpdate Id +func (client ApplyUpdatesClient) GetParent(ctx context.Context, resourceGroupName string, resourceParentType string, resourceParentName string, providerName string, resourceType string, resourceName string, applyUpdateName string) (result ApplyUpdate, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplyUpdatesClient.GetParent") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetParentPreparer(ctx, resourceGroupName, resourceParentType, resourceParentName, providerName, resourceType, resourceName, applyUpdateName) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.ApplyUpdatesClient", "GetParent", nil, "Failure preparing request") + return + } + + resp, err := client.GetParentSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "maintenance.ApplyUpdatesClient", "GetParent", resp, "Failure sending request") + return + } + + result, err = client.GetParentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.ApplyUpdatesClient", "GetParent", resp, "Failure responding to request") + } + + return +} + +// GetParentPreparer prepares the GetParent request. +func (client ApplyUpdatesClient) GetParentPreparer(ctx context.Context, resourceGroupName string, resourceParentType string, resourceParentName string, providerName string, resourceType string, resourceName string, applyUpdateName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applyUpdateName": autorest.Encode("path", applyUpdateName), + "providerName": autorest.Encode("path", providerName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "resourceParentName": autorest.Encode("path", resourceParentName), + "resourceParentType": autorest.Encode("path", resourceParentType), + "resourceType": autorest.Encode("path", resourceType), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/applyUpdates/{applyUpdateName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetParentSender sends the GetParent request. The method will close the +// http.Response Body if it receives an error. +func (client ApplyUpdatesClient) GetParentSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// GetParentResponder handles the response to the GetParent request. The method always +// closes the http.Response Body. +func (client ApplyUpdatesClient) GetParentResponder(resp *http.Response) (result ApplyUpdate, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/client.go b/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/client.go new file mode 100644 index 000000000000..6401c280e644 --- /dev/null +++ b/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/client.go @@ -0,0 +1,51 @@ +// Package maintenance implements the Azure ARM Maintenance service API version 2018-06-01-preview. +// +// Azure Maintenance Management Client +package maintenance + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Maintenance + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Maintenance. +type BaseClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the BaseClient client. +func New(subscriptionID string) BaseClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the BaseClient client. +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/configurationassignments.go b/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/configurationassignments.go new file mode 100644 index 000000000000..d2dbf2ff19c0 --- /dev/null +++ b/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/configurationassignments.go @@ -0,0 +1,553 @@ +package maintenance + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ConfigurationAssignmentsClient is the azure Maintenance Management Client +type ConfigurationAssignmentsClient struct { + BaseClient +} + +// NewConfigurationAssignmentsClient creates an instance of the ConfigurationAssignmentsClient client. +func NewConfigurationAssignmentsClient(subscriptionID string) ConfigurationAssignmentsClient { + return NewConfigurationAssignmentsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewConfigurationAssignmentsClientWithBaseURI creates an instance of the ConfigurationAssignmentsClient client. +func NewConfigurationAssignmentsClientWithBaseURI(baseURI string, subscriptionID string) ConfigurationAssignmentsClient { + return ConfigurationAssignmentsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate register configuration for resource. +// Parameters: +// resourceGroupName - resource group name +// providerName - resource provider name +// resourceType - resource type +// resourceName - resource identifier +// configurationAssignmentName - configuration assignment name +// configurationAssignment - the configurationAssignment +func (client ConfigurationAssignmentsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string, configurationAssignmentName string, configurationAssignment ConfigurationAssignment) (result ConfigurationAssignment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationAssignmentsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, providerName, resourceType, resourceName, configurationAssignmentName, configurationAssignment) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationAssignmentsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationAssignmentsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationAssignmentsClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ConfigurationAssignmentsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string, configurationAssignmentName string, configurationAssignment ConfigurationAssignment) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configurationAssignmentName": autorest.Encode("path", configurationAssignmentName), + "providerName": autorest.Encode("path", providerName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "resourceType": autorest.Encode("path", resourceType), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}", pathParameters), + autorest.WithJSON(configurationAssignment), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ConfigurationAssignmentsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ConfigurationAssignmentsClient) CreateOrUpdateResponder(resp *http.Response) (result ConfigurationAssignment, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateOrUpdateParent register configuration for resource. +// Parameters: +// resourceGroupName - resource group name +// providerName - resource provider name +// resourceParentType - resource parent type +// resourceParentName - resource parent identifier +// resourceType - resource type +// resourceName - resource identifier +// configurationAssignmentName - configuration assignment name +// configurationAssignment - the configurationAssignment +func (client ConfigurationAssignmentsClient) CreateOrUpdateParent(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string, configurationAssignmentName string, configurationAssignment ConfigurationAssignment) (result ConfigurationAssignment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationAssignmentsClient.CreateOrUpdateParent") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdateParentPreparer(ctx, resourceGroupName, providerName, resourceParentType, resourceParentName, resourceType, resourceName, configurationAssignmentName, configurationAssignment) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationAssignmentsClient", "CreateOrUpdateParent", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateParentSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationAssignmentsClient", "CreateOrUpdateParent", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateParentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationAssignmentsClient", "CreateOrUpdateParent", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdateParentPreparer prepares the CreateOrUpdateParent request. +func (client ConfigurationAssignmentsClient) CreateOrUpdateParentPreparer(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string, configurationAssignmentName string, configurationAssignment ConfigurationAssignment) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configurationAssignmentName": autorest.Encode("path", configurationAssignmentName), + "providerName": autorest.Encode("path", providerName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "resourceParentName": autorest.Encode("path", resourceParentName), + "resourceParentType": autorest.Encode("path", resourceParentType), + "resourceType": autorest.Encode("path", resourceType), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}", pathParameters), + autorest.WithJSON(configurationAssignment), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateParentSender sends the CreateOrUpdateParent request. The method will close the +// http.Response Body if it receives an error. +func (client ConfigurationAssignmentsClient) CreateOrUpdateParentSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// CreateOrUpdateParentResponder handles the response to the CreateOrUpdateParent request. The method always +// closes the http.Response Body. +func (client ConfigurationAssignmentsClient) CreateOrUpdateParentResponder(resp *http.Response) (result ConfigurationAssignment, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete unregister configuration for resource. +// Parameters: +// resourceGroupName - resource group name +// providerName - resource provider name +// resourceType - resource type +// resourceName - resource identifier +// configurationAssignmentName - unique configuration assignment name +func (client ConfigurationAssignmentsClient) Delete(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string, configurationAssignmentName string) (result ConfigurationAssignment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationAssignmentsClient.Delete") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, providerName, resourceType, resourceName, configurationAssignmentName) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationAssignmentsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationAssignmentsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationAssignmentsClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ConfigurationAssignmentsClient) DeletePreparer(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string, configurationAssignmentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configurationAssignmentName": autorest.Encode("path", configurationAssignmentName), + "providerName": autorest.Encode("path", providerName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "resourceType": autorest.Encode("path", resourceType), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ConfigurationAssignmentsClient) DeleteSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ConfigurationAssignmentsClient) DeleteResponder(resp *http.Response) (result ConfigurationAssignment, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// DeleteParent unregister configuration for resource. +// Parameters: +// resourceGroupName - resource group name +// providerName - resource provider name +// resourceParentType - resource parent type +// resourceParentName - resource parent identifier +// resourceType - resource type +// resourceName - resource identifier +// configurationAssignmentName - unique configuration assignment name +func (client ConfigurationAssignmentsClient) DeleteParent(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string, configurationAssignmentName string) (result ConfigurationAssignment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationAssignmentsClient.DeleteParent") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeleteParentPreparer(ctx, resourceGroupName, providerName, resourceParentType, resourceParentName, resourceType, resourceName, configurationAssignmentName) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationAssignmentsClient", "DeleteParent", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteParentSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationAssignmentsClient", "DeleteParent", resp, "Failure sending request") + return + } + + result, err = client.DeleteParentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationAssignmentsClient", "DeleteParent", resp, "Failure responding to request") + } + + return +} + +// DeleteParentPreparer prepares the DeleteParent request. +func (client ConfigurationAssignmentsClient) DeleteParentPreparer(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string, configurationAssignmentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configurationAssignmentName": autorest.Encode("path", configurationAssignmentName), + "providerName": autorest.Encode("path", providerName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "resourceParentName": autorest.Encode("path", resourceParentName), + "resourceParentType": autorest.Encode("path", resourceParentType), + "resourceType": autorest.Encode("path", resourceType), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteParentSender sends the DeleteParent request. The method will close the +// http.Response Body if it receives an error. +func (client ConfigurationAssignmentsClient) DeleteParentSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// DeleteParentResponder handles the response to the DeleteParent request. The method always +// closes the http.Response Body. +func (client ConfigurationAssignmentsClient) DeleteParentResponder(resp *http.Response) (result ConfigurationAssignment, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List list configurationAssignments for resource. +// Parameters: +// resourceGroupName - resource group name +// providerName - resource provider name +// resourceType - resource type +// resourceName - resource identifier +func (client ConfigurationAssignmentsClient) List(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string) (result ListConfigurationAssignmentsResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationAssignmentsClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListPreparer(ctx, resourceGroupName, providerName, resourceType, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationAssignmentsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationAssignmentsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationAssignmentsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client ConfigurationAssignmentsClient) ListPreparer(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "providerName": autorest.Encode("path", providerName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "resourceType": autorest.Encode("path", resourceType), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client ConfigurationAssignmentsClient) ListSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ConfigurationAssignmentsClient) ListResponder(resp *http.Response) (result ListConfigurationAssignmentsResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListParent list configurationAssignments for resource. +// Parameters: +// resourceGroupName - resource group name +// providerName - resource provider name +// resourceParentType - resource parent type +// resourceParentName - resource parent identifier +// resourceType - resource type +// resourceName - resource identifier +func (client ConfigurationAssignmentsClient) ListParent(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string) (result ListConfigurationAssignmentsResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationAssignmentsClient.ListParent") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListParentPreparer(ctx, resourceGroupName, providerName, resourceParentType, resourceParentName, resourceType, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationAssignmentsClient", "ListParent", nil, "Failure preparing request") + return + } + + resp, err := client.ListParentSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationAssignmentsClient", "ListParent", resp, "Failure sending request") + return + } + + result, err = client.ListParentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationAssignmentsClient", "ListParent", resp, "Failure responding to request") + } + + return +} + +// ListParentPreparer prepares the ListParent request. +func (client ConfigurationAssignmentsClient) ListParentPreparer(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "providerName": autorest.Encode("path", providerName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "resourceParentName": autorest.Encode("path", resourceParentName), + "resourceParentType": autorest.Encode("path", resourceParentType), + "resourceType": autorest.Encode("path", resourceType), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListParentSender sends the ListParent request. The method will close the +// http.Response Body if it receives an error. +func (client ConfigurationAssignmentsClient) ListParentSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListParentResponder handles the response to the ListParent request. The method always +// closes the http.Response Body. +func (client ConfigurationAssignmentsClient) ListParentResponder(resp *http.Response) (result ListConfigurationAssignmentsResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/configurations.go b/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/configurations.go new file mode 100644 index 000000000000..35504da43e2b --- /dev/null +++ b/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/configurations.go @@ -0,0 +1,427 @@ +package maintenance + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ConfigurationsClient is the azure Maintenance Management Client +type ConfigurationsClient struct { + BaseClient +} + +// NewConfigurationsClient creates an instance of the ConfigurationsClient client. +func NewConfigurationsClient(subscriptionID string) ConfigurationsClient { + return NewConfigurationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewConfigurationsClientWithBaseURI creates an instance of the ConfigurationsClient client. +func NewConfigurationsClientWithBaseURI(baseURI string, subscriptionID string) ConfigurationsClient { + return ConfigurationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate sends the create or update request. +// Parameters: +// resourceGroupName - resource Group Name +// resourceName - resource Identifier +// configuration - the configuration +func (client ConfigurationsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, configuration Configuration) (result Configuration, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, resourceName, configuration) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationsClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ConfigurationsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, configuration Configuration) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations/{resourceName}", pathParameters), + autorest.WithJSON(configuration), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ConfigurationsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ConfigurationsClient) CreateOrUpdateResponder(resp *http.Response) (result Configuration, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete sends the delete request. +// Parameters: +// resourceGroupName - resource Group Name +// resourceName - resource Identifier +func (client ConfigurationsClient) Delete(ctx context.Context, resourceGroupName string, resourceName string) (result Configuration, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationsClient.Delete") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationsClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ConfigurationsClient) DeletePreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations/{resourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ConfigurationsClient) DeleteSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ConfigurationsClient) DeleteResponder(resp *http.Response) (result Configuration, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get sends the get request. +// Parameters: +// resourceGroupName - resource Group Name +// resourceName - resource Identifier +func (client ConfigurationsClient) Get(ctx context.Context, resourceGroupName string, resourceName string) (result Configuration, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ConfigurationsClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations/{resourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ConfigurationsClient) GetSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ConfigurationsClient) GetResponder(resp *http.Response) (result Configuration, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List sends the list request. +func (client ConfigurationsClient) List(ctx context.Context) (result ListMaintenanceConfigurationsResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationsClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client ConfigurationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/maintenanceConfigurations", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client ConfigurationsClient) ListSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ConfigurationsClient) ListResponder(resp *http.Response) (result ListMaintenanceConfigurationsResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// UpdateMethod sends the update method request. +// Parameters: +// resourceGroupName - resource Group Name +// resourceName - resource Identifier +// configuration - the configuration +func (client ConfigurationsClient) UpdateMethod(ctx context.Context, resourceGroupName string, resourceName string, configuration Configuration) (result Configuration, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationsClient.UpdateMethod") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdateMethodPreparer(ctx, resourceGroupName, resourceName, configuration) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationsClient", "UpdateMethod", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateMethodSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationsClient", "UpdateMethod", resp, "Failure sending request") + return + } + + result, err = client.UpdateMethodResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationsClient", "UpdateMethod", resp, "Failure responding to request") + } + + return +} + +// UpdateMethodPreparer prepares the UpdateMethod request. +func (client ConfigurationsClient) UpdateMethodPreparer(ctx context.Context, resourceGroupName string, resourceName string, configuration Configuration) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations/{resourceName}", pathParameters), + autorest.WithJSON(configuration), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateMethodSender sends the UpdateMethod request. The method will close the +// http.Response Body if it receives an error. +func (client ConfigurationsClient) UpdateMethodSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// UpdateMethodResponder handles the response to the UpdateMethod request. The method always +// closes the http.Response Body. +func (client ConfigurationsClient) UpdateMethodResponder(resp *http.Response) (result Configuration, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/maintenanceapi/interfaces.go b/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/maintenanceapi/interfaces.go new file mode 100644 index 000000000000..43eb719280a2 --- /dev/null +++ b/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/maintenanceapi/interfaces.go @@ -0,0 +1,71 @@ +package maintenanceapi + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance" +) + +// ApplyUpdatesClientAPI contains the set of methods on the ApplyUpdatesClient type. +type ApplyUpdatesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string) (result maintenance.ApplyUpdate, err error) + CreateOrUpdateParent(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string) (result maintenance.ApplyUpdate, err error) + Get(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string, applyUpdateName string) (result maintenance.ApplyUpdate, err error) + GetParent(ctx context.Context, resourceGroupName string, resourceParentType string, resourceParentName string, providerName string, resourceType string, resourceName string, applyUpdateName string) (result maintenance.ApplyUpdate, err error) +} + +var _ ApplyUpdatesClientAPI = (*maintenance.ApplyUpdatesClient)(nil) + +// ConfigurationAssignmentsClientAPI contains the set of methods on the ConfigurationAssignmentsClient type. +type ConfigurationAssignmentsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string, configurationAssignmentName string, configurationAssignment maintenance.ConfigurationAssignment) (result maintenance.ConfigurationAssignment, err error) + CreateOrUpdateParent(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string, configurationAssignmentName string, configurationAssignment maintenance.ConfigurationAssignment) (result maintenance.ConfigurationAssignment, err error) + Delete(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string, configurationAssignmentName string) (result maintenance.ConfigurationAssignment, err error) + DeleteParent(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string, configurationAssignmentName string) (result maintenance.ConfigurationAssignment, err error) + List(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string) (result maintenance.ListConfigurationAssignmentsResult, err error) + ListParent(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string) (result maintenance.ListConfigurationAssignmentsResult, err error) +} + +var _ ConfigurationAssignmentsClientAPI = (*maintenance.ConfigurationAssignmentsClient)(nil) + +// ConfigurationsClientAPI contains the set of methods on the ConfigurationsClient type. +type ConfigurationsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, configuration maintenance.Configuration) (result maintenance.Configuration, err error) + Delete(ctx context.Context, resourceGroupName string, resourceName string) (result maintenance.Configuration, err error) + Get(ctx context.Context, resourceGroupName string, resourceName string) (result maintenance.Configuration, err error) + List(ctx context.Context) (result maintenance.ListMaintenanceConfigurationsResult, err error) + UpdateMethod(ctx context.Context, resourceGroupName string, resourceName string, configuration maintenance.Configuration) (result maintenance.Configuration, err error) +} + +var _ ConfigurationsClientAPI = (*maintenance.ConfigurationsClient)(nil) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + List(ctx context.Context) (result maintenance.OperationsListResult, err error) +} + +var _ OperationsClientAPI = (*maintenance.OperationsClient)(nil) + +// UpdatesClientAPI contains the set of methods on the UpdatesClient type. +type UpdatesClientAPI interface { + List(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string) (result maintenance.ListUpdatesResult, err error) + ListParent(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string) (result maintenance.ListUpdatesResult, err error) +} + +var _ UpdatesClientAPI = (*maintenance.UpdatesClient)(nil) diff --git a/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/models.go b/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/models.go new file mode 100644 index 000000000000..34796e7b49c1 --- /dev/null +++ b/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/models.go @@ -0,0 +1,581 @@ +package maintenance + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/date" +) + +// The package's fully qualified name. +const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance" + +// ImpactType enumerates the values for impact type. +type ImpactType string + +const ( + // Freeze ... + Freeze ImpactType = "Freeze" + // None ... + None ImpactType = "None" + // Redeploy ... + Redeploy ImpactType = "Redeploy" + // Restart ... + Restart ImpactType = "Restart" +) + +// PossibleImpactTypeValues returns an array of possible values for the ImpactType const type. +func PossibleImpactTypeValues() []ImpactType { + return []ImpactType{Freeze, None, Redeploy, Restart} +} + +// Scope enumerates the values for scope. +type Scope string + +const ( + // ScopeAll ... + ScopeAll Scope = "All" + // ScopeHost ... + ScopeHost Scope = "Host" + // ScopeInResource ... + ScopeInResource Scope = "InResource" + // ScopeResource ... + ScopeResource Scope = "Resource" +) + +// PossibleScopeValues returns an array of possible values for the Scope const type. +func PossibleScopeValues() []Scope { + return []Scope{ScopeAll, ScopeHost, ScopeInResource, ScopeResource} +} + +// UpdateStatus enumerates the values for update status. +type UpdateStatus string + +const ( + // Completed ... + Completed UpdateStatus = "Completed" + // InProgress ... + InProgress UpdateStatus = "InProgress" + // Pending ... + Pending UpdateStatus = "Pending" + // RetryLater ... + RetryLater UpdateStatus = "RetryLater" + // RetryNow ... + RetryNow UpdateStatus = "RetryNow" +) + +// PossibleUpdateStatusValues returns an array of possible values for the UpdateStatus const type. +func PossibleUpdateStatusValues() []UpdateStatus { + return []UpdateStatus{Completed, InProgress, Pending, RetryLater, RetryNow} +} + +// ApplyUpdate apply Update request +type ApplyUpdate struct { + autorest.Response `json:"-"` + // ApplyUpdateProperties - Properties of the apply update + *ApplyUpdateProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Fully qualified identifier of the resource + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Type of the resource + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ApplyUpdate. +func (au ApplyUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if au.ApplyUpdateProperties != nil { + objectMap["properties"] = au.ApplyUpdateProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ApplyUpdate struct. +func (au *ApplyUpdate) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var applyUpdateProperties ApplyUpdateProperties + err = json.Unmarshal(*v, &applyUpdateProperties) + if err != nil { + return err + } + au.ApplyUpdateProperties = &applyUpdateProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + au.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + au.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + au.Type = &typeVar + } + } + } + + return nil +} + +// ApplyUpdateProperties properties for apply update +type ApplyUpdateProperties struct { + // Status - The status. Possible values include: 'Pending', 'InProgress', 'Completed', 'RetryNow', 'RetryLater' + Status UpdateStatus `json:"status,omitempty"` + // ResourceID - The resourceId + ResourceID *string `json:"resourceId,omitempty"` + // LastUpdateTime - Last Update time + LastUpdateTime *date.Time `json:"lastUpdateTime,omitempty"` +} + +// Configuration maintenance configuration record type +type Configuration struct { + autorest.Response `json:"-"` + // Location - Gets or sets location of the resource + Location *string `json:"location,omitempty"` + // Tags - Gets or sets tags of the resource + Tags map[string]*string `json:"tags"` + // ConfigurationProperties - Gets or sets properties of the resource + *ConfigurationProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Fully qualified identifier of the resource + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Type of the resource + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Configuration. +func (c Configuration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if c.Location != nil { + objectMap["location"] = c.Location + } + if c.Tags != nil { + objectMap["tags"] = c.Tags + } + if c.ConfigurationProperties != nil { + objectMap["properties"] = c.ConfigurationProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Configuration struct. +func (c *Configuration) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + c.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + c.Tags = tags + } + case "properties": + if v != nil { + var configurationProperties ConfigurationProperties + err = json.Unmarshal(*v, &configurationProperties) + if err != nil { + return err + } + c.ConfigurationProperties = &configurationProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + c.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + c.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + c.Type = &typeVar + } + } + } + + return nil +} + +// ConfigurationAssignment configuration Assignment +type ConfigurationAssignment struct { + autorest.Response `json:"-"` + // Location - Location of the resource + Location *string `json:"location,omitempty"` + // ConfigurationAssignmentProperties - Properties of the configuration assignment + *ConfigurationAssignmentProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Fully qualified identifier of the resource + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Type of the resource + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ConfigurationAssignment. +func (ca ConfigurationAssignment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ca.Location != nil { + objectMap["location"] = ca.Location + } + if ca.ConfigurationAssignmentProperties != nil { + objectMap["properties"] = ca.ConfigurationAssignmentProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ConfigurationAssignment struct. +func (ca *ConfigurationAssignment) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + ca.Location = &location + } + case "properties": + if v != nil { + var configurationAssignmentProperties ConfigurationAssignmentProperties + err = json.Unmarshal(*v, &configurationAssignmentProperties) + if err != nil { + return err + } + ca.ConfigurationAssignmentProperties = &configurationAssignmentProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ca.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ca.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ca.Type = &typeVar + } + } + } + + return nil +} + +// ConfigurationAssignmentProperties properties for configuration assignment +type ConfigurationAssignmentProperties struct { + // MaintenanceConfigurationID - The maintenance configuration Id + MaintenanceConfigurationID *string `json:"maintenanceConfigurationId,omitempty"` + // ResourceID - The unique resourceId + ResourceID *string `json:"resourceId,omitempty"` +} + +// ConfigurationProperties properties for maintenance configuration +type ConfigurationProperties struct { + // Namespace - Gets or sets namespace of the resource + Namespace *string `json:"namespace,omitempty"` + // ExtensionProperties - Gets or sets extensionProperties of the maintenanceConfiguration + ExtensionProperties map[string]*string `json:"extensionProperties"` + // MaintenanceScope - Gets or sets maintenanceScope of the configuration. Possible values include: 'ScopeAll', 'ScopeHost', 'ScopeResource', 'ScopeInResource' + MaintenanceScope Scope `json:"maintenanceScope,omitempty"` +} + +// MarshalJSON is the custom marshaler for ConfigurationProperties. +func (cp ConfigurationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cp.Namespace != nil { + objectMap["namespace"] = cp.Namespace + } + if cp.ExtensionProperties != nil { + objectMap["extensionProperties"] = cp.ExtensionProperties + } + if cp.MaintenanceScope != "" { + objectMap["maintenanceScope"] = cp.MaintenanceScope + } + return json.Marshal(objectMap) +} + +// Error an error response received from the Azure Maintenance service. +type Error struct { + // Error - Details of the error + Error *ErrorDetails `json:"error,omitempty"` +} + +// ErrorDetails an error response details received from the Azure Maintenance service. +type ErrorDetails struct { + // Code - Service-defined error code. This code serves as a sub-status for the HTTP error code specified in the response. + Code *string `json:"code,omitempty"` + // Message - Human-readable representation of the error. + Message *string `json:"message,omitempty"` +} + +// ListConfigurationAssignmentsResult response for ConfigurationAssignments list +type ListConfigurationAssignmentsResult struct { + autorest.Response `json:"-"` + // Value - The list of configuration Assignments + Value *[]ConfigurationAssignment `json:"value,omitempty"` +} + +// ListMaintenanceConfigurationsResult response for MaintenanceConfigurations list +type ListMaintenanceConfigurationsResult struct { + autorest.Response `json:"-"` + // Value - The list of maintenance Configurations + Value *[]Configuration `json:"value,omitempty"` +} + +// ListUpdatesResult response for Updates list +type ListUpdatesResult struct { + autorest.Response `json:"-"` + // Value - The pending updates + Value *[]Update `json:"value,omitempty"` +} + +// Operation represents an operation returned by the GetOperations request +type Operation struct { + // Name - Name of the operation + Name *string `json:"name,omitempty"` + // Display - Display name of the operation + Display *OperationInfo `json:"display,omitempty"` + // Origin - Origin of the operation + Origin *string `json:"origin,omitempty"` + // Properties - Properties of the operation + Properties interface{} `json:"properties,omitempty"` +} + +// OperationInfo information about an operation +type OperationInfo struct { + // Provider - Name of the provider + Provider *string `json:"provider,omitempty"` + // Resource - Name of the resource type + Resource *string `json:"resource,omitempty"` + // Operation - Name of the operation + Operation *string `json:"operation,omitempty"` + // Description - Description of the operation + Description *string `json:"description,omitempty"` +} + +// OperationsListResult result of the List Operations operation +type OperationsListResult struct { + autorest.Response `json:"-"` + // Value - A collection of operations + Value *[]Operation `json:"value,omitempty"` +} + +// Resource definition of a Resource +type Resource struct { + // ID - READ-ONLY; Fully qualified identifier of the resource + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Type of the resource + Type *string `json:"type,omitempty"` +} + +// Update maintenance update on a resource +type Update struct { + // MaintenanceScope - The impact area. Possible values include: 'ScopeAll', 'ScopeHost', 'ScopeResource', 'ScopeInResource' + MaintenanceScope Scope `json:"maintenanceScope,omitempty"` + // ImpactType - The impact type. Possible values include: 'None', 'Freeze', 'Restart', 'Redeploy' + ImpactType ImpactType `json:"impactType,omitempty"` + // Status - The status. Possible values include: 'Pending', 'InProgress', 'Completed', 'RetryNow', 'RetryLater' + Status UpdateStatus `json:"status,omitempty"` + // ImpactDurationInSec - Duration of impact in seconds + ImpactDurationInSec *int32 `json:"impactDurationInSec,omitempty"` + // NotBefore - Time when Azure will start force updates if not self-updated by customer before this time + NotBefore *date.Time `json:"notBefore,omitempty"` + // UpdateProperties - Properties of the apply update + *UpdateProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for Update. +func (u Update) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if u.MaintenanceScope != "" { + objectMap["maintenanceScope"] = u.MaintenanceScope + } + if u.ImpactType != "" { + objectMap["impactType"] = u.ImpactType + } + if u.Status != "" { + objectMap["status"] = u.Status + } + if u.ImpactDurationInSec != nil { + objectMap["impactDurationInSec"] = u.ImpactDurationInSec + } + if u.NotBefore != nil { + objectMap["notBefore"] = u.NotBefore + } + if u.UpdateProperties != nil { + objectMap["properties"] = u.UpdateProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Update struct. +func (u *Update) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "maintenanceScope": + if v != nil { + var maintenanceScope Scope + err = json.Unmarshal(*v, &maintenanceScope) + if err != nil { + return err + } + u.MaintenanceScope = maintenanceScope + } + case "impactType": + if v != nil { + var impactType ImpactType + err = json.Unmarshal(*v, &impactType) + if err != nil { + return err + } + u.ImpactType = impactType + } + case "status": + if v != nil { + var status UpdateStatus + err = json.Unmarshal(*v, &status) + if err != nil { + return err + } + u.Status = status + } + case "impactDurationInSec": + if v != nil { + var impactDurationInSec int32 + err = json.Unmarshal(*v, &impactDurationInSec) + if err != nil { + return err + } + u.ImpactDurationInSec = &impactDurationInSec + } + case "notBefore": + if v != nil { + var notBefore date.Time + err = json.Unmarshal(*v, ¬Before) + if err != nil { + return err + } + u.NotBefore = ¬Before + } + case "properties": + if v != nil { + var updateProperties UpdateProperties + err = json.Unmarshal(*v, &updateProperties) + if err != nil { + return err + } + u.UpdateProperties = &updateProperties + } + } + } + + return nil +} + +// UpdateProperties properties for update +type UpdateProperties struct { + // ResourceID - The resourceId + ResourceID *string `json:"resourceId,omitempty"` +} diff --git a/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/operations.go b/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/operations.go new file mode 100644 index 000000000000..0f45be5df825 --- /dev/null +++ b/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/operations.go @@ -0,0 +1,109 @@ +package maintenance + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// OperationsClient is the azure Maintenance Management Client +type OperationsClient struct { + BaseClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client. +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List list the available operations supported by the Microsoft.Maintenance resource provider +func (client OperationsClient) List(ctx context.Context) (result OperationsListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "maintenance.OperationsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.OperationsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Maintenance/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationsListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/updates.go b/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/updates.go new file mode 100644 index 000000000000..1647a556fffb --- /dev/null +++ b/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/updates.go @@ -0,0 +1,207 @@ +package maintenance + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// UpdatesClient is the azure Maintenance Management Client +type UpdatesClient struct { + BaseClient +} + +// NewUpdatesClient creates an instance of the UpdatesClient client. +func NewUpdatesClient(subscriptionID string) UpdatesClient { + return NewUpdatesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewUpdatesClientWithBaseURI creates an instance of the UpdatesClient client. +func NewUpdatesClientWithBaseURI(baseURI string, subscriptionID string) UpdatesClient { + return UpdatesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List get updates to resources. +// Parameters: +// resourceGroupName - resource group name +// providerName - resource provider name +// resourceType - resource type +// resourceName - resource identifier +func (client UpdatesClient) List(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string) (result ListUpdatesResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/UpdatesClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListPreparer(ctx, resourceGroupName, providerName, resourceType, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.UpdatesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "maintenance.UpdatesClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.UpdatesClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client UpdatesClient) ListPreparer(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "providerName": autorest.Encode("path", providerName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "resourceType": autorest.Encode("path", resourceType), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/updates", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client UpdatesClient) ListSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client UpdatesClient) ListResponder(resp *http.Response) (result ListUpdatesResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListParent get updates to resources. +// Parameters: +// resourceGroupName - resource group name +// providerName - resource provider name +// resourceParentType - resource parent type +// resourceParentName - resource parent identifier +// resourceType - resource type +// resourceName - resource identifier +func (client UpdatesClient) ListParent(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string) (result ListUpdatesResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/UpdatesClient.ListParent") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListParentPreparer(ctx, resourceGroupName, providerName, resourceParentType, resourceParentName, resourceType, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.UpdatesClient", "ListParent", nil, "Failure preparing request") + return + } + + resp, err := client.ListParentSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "maintenance.UpdatesClient", "ListParent", resp, "Failure sending request") + return + } + + result, err = client.ListParentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.UpdatesClient", "ListParent", resp, "Failure responding to request") + } + + return +} + +// ListParentPreparer prepares the ListParent request. +func (client UpdatesClient) ListParentPreparer(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "providerName": autorest.Encode("path", providerName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "resourceParentName": autorest.Encode("path", resourceParentName), + "resourceParentType": autorest.Encode("path", resourceParentType), + "resourceType": autorest.Encode("path", resourceType), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/updates", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListParentSender sends the ListParent request. The method will close the +// http.Response Body if it receives an error. +func (client UpdatesClient) ListParentSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListParentResponder handles the response to the ListParent request. The method always +// closes the http.Response Body. +func (client UpdatesClient) ListParentResponder(resp *http.Response) (result ListUpdatesResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/version.go b/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/version.go new file mode 100644 index 000000000000..dd7474e61c38 --- /dev/null +++ b/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/version.go @@ -0,0 +1,30 @@ +package maintenance + +import "github.com/Azure/azure-sdk-for-go/version" + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + version.Number + " maintenance/2018-06-01-preview" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +}