From 8c1216b55dad2665b09bf80d11186dc36dd26605 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Tue, 3 Jul 2018 14:21:57 +0000 Subject: [PATCH 1/3] Generated from d88a6c0dcaa870b5c315ce8eca79798363fb5361 fix workbook patch operation --- .../appinsights/mgmt/insights/models.go | 13 +- .../appinsights/mgmt/insights/models.go | 13 +- .../mgmt/2015-05-01/insights/models.go | 147 ++++++-- .../mgmt/2015-05-01/insights/workbook.go | 326 ++++++++++++++++++ .../mgmt/2015-05-01/insights/workbooks.go | 290 +--------------- 5 files changed, 470 insertions(+), 319 deletions(-) create mode 100644 services/appinsights/mgmt/2015-05-01/insights/workbook.go diff --git a/profiles/latest/appinsights/mgmt/insights/models.go b/profiles/latest/appinsights/mgmt/insights/models.go index c06bb7af5f78..770b95cbf367 100644 --- a/profiles/latest/appinsights/mgmt/insights/models.go +++ b/profiles/latest/appinsights/mgmt/insights/models.go @@ -185,6 +185,7 @@ type OperationDisplay = original.OperationDisplay type OperationListResult = original.OperationListResult type OperationListResultIterator = original.OperationListResultIterator type OperationListResultPage = original.OperationListResultPage +type Resource = original.Resource type SetObject = original.SetObject type TagsResource = original.TagsResource type WebTest = original.WebTest @@ -198,8 +199,9 @@ type WebtestsResource = original.WebtestsResource type Workbook = original.Workbook type WorkbookError = original.WorkbookError type WorkbookProperties = original.WorkbookProperties -type WorkbookResource = original.WorkbookResource -type WorkbooksListResult = original.WorkbooksListResult +type WorkbookPropertiesUpdateParameters = original.WorkbookPropertiesUpdateParameters +type Workbooks = original.Workbooks +type WorkbookUpdateParameters = original.WorkbookUpdateParameters type WorkItemConfiguration = original.WorkItemConfiguration type WorkItemConfigurationError = original.WorkItemConfigurationError type WorkItemConfigurationsListResult = original.WorkItemConfigurationsListResult @@ -208,6 +210,7 @@ type OperationsClient = original.OperationsClient type ProactiveDetectionConfigurationsClient = original.ProactiveDetectionConfigurationsClient type WebTestLocationsClient = original.WebTestLocationsClient type WebTestsClient = original.WebTestsClient +type WorkbookClient = original.WorkbookClient type WorkbooksClient = original.WorkbooksClient type WorkItemConfigurationsClient = original.WorkItemConfigurationsClient @@ -346,6 +349,12 @@ func NewWebTestsClient(subscriptionID string) WebTestsClient { func NewWebTestsClientWithBaseURI(baseURI string, subscriptionID string) WebTestsClient { return original.NewWebTestsClientWithBaseURI(baseURI, subscriptionID) } +func NewWorkbookClient(subscriptionID string) WorkbookClient { + return original.NewWorkbookClient(subscriptionID) +} +func NewWorkbookClientWithBaseURI(baseURI string, subscriptionID string) WorkbookClient { + return original.NewWorkbookClientWithBaseURI(baseURI, subscriptionID) +} func NewWorkbooksClient(subscriptionID string) WorkbooksClient { return original.NewWorkbooksClient(subscriptionID) } diff --git a/profiles/preview/appinsights/mgmt/insights/models.go b/profiles/preview/appinsights/mgmt/insights/models.go index d88d1a980050..2ecb03a273f9 100644 --- a/profiles/preview/appinsights/mgmt/insights/models.go +++ b/profiles/preview/appinsights/mgmt/insights/models.go @@ -185,6 +185,7 @@ type OperationDisplay = original.OperationDisplay type OperationListResult = original.OperationListResult type OperationListResultIterator = original.OperationListResultIterator type OperationListResultPage = original.OperationListResultPage +type Resource = original.Resource type SetObject = original.SetObject type TagsResource = original.TagsResource type WebTest = original.WebTest @@ -198,8 +199,9 @@ type WebtestsResource = original.WebtestsResource type Workbook = original.Workbook type WorkbookError = original.WorkbookError type WorkbookProperties = original.WorkbookProperties -type WorkbookResource = original.WorkbookResource -type WorkbooksListResult = original.WorkbooksListResult +type WorkbookPropertiesUpdateParameters = original.WorkbookPropertiesUpdateParameters +type Workbooks = original.Workbooks +type WorkbookUpdateParameters = original.WorkbookUpdateParameters type WorkItemConfiguration = original.WorkItemConfiguration type WorkItemConfigurationError = original.WorkItemConfigurationError type WorkItemConfigurationsListResult = original.WorkItemConfigurationsListResult @@ -208,6 +210,7 @@ type OperationsClient = original.OperationsClient type ProactiveDetectionConfigurationsClient = original.ProactiveDetectionConfigurationsClient type WebTestLocationsClient = original.WebTestLocationsClient type WebTestsClient = original.WebTestsClient +type WorkbookClient = original.WorkbookClient type WorkbooksClient = original.WorkbooksClient type WorkItemConfigurationsClient = original.WorkItemConfigurationsClient @@ -346,6 +349,12 @@ func NewWebTestsClient(subscriptionID string) WebTestsClient { func NewWebTestsClientWithBaseURI(baseURI string, subscriptionID string) WebTestsClient { return original.NewWebTestsClientWithBaseURI(baseURI, subscriptionID) } +func NewWorkbookClient(subscriptionID string) WorkbookClient { + return original.NewWorkbookClient(subscriptionID) +} +func NewWorkbookClientWithBaseURI(baseURI string, subscriptionID string) WorkbookClient { + return original.NewWorkbookClientWithBaseURI(baseURI, subscriptionID) +} func NewWorkbooksClient(subscriptionID string) WorkbooksClient { return original.NewWorkbooksClient(subscriptionID) } diff --git a/services/appinsights/mgmt/2015-05-01/insights/models.go b/services/appinsights/mgmt/2015-05-01/insights/models.go index 3222af87998d..a92b247cfb6d 100644 --- a/services/appinsights/mgmt/2015-05-01/insights/models.go +++ b/services/appinsights/mgmt/2015-05-01/insights/models.go @@ -1117,6 +1117,41 @@ func (page OperationListResultPage) Values() []Operation { return *page.olr.Value } +// Resource an azure resource object +type Resource struct { + // ID - Azure resource Id + ID *string `json:"id,omitempty"` + // Name - Azure resource name + Name *string `json:"name,omitempty"` + // Type - Azure resource type + Type *string `json:"type,omitempty"` + // Location - Resource location + Location *string `json:"location,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if r.ID != nil { + objectMap["id"] = r.ID + } + if r.Name != nil { + objectMap["name"] = r.Name + } + if r.Type != nil { + objectMap["type"] = r.Type + } + if r.Location != nil { + objectMap["location"] = r.Location + } + if r.Tags != nil { + objectMap["tags"] = r.Tags + } + return json.Marshal(objectMap) +} + // SetObject ... type SetObject struct { autorest.Response `json:"-"` @@ -1597,46 +1632,104 @@ type WorkbookProperties struct { SourceResourceID *string `json:"sourceResourceId,omitempty"` } -// WorkbookResource an azure resource object -type WorkbookResource struct { - // ID - Azure resource Id - ID *string `json:"id,omitempty"` - // Name - Azure resource name +// WorkbookPropertiesUpdateParameters properties that contain a workbook for PATCH operation. +type WorkbookPropertiesUpdateParameters struct { + // Name - The user-defined name (display name) of the workbook. Name *string `json:"name,omitempty"` - // Type - Azure resource type - Type *string `json:"type,omitempty"` + // SerializedData - Configuration of this particular workbook. Configuration data is a string containing valid JSON + SerializedData *string `json:"serializedData,omitempty"` + // Category - Workbook category, as defined by the user at creation time. + Category *string `json:"category,omitempty"` + // Tags - A list of 0 or more tags that are associated with this workbook definition + Tags *[]string `json:"tags,omitempty"` +} + +// Workbooks workbook list result. +type Workbooks struct { + autorest.Response `json:"-"` + // Value - An array of workbooks. + Value *[]Workbook `json:"value,omitempty"` +} + +// WorkbookUpdateParameters the parameters that can be provided when updating workbook properties properties. +type WorkbookUpdateParameters struct { + // Kind - The kind of workbook. Choices are user and shared. Possible values include: 'SharedTypeKindUser', 'SharedTypeKindShared' + Kind SharedTypeKind `json:"kind,omitempty"` + // Tags - Resource tags + Tags *[]interface{} `json:"tags,omitempty"` // Location - Resource location Location *string `json:"location,omitempty"` - // Tags - Resource tags - Tags map[string]*string `json:"tags"` + // WorkbookPropertiesUpdateParameters - Metadata describing a workbook for an Azure resource. + *WorkbookPropertiesUpdateParameters `json:"properties,omitempty"` } -// MarshalJSON is the custom marshaler for WorkbookResource. -func (wr WorkbookResource) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for WorkbookUpdateParameters. +func (wup WorkbookUpdateParameters) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - if wr.ID != nil { - objectMap["id"] = wr.ID - } - if wr.Name != nil { - objectMap["name"] = wr.Name + if wup.Kind != "" { + objectMap["kind"] = wup.Kind } - if wr.Type != nil { - objectMap["type"] = wr.Type + if wup.Tags != nil { + objectMap["tags"] = wup.Tags } - if wr.Location != nil { - objectMap["location"] = wr.Location + if wup.Location != nil { + objectMap["location"] = wup.Location } - if wr.Tags != nil { - objectMap["tags"] = wr.Tags + if wup.WorkbookPropertiesUpdateParameters != nil { + objectMap["properties"] = wup.WorkbookPropertiesUpdateParameters } return json.Marshal(objectMap) } -// WorkbooksListResult workbook list result. -type WorkbooksListResult struct { - autorest.Response `json:"-"` - // Value - An array of workbooks. - Value *[]Workbook `json:"value,omitempty"` +// UnmarshalJSON is the custom unmarshaler for WorkbookUpdateParameters struct. +func (wup *WorkbookUpdateParameters) 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 "kind": + if v != nil { + var kind SharedTypeKind + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + wup.Kind = kind + } + case "tags": + if v != nil { + var tags []interface{} + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + wup.Tags = &tags + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + wup.Location = &location + } + case "properties": + if v != nil { + var workbookPropertiesUpdateParameters WorkbookPropertiesUpdateParameters + err = json.Unmarshal(*v, &workbookPropertiesUpdateParameters) + if err != nil { + return err + } + wup.WorkbookPropertiesUpdateParameters = &workbookPropertiesUpdateParameters + } + } + } + + return nil } // WorkItemConfiguration work item configuration associated with an application insights resource. diff --git a/services/appinsights/mgmt/2015-05-01/insights/workbook.go b/services/appinsights/mgmt/2015-05-01/insights/workbook.go new file mode 100644 index 000000000000..4cf6ffbe21f6 --- /dev/null +++ b/services/appinsights/mgmt/2015-05-01/insights/workbook.go @@ -0,0 +1,326 @@ +package insights + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// WorkbookClient is the composite Swagger for Application Insights Management Client +type WorkbookClient struct { + BaseClient +} + +// NewWorkbookClient creates an instance of the WorkbookClient client. +func NewWorkbookClient(subscriptionID string) WorkbookClient { + return NewWorkbookClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWorkbookClientWithBaseURI creates an instance of the WorkbookClient client. +func NewWorkbookClientWithBaseURI(baseURI string, subscriptionID string) WorkbookClient { + return WorkbookClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create a new workbook. +// Parameters: +// resourceGroupName - the name of the resource group. +// resourceName - the name of the Application Insights component resource. +// workbookProperties - properties that need to be specified to create a new workbook. +func (client WorkbookClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, workbookProperties Workbook) (result Workbook, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: workbookProperties, + Constraints: []validation.Constraint{{Target: "workbookProperties.WorkbookProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "workbookProperties.WorkbookProperties.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "workbookProperties.WorkbookProperties.SerializedData", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "workbookProperties.WorkbookProperties.WorkbookID", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "workbookProperties.WorkbookProperties.Category", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "workbookProperties.WorkbookProperties.UserID", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("insights.WorkbookClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, resourceName, workbookProperties) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WorkbookClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.WorkbookClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WorkbookClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client WorkbookClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, workbookProperties Workbook) (*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 = "2015-05-01" + 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}/resourceGroup/{resourceGroupName}/providers/microsoft.insights/workbooks/{resourceName}", pathParameters), + autorest.WithJSON(workbookProperties), + 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 WorkbookClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client WorkbookClient) CreateOrUpdateResponder(resp *http.Response) (result Workbook, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete a workbook. +// Parameters: +// resourceGroupName - the name of the resource group. +// resourceName - the name of the Application Insights component resource. +func (client WorkbookClient) Delete(ctx context.Context, resourceGroupName string, resourceName string) (result autorest.Response, err error) { + req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WorkbookClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "insights.WorkbookClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WorkbookClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client WorkbookClient) 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 = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroup/{resourceGroupName}/providers/microsoft.insights/workbooks/{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 WorkbookClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client WorkbookClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get a single workbook by its resourceName. +// Parameters: +// resourceGroupName - the name of the resource group. +// resourceName - the name of the Application Insights component resource. +func (client WorkbookClient) Get(ctx context.Context, resourceGroupName string, resourceName string) (result Workbook, err error) { + req, err := client.GetPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WorkbookClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.WorkbookClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WorkbookClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client WorkbookClient) 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 = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroup/{resourceGroupName}/providers/microsoft.insights/workbooks/{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 WorkbookClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client WorkbookClient) GetResponder(resp *http.Response) (result Workbook, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update updates a workbook that has already been added. +// Parameters: +// resourceGroupName - the name of the resource group. +// resourceName - the name of the Application Insights component resource. +// workbookUpdateParameters - properties that need to be specified to create a new workbook. +func (client WorkbookClient) Update(ctx context.Context, resourceGroupName string, resourceName string, workbookUpdateParameters WorkbookUpdateParameters) (result Workbook, err error) { + req, err := client.UpdatePreparer(ctx, resourceGroupName, resourceName, workbookUpdateParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WorkbookClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.WorkbookClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WorkbookClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client WorkbookClient) UpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, workbookUpdateParameters WorkbookUpdateParameters) (*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 = "2015-05-01" + 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}/resourceGroup/{resourceGroupName}/providers/microsoft.insights/workbooks/{resourceName}", pathParameters), + autorest.WithJSON(workbookUpdateParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client WorkbookClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client WorkbookClient) UpdateResponder(resp *http.Response) (result Workbook, 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/appinsights/mgmt/2015-05-01/insights/workbooks.go b/services/appinsights/mgmt/2015-05-01/insights/workbooks.go index 7dc771d3813d..46e4f0d82c87 100644 --- a/services/appinsights/mgmt/2015-05-01/insights/workbooks.go +++ b/services/appinsights/mgmt/2015-05-01/insights/workbooks.go @@ -21,7 +21,6 @@ import ( "context" "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" "net/http" ) @@ -40,221 +39,6 @@ func NewWorkbooksClientWithBaseURI(baseURI string, subscriptionID string) Workbo return WorkbooksClient{NewWithBaseURI(baseURI, subscriptionID)} } -// CreateOrUpdate create a new workbook. -// Parameters: -// resourceGroupName - the name of the resource group. -// resourceName - the name of the Application Insights component resource. -// workbookProperties - properties that need to be specified to create a new workbook. -func (client WorkbooksClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, workbookProperties Workbook) (result Workbook, err error) { - if err := validation.Validate([]validation.Validation{ - {TargetValue: workbookProperties, - Constraints: []validation.Constraint{{Target: "workbookProperties.WorkbookProperties", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "workbookProperties.WorkbookProperties.Name", Name: validation.Null, Rule: true, Chain: nil}, - {Target: "workbookProperties.WorkbookProperties.SerializedData", Name: validation.Null, Rule: true, Chain: nil}, - {Target: "workbookProperties.WorkbookProperties.WorkbookID", Name: validation.Null, Rule: true, Chain: nil}, - {Target: "workbookProperties.WorkbookProperties.Category", Name: validation.Null, Rule: true, Chain: nil}, - {Target: "workbookProperties.WorkbookProperties.UserID", Name: validation.Null, Rule: true, Chain: nil}, - }}}}}); err != nil { - return result, validation.NewError("insights.WorkbooksClient", "CreateOrUpdate", err.Error()) - } - - req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, resourceName, workbookProperties) - if err != nil { - err = autorest.NewErrorWithError(err, "insights.WorkbooksClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "insights.WorkbooksClient", "CreateOrUpdate", resp, "Failure sending request") - return - } - - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "insights.WorkbooksClient", "CreateOrUpdate", resp, "Failure responding to request") - } - - return -} - -// CreateOrUpdatePreparer prepares the CreateOrUpdate request. -func (client WorkbooksClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, workbookProperties Workbook) (*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 = "2015-05-01" - 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}/resourceGroup/{resourceGroupName}/providers/microsoft.insights/workbooks/{resourceName}", pathParameters), - autorest.WithJSON(workbookProperties), - 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 WorkbooksClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always -// closes the http.Response Body. -func (client WorkbooksClient) CreateOrUpdateResponder(resp *http.Response) (result Workbook, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// Delete delete a workbook. -// Parameters: -// resourceGroupName - the name of the resource group. -// resourceName - the name of the Application Insights component resource. -func (client WorkbooksClient) Delete(ctx context.Context, resourceGroupName string, resourceName string) (result autorest.Response, err error) { - req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName) - if err != nil { - err = autorest.NewErrorWithError(err, "insights.WorkbooksClient", "Delete", nil, "Failure preparing request") - return - } - - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - err = autorest.NewErrorWithError(err, "insights.WorkbooksClient", "Delete", resp, "Failure sending request") - return - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "insights.WorkbooksClient", "Delete", resp, "Failure responding to request") - } - - return -} - -// DeletePreparer prepares the Delete request. -func (client WorkbooksClient) 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 = "2015-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroup/{resourceGroupName}/providers/microsoft.insights/workbooks/{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 WorkbooksClient) DeleteSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// DeleteResponder handles the response to the Delete request. The method always -// closes the http.Response Body. -func (client WorkbooksClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - -// Get get a single workbook by its resourceName. -// Parameters: -// resourceGroupName - the name of the resource group. -// resourceName - the name of the Application Insights component resource. -func (client WorkbooksClient) Get(ctx context.Context, resourceGroupName string, resourceName string) (result Workbook, err error) { - req, err := client.GetPreparer(ctx, resourceGroupName, resourceName) - if err != nil { - err = autorest.NewErrorWithError(err, "insights.WorkbooksClient", "Get", nil, "Failure preparing request") - return - } - - resp, err := client.GetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "insights.WorkbooksClient", "Get", resp, "Failure sending request") - return - } - - result, err = client.GetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "insights.WorkbooksClient", "Get", resp, "Failure responding to request") - } - - return -} - -// GetPreparer prepares the Get request. -func (client WorkbooksClient) 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 = "2015-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroup/{resourceGroupName}/providers/microsoft.insights/workbooks/{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 WorkbooksClient) GetSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// GetResponder handles the response to the Get request. The method always -// closes the http.Response Body. -func (client WorkbooksClient) GetResponder(resp *http.Response) (result Workbook, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - // ListByResourceGroup get all Workbooks defined within a specified resource group and category. // Parameters: // resourceGroupName - the name of the resource group. @@ -262,7 +46,7 @@ func (client WorkbooksClient) GetResponder(resp *http.Response) (result Workbook // tags - tags presents on each workbook returned. // canFetchContent - flag indicating whether or not to return the full content for each applicable workbook. If // false, only return summary content for workbooks. -func (client WorkbooksClient) ListByResourceGroup(ctx context.Context, resourceGroupName string, category CategoryType, tags []string, canFetchContent *bool) (result WorkbooksListResult, err error) { +func (client WorkbooksClient) ListByResourceGroup(ctx context.Context, resourceGroupName string, category CategoryType, tags []string, canFetchContent *bool) (result Workbooks, err error) { req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName, category, tags, canFetchContent) if err != nil { err = autorest.NewErrorWithError(err, "insights.WorkbooksClient", "ListByResourceGroup", nil, "Failure preparing request") @@ -320,77 +104,7 @@ func (client WorkbooksClient) ListByResourceGroupSender(req *http.Request) (*htt // ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always // closes the http.Response Body. -func (client WorkbooksClient) ListByResourceGroupResponder(resp *http.Response) (result WorkbooksListResult, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// Update updates a workbook that has already been added. -// Parameters: -// resourceGroupName - the name of the resource group. -// resourceName - the name of the Application Insights component resource. -// workbookProperties - properties that need to be specified to create a new workbook. -func (client WorkbooksClient) Update(ctx context.Context, resourceGroupName string, resourceName string, workbookProperties Workbook) (result Workbook, err error) { - req, err := client.UpdatePreparer(ctx, resourceGroupName, resourceName, workbookProperties) - if err != nil { - err = autorest.NewErrorWithError(err, "insights.WorkbooksClient", "Update", nil, "Failure preparing request") - return - } - - resp, err := client.UpdateSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "insights.WorkbooksClient", "Update", resp, "Failure sending request") - return - } - - result, err = client.UpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "insights.WorkbooksClient", "Update", resp, "Failure responding to request") - } - - return -} - -// UpdatePreparer prepares the Update request. -func (client WorkbooksClient) UpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, workbookProperties Workbook) (*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 = "2015-05-01" - 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}/resourceGroup/{resourceGroupName}/providers/microsoft.insights/workbooks/{resourceName}", pathParameters), - autorest.WithJSON(workbookProperties), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// UpdateSender sends the Update request. The method will close the -// http.Response Body if it receives an error. -func (client WorkbooksClient) UpdateSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// UpdateResponder handles the response to the Update request. The method always -// closes the http.Response Body. -func (client WorkbooksClient) UpdateResponder(resp *http.Response) (result Workbook, err error) { +func (client WorkbooksClient) ListByResourceGroupResponder(resp *http.Response) (result Workbooks, err error) { err = autorest.Respond( resp, client.ByInspecting(), From 9c954712f3222fecb4e4cbe81995f36954c12194 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Wed, 4 Jul 2018 07:20:58 +0000 Subject: [PATCH 2/3] Generated from 1d21250cb41a0fc249ded45441e19f6a1d30a28d reverting eric changes --- .../appinsights/mgmt/insights/models.go | 13 +- .../appinsights/mgmt/insights/models.go | 13 +- .../mgmt/2015-05-01/insights/models.go | 147 ++------ .../mgmt/2015-05-01/insights/workbook.go | 326 ------------------ .../mgmt/2015-05-01/insights/workbooks.go | 290 +++++++++++++++- 5 files changed, 319 insertions(+), 470 deletions(-) delete mode 100644 services/appinsights/mgmt/2015-05-01/insights/workbook.go diff --git a/profiles/latest/appinsights/mgmt/insights/models.go b/profiles/latest/appinsights/mgmt/insights/models.go index 770b95cbf367..c06bb7af5f78 100644 --- a/profiles/latest/appinsights/mgmt/insights/models.go +++ b/profiles/latest/appinsights/mgmt/insights/models.go @@ -185,7 +185,6 @@ type OperationDisplay = original.OperationDisplay type OperationListResult = original.OperationListResult type OperationListResultIterator = original.OperationListResultIterator type OperationListResultPage = original.OperationListResultPage -type Resource = original.Resource type SetObject = original.SetObject type TagsResource = original.TagsResource type WebTest = original.WebTest @@ -199,9 +198,8 @@ type WebtestsResource = original.WebtestsResource type Workbook = original.Workbook type WorkbookError = original.WorkbookError type WorkbookProperties = original.WorkbookProperties -type WorkbookPropertiesUpdateParameters = original.WorkbookPropertiesUpdateParameters -type Workbooks = original.Workbooks -type WorkbookUpdateParameters = original.WorkbookUpdateParameters +type WorkbookResource = original.WorkbookResource +type WorkbooksListResult = original.WorkbooksListResult type WorkItemConfiguration = original.WorkItemConfiguration type WorkItemConfigurationError = original.WorkItemConfigurationError type WorkItemConfigurationsListResult = original.WorkItemConfigurationsListResult @@ -210,7 +208,6 @@ type OperationsClient = original.OperationsClient type ProactiveDetectionConfigurationsClient = original.ProactiveDetectionConfigurationsClient type WebTestLocationsClient = original.WebTestLocationsClient type WebTestsClient = original.WebTestsClient -type WorkbookClient = original.WorkbookClient type WorkbooksClient = original.WorkbooksClient type WorkItemConfigurationsClient = original.WorkItemConfigurationsClient @@ -349,12 +346,6 @@ func NewWebTestsClient(subscriptionID string) WebTestsClient { func NewWebTestsClientWithBaseURI(baseURI string, subscriptionID string) WebTestsClient { return original.NewWebTestsClientWithBaseURI(baseURI, subscriptionID) } -func NewWorkbookClient(subscriptionID string) WorkbookClient { - return original.NewWorkbookClient(subscriptionID) -} -func NewWorkbookClientWithBaseURI(baseURI string, subscriptionID string) WorkbookClient { - return original.NewWorkbookClientWithBaseURI(baseURI, subscriptionID) -} func NewWorkbooksClient(subscriptionID string) WorkbooksClient { return original.NewWorkbooksClient(subscriptionID) } diff --git a/profiles/preview/appinsights/mgmt/insights/models.go b/profiles/preview/appinsights/mgmt/insights/models.go index 2ecb03a273f9..d88d1a980050 100644 --- a/profiles/preview/appinsights/mgmt/insights/models.go +++ b/profiles/preview/appinsights/mgmt/insights/models.go @@ -185,7 +185,6 @@ type OperationDisplay = original.OperationDisplay type OperationListResult = original.OperationListResult type OperationListResultIterator = original.OperationListResultIterator type OperationListResultPage = original.OperationListResultPage -type Resource = original.Resource type SetObject = original.SetObject type TagsResource = original.TagsResource type WebTest = original.WebTest @@ -199,9 +198,8 @@ type WebtestsResource = original.WebtestsResource type Workbook = original.Workbook type WorkbookError = original.WorkbookError type WorkbookProperties = original.WorkbookProperties -type WorkbookPropertiesUpdateParameters = original.WorkbookPropertiesUpdateParameters -type Workbooks = original.Workbooks -type WorkbookUpdateParameters = original.WorkbookUpdateParameters +type WorkbookResource = original.WorkbookResource +type WorkbooksListResult = original.WorkbooksListResult type WorkItemConfiguration = original.WorkItemConfiguration type WorkItemConfigurationError = original.WorkItemConfigurationError type WorkItemConfigurationsListResult = original.WorkItemConfigurationsListResult @@ -210,7 +208,6 @@ type OperationsClient = original.OperationsClient type ProactiveDetectionConfigurationsClient = original.ProactiveDetectionConfigurationsClient type WebTestLocationsClient = original.WebTestLocationsClient type WebTestsClient = original.WebTestsClient -type WorkbookClient = original.WorkbookClient type WorkbooksClient = original.WorkbooksClient type WorkItemConfigurationsClient = original.WorkItemConfigurationsClient @@ -349,12 +346,6 @@ func NewWebTestsClient(subscriptionID string) WebTestsClient { func NewWebTestsClientWithBaseURI(baseURI string, subscriptionID string) WebTestsClient { return original.NewWebTestsClientWithBaseURI(baseURI, subscriptionID) } -func NewWorkbookClient(subscriptionID string) WorkbookClient { - return original.NewWorkbookClient(subscriptionID) -} -func NewWorkbookClientWithBaseURI(baseURI string, subscriptionID string) WorkbookClient { - return original.NewWorkbookClientWithBaseURI(baseURI, subscriptionID) -} func NewWorkbooksClient(subscriptionID string) WorkbooksClient { return original.NewWorkbooksClient(subscriptionID) } diff --git a/services/appinsights/mgmt/2015-05-01/insights/models.go b/services/appinsights/mgmt/2015-05-01/insights/models.go index a92b247cfb6d..3222af87998d 100644 --- a/services/appinsights/mgmt/2015-05-01/insights/models.go +++ b/services/appinsights/mgmt/2015-05-01/insights/models.go @@ -1117,41 +1117,6 @@ func (page OperationListResultPage) Values() []Operation { return *page.olr.Value } -// Resource an azure resource object -type Resource struct { - // ID - Azure resource Id - ID *string `json:"id,omitempty"` - // Name - Azure resource name - Name *string `json:"name,omitempty"` - // Type - Azure resource type - Type *string `json:"type,omitempty"` - // Location - Resource location - Location *string `json:"location,omitempty"` - // Tags - Resource tags - Tags map[string]*string `json:"tags"` -} - -// MarshalJSON is the custom marshaler for Resource. -func (r Resource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if r.ID != nil { - objectMap["id"] = r.ID - } - if r.Name != nil { - objectMap["name"] = r.Name - } - if r.Type != nil { - objectMap["type"] = r.Type - } - if r.Location != nil { - objectMap["location"] = r.Location - } - if r.Tags != nil { - objectMap["tags"] = r.Tags - } - return json.Marshal(objectMap) -} - // SetObject ... type SetObject struct { autorest.Response `json:"-"` @@ -1632,104 +1597,46 @@ type WorkbookProperties struct { SourceResourceID *string `json:"sourceResourceId,omitempty"` } -// WorkbookPropertiesUpdateParameters properties that contain a workbook for PATCH operation. -type WorkbookPropertiesUpdateParameters struct { - // Name - The user-defined name (display name) of the workbook. +// WorkbookResource an azure resource object +type WorkbookResource struct { + // ID - Azure resource Id + ID *string `json:"id,omitempty"` + // Name - Azure resource name Name *string `json:"name,omitempty"` - // SerializedData - Configuration of this particular workbook. Configuration data is a string containing valid JSON - SerializedData *string `json:"serializedData,omitempty"` - // Category - Workbook category, as defined by the user at creation time. - Category *string `json:"category,omitempty"` - // Tags - A list of 0 or more tags that are associated with this workbook definition - Tags *[]string `json:"tags,omitempty"` -} - -// Workbooks workbook list result. -type Workbooks struct { - autorest.Response `json:"-"` - // Value - An array of workbooks. - Value *[]Workbook `json:"value,omitempty"` -} - -// WorkbookUpdateParameters the parameters that can be provided when updating workbook properties properties. -type WorkbookUpdateParameters struct { - // Kind - The kind of workbook. Choices are user and shared. Possible values include: 'SharedTypeKindUser', 'SharedTypeKindShared' - Kind SharedTypeKind `json:"kind,omitempty"` - // Tags - Resource tags - Tags *[]interface{} `json:"tags,omitempty"` + // Type - Azure resource type + Type *string `json:"type,omitempty"` // Location - Resource location Location *string `json:"location,omitempty"` - // WorkbookPropertiesUpdateParameters - Metadata describing a workbook for an Azure resource. - *WorkbookPropertiesUpdateParameters `json:"properties,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` } -// MarshalJSON is the custom marshaler for WorkbookUpdateParameters. -func (wup WorkbookUpdateParameters) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for WorkbookResource. +func (wr WorkbookResource) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - if wup.Kind != "" { - objectMap["kind"] = wup.Kind + if wr.ID != nil { + objectMap["id"] = wr.ID + } + if wr.Name != nil { + objectMap["name"] = wr.Name } - if wup.Tags != nil { - objectMap["tags"] = wup.Tags + if wr.Type != nil { + objectMap["type"] = wr.Type } - if wup.Location != nil { - objectMap["location"] = wup.Location + if wr.Location != nil { + objectMap["location"] = wr.Location } - if wup.WorkbookPropertiesUpdateParameters != nil { - objectMap["properties"] = wup.WorkbookPropertiesUpdateParameters + if wr.Tags != nil { + objectMap["tags"] = wr.Tags } return json.Marshal(objectMap) } -// UnmarshalJSON is the custom unmarshaler for WorkbookUpdateParameters struct. -func (wup *WorkbookUpdateParameters) 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 "kind": - if v != nil { - var kind SharedTypeKind - err = json.Unmarshal(*v, &kind) - if err != nil { - return err - } - wup.Kind = kind - } - case "tags": - if v != nil { - var tags []interface{} - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - wup.Tags = &tags - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - wup.Location = &location - } - case "properties": - if v != nil { - var workbookPropertiesUpdateParameters WorkbookPropertiesUpdateParameters - err = json.Unmarshal(*v, &workbookPropertiesUpdateParameters) - if err != nil { - return err - } - wup.WorkbookPropertiesUpdateParameters = &workbookPropertiesUpdateParameters - } - } - } - - return nil +// WorkbooksListResult workbook list result. +type WorkbooksListResult struct { + autorest.Response `json:"-"` + // Value - An array of workbooks. + Value *[]Workbook `json:"value,omitempty"` } // WorkItemConfiguration work item configuration associated with an application insights resource. diff --git a/services/appinsights/mgmt/2015-05-01/insights/workbook.go b/services/appinsights/mgmt/2015-05-01/insights/workbook.go deleted file mode 100644 index 4cf6ffbe21f6..000000000000 --- a/services/appinsights/mgmt/2015-05-01/insights/workbook.go +++ /dev/null @@ -1,326 +0,0 @@ -package insights - -// Copyright (c) Microsoft and contributors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "net/http" -) - -// WorkbookClient is the composite Swagger for Application Insights Management Client -type WorkbookClient struct { - BaseClient -} - -// NewWorkbookClient creates an instance of the WorkbookClient client. -func NewWorkbookClient(subscriptionID string) WorkbookClient { - return NewWorkbookClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewWorkbookClientWithBaseURI creates an instance of the WorkbookClient client. -func NewWorkbookClientWithBaseURI(baseURI string, subscriptionID string) WorkbookClient { - return WorkbookClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// CreateOrUpdate create a new workbook. -// Parameters: -// resourceGroupName - the name of the resource group. -// resourceName - the name of the Application Insights component resource. -// workbookProperties - properties that need to be specified to create a new workbook. -func (client WorkbookClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, workbookProperties Workbook) (result Workbook, err error) { - if err := validation.Validate([]validation.Validation{ - {TargetValue: workbookProperties, - Constraints: []validation.Constraint{{Target: "workbookProperties.WorkbookProperties", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "workbookProperties.WorkbookProperties.Name", Name: validation.Null, Rule: true, Chain: nil}, - {Target: "workbookProperties.WorkbookProperties.SerializedData", Name: validation.Null, Rule: true, Chain: nil}, - {Target: "workbookProperties.WorkbookProperties.WorkbookID", Name: validation.Null, Rule: true, Chain: nil}, - {Target: "workbookProperties.WorkbookProperties.Category", Name: validation.Null, Rule: true, Chain: nil}, - {Target: "workbookProperties.WorkbookProperties.UserID", Name: validation.Null, Rule: true, Chain: nil}, - }}}}}); err != nil { - return result, validation.NewError("insights.WorkbookClient", "CreateOrUpdate", err.Error()) - } - - req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, resourceName, workbookProperties) - if err != nil { - err = autorest.NewErrorWithError(err, "insights.WorkbookClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "insights.WorkbookClient", "CreateOrUpdate", resp, "Failure sending request") - return - } - - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "insights.WorkbookClient", "CreateOrUpdate", resp, "Failure responding to request") - } - - return -} - -// CreateOrUpdatePreparer prepares the CreateOrUpdate request. -func (client WorkbookClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, workbookProperties Workbook) (*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 = "2015-05-01" - 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}/resourceGroup/{resourceGroupName}/providers/microsoft.insights/workbooks/{resourceName}", pathParameters), - autorest.WithJSON(workbookProperties), - 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 WorkbookClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always -// closes the http.Response Body. -func (client WorkbookClient) CreateOrUpdateResponder(resp *http.Response) (result Workbook, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// Delete delete a workbook. -// Parameters: -// resourceGroupName - the name of the resource group. -// resourceName - the name of the Application Insights component resource. -func (client WorkbookClient) Delete(ctx context.Context, resourceGroupName string, resourceName string) (result autorest.Response, err error) { - req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName) - if err != nil { - err = autorest.NewErrorWithError(err, "insights.WorkbookClient", "Delete", nil, "Failure preparing request") - return - } - - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - err = autorest.NewErrorWithError(err, "insights.WorkbookClient", "Delete", resp, "Failure sending request") - return - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "insights.WorkbookClient", "Delete", resp, "Failure responding to request") - } - - return -} - -// DeletePreparer prepares the Delete request. -func (client WorkbookClient) 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 = "2015-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroup/{resourceGroupName}/providers/microsoft.insights/workbooks/{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 WorkbookClient) DeleteSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// DeleteResponder handles the response to the Delete request. The method always -// closes the http.Response Body. -func (client WorkbookClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - -// Get get a single workbook by its resourceName. -// Parameters: -// resourceGroupName - the name of the resource group. -// resourceName - the name of the Application Insights component resource. -func (client WorkbookClient) Get(ctx context.Context, resourceGroupName string, resourceName string) (result Workbook, err error) { - req, err := client.GetPreparer(ctx, resourceGroupName, resourceName) - if err != nil { - err = autorest.NewErrorWithError(err, "insights.WorkbookClient", "Get", nil, "Failure preparing request") - return - } - - resp, err := client.GetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "insights.WorkbookClient", "Get", resp, "Failure sending request") - return - } - - result, err = client.GetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "insights.WorkbookClient", "Get", resp, "Failure responding to request") - } - - return -} - -// GetPreparer prepares the Get request. -func (client WorkbookClient) 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 = "2015-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroup/{resourceGroupName}/providers/microsoft.insights/workbooks/{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 WorkbookClient) GetSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// GetResponder handles the response to the Get request. The method always -// closes the http.Response Body. -func (client WorkbookClient) GetResponder(resp *http.Response) (result Workbook, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// Update updates a workbook that has already been added. -// Parameters: -// resourceGroupName - the name of the resource group. -// resourceName - the name of the Application Insights component resource. -// workbookUpdateParameters - properties that need to be specified to create a new workbook. -func (client WorkbookClient) Update(ctx context.Context, resourceGroupName string, resourceName string, workbookUpdateParameters WorkbookUpdateParameters) (result Workbook, err error) { - req, err := client.UpdatePreparer(ctx, resourceGroupName, resourceName, workbookUpdateParameters) - if err != nil { - err = autorest.NewErrorWithError(err, "insights.WorkbookClient", "Update", nil, "Failure preparing request") - return - } - - resp, err := client.UpdateSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "insights.WorkbookClient", "Update", resp, "Failure sending request") - return - } - - result, err = client.UpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "insights.WorkbookClient", "Update", resp, "Failure responding to request") - } - - return -} - -// UpdatePreparer prepares the Update request. -func (client WorkbookClient) UpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, workbookUpdateParameters WorkbookUpdateParameters) (*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 = "2015-05-01" - 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}/resourceGroup/{resourceGroupName}/providers/microsoft.insights/workbooks/{resourceName}", pathParameters), - autorest.WithJSON(workbookUpdateParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// UpdateSender sends the Update request. The method will close the -// http.Response Body if it receives an error. -func (client WorkbookClient) UpdateSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// UpdateResponder handles the response to the Update request. The method always -// closes the http.Response Body. -func (client WorkbookClient) UpdateResponder(resp *http.Response) (result Workbook, 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/appinsights/mgmt/2015-05-01/insights/workbooks.go b/services/appinsights/mgmt/2015-05-01/insights/workbooks.go index 46e4f0d82c87..7dc771d3813d 100644 --- a/services/appinsights/mgmt/2015-05-01/insights/workbooks.go +++ b/services/appinsights/mgmt/2015-05-01/insights/workbooks.go @@ -21,6 +21,7 @@ import ( "context" "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" "net/http" ) @@ -39,6 +40,221 @@ func NewWorkbooksClientWithBaseURI(baseURI string, subscriptionID string) Workbo return WorkbooksClient{NewWithBaseURI(baseURI, subscriptionID)} } +// CreateOrUpdate create a new workbook. +// Parameters: +// resourceGroupName - the name of the resource group. +// resourceName - the name of the Application Insights component resource. +// workbookProperties - properties that need to be specified to create a new workbook. +func (client WorkbooksClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, workbookProperties Workbook) (result Workbook, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: workbookProperties, + Constraints: []validation.Constraint{{Target: "workbookProperties.WorkbookProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "workbookProperties.WorkbookProperties.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "workbookProperties.WorkbookProperties.SerializedData", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "workbookProperties.WorkbookProperties.WorkbookID", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "workbookProperties.WorkbookProperties.Category", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "workbookProperties.WorkbookProperties.UserID", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("insights.WorkbooksClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, resourceName, workbookProperties) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WorkbooksClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.WorkbooksClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WorkbooksClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client WorkbooksClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, workbookProperties Workbook) (*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 = "2015-05-01" + 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}/resourceGroup/{resourceGroupName}/providers/microsoft.insights/workbooks/{resourceName}", pathParameters), + autorest.WithJSON(workbookProperties), + 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 WorkbooksClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client WorkbooksClient) CreateOrUpdateResponder(resp *http.Response) (result Workbook, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete a workbook. +// Parameters: +// resourceGroupName - the name of the resource group. +// resourceName - the name of the Application Insights component resource. +func (client WorkbooksClient) Delete(ctx context.Context, resourceGroupName string, resourceName string) (result autorest.Response, err error) { + req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WorkbooksClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "insights.WorkbooksClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WorkbooksClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client WorkbooksClient) 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 = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroup/{resourceGroupName}/providers/microsoft.insights/workbooks/{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 WorkbooksClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client WorkbooksClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get a single workbook by its resourceName. +// Parameters: +// resourceGroupName - the name of the resource group. +// resourceName - the name of the Application Insights component resource. +func (client WorkbooksClient) Get(ctx context.Context, resourceGroupName string, resourceName string) (result Workbook, err error) { + req, err := client.GetPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WorkbooksClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.WorkbooksClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WorkbooksClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client WorkbooksClient) 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 = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroup/{resourceGroupName}/providers/microsoft.insights/workbooks/{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 WorkbooksClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client WorkbooksClient) GetResponder(resp *http.Response) (result Workbook, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + // ListByResourceGroup get all Workbooks defined within a specified resource group and category. // Parameters: // resourceGroupName - the name of the resource group. @@ -46,7 +262,7 @@ func NewWorkbooksClientWithBaseURI(baseURI string, subscriptionID string) Workbo // tags - tags presents on each workbook returned. // canFetchContent - flag indicating whether or not to return the full content for each applicable workbook. If // false, only return summary content for workbooks. -func (client WorkbooksClient) ListByResourceGroup(ctx context.Context, resourceGroupName string, category CategoryType, tags []string, canFetchContent *bool) (result Workbooks, err error) { +func (client WorkbooksClient) ListByResourceGroup(ctx context.Context, resourceGroupName string, category CategoryType, tags []string, canFetchContent *bool) (result WorkbooksListResult, err error) { req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName, category, tags, canFetchContent) if err != nil { err = autorest.NewErrorWithError(err, "insights.WorkbooksClient", "ListByResourceGroup", nil, "Failure preparing request") @@ -104,7 +320,77 @@ func (client WorkbooksClient) ListByResourceGroupSender(req *http.Request) (*htt // ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always // closes the http.Response Body. -func (client WorkbooksClient) ListByResourceGroupResponder(resp *http.Response) (result Workbooks, err error) { +func (client WorkbooksClient) ListByResourceGroupResponder(resp *http.Response) (result WorkbooksListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update updates a workbook that has already been added. +// Parameters: +// resourceGroupName - the name of the resource group. +// resourceName - the name of the Application Insights component resource. +// workbookProperties - properties that need to be specified to create a new workbook. +func (client WorkbooksClient) Update(ctx context.Context, resourceGroupName string, resourceName string, workbookProperties Workbook) (result Workbook, err error) { + req, err := client.UpdatePreparer(ctx, resourceGroupName, resourceName, workbookProperties) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WorkbooksClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.WorkbooksClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WorkbooksClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client WorkbooksClient) UpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, workbookProperties Workbook) (*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 = "2015-05-01" + 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}/resourceGroup/{resourceGroupName}/providers/microsoft.insights/workbooks/{resourceName}", pathParameters), + autorest.WithJSON(workbookProperties), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client WorkbooksClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client WorkbooksClient) UpdateResponder(resp *http.Response) (result Workbook, err error) { err = autorest.Respond( resp, client.ByInspecting(), From 88c79b628a7b5350d2e08ba03b06e3b3347cc122 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Tue, 31 Jul 2018 18:12:45 +0000 Subject: [PATCH 3/3] Generated from 1d21250cb41a0fc249ded45441e19f6a1d30a28d reverting eric changes --- Gopkg.lock | 101 ++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 92 insertions(+), 9 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index 57f00c99bda5..746f776b4d9e 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -2,6 +2,7 @@ [[projects]] + digest = "1:a395127e39ea4973e9d3b78017014384d650efa5ae785c47885bfb3cf2f9651a" name = "github.com/Azure/go-autorest" packages = [ "autorest", @@ -10,52 +11,64 @@ "autorest/azure/auth", "autorest/date", "autorest/to", - "autorest/validation" + "autorest/validation", ] + pruneopts = "" revision = "e6d2a85bbb5cd2a3162e4942594e1e520e442b0b" version = "v10.11.4" [[projects]] + digest = "1:6098222470fe0172157ce9bbef5d2200df4edde17ee649c5d6e48330e4afa4c6" name = "github.com/dgrijalva/jwt-go" packages = ["."] + pruneopts = "" revision = "06ea1031745cb8b3dab3f6a236daf2b0aa468b7e" version = "v3.2.0" [[projects]] branch = "master" + digest = "1:654ac9799e7a8a586d8690bb2229a4f3408bbfe2c5494bf4dfe043053eeb5496" name = "github.com/dimchansky/utfbom" packages = ["."] + pruneopts = "" revision = "6c6132ff69f0f6c088739067407b5d32c52e1d0f" [[projects]] branch = "master" + digest = "1:b2d7ddf0e7f09e6468da25f27d3a17812e150345cd790da5578b05fcf92d2f31" name = "github.com/dnaeon/go-vcr" packages = [ "cassette", - "recorder" + "recorder", ] + pruneopts = "" revision = "f8a7e8b9c630b486df74145bb887793a1b85459b" [[projects]] + digest = "1:eb53021a8aa3f599d29c7102e65026242bdedce998a54837dc67f14b6a97c5fd" name = "github.com/fsnotify/fsnotify" packages = ["."] + pruneopts = "" revision = "c2828203cd70a50dcccfb2761f8b1f8ceef9a8e9" version = "v1.4.7" [[projects]] branch = "master" + digest = "1:d9cf334ee84f60ea8855a530f09ce9d7b81880ca35bb76b255b5d72ceb11f8bb" name = "github.com/globalsign/mgo" packages = [ ".", "bson", "internal/json", "internal/sasl", - "internal/scram" + "internal/scram", ] + pruneopts = "" revision = "efe0945164a7e582241f37ae8983c075f8f2e870" [[projects]] branch = "master" + digest = "1:9b7c5846d70f425d7fe279595e32a20994c6075e87be03b5c367ed07280877c5" name = "github.com/hashicorp/hcl" packages = [ ".", @@ -67,131 +80,171 @@ "hcl/token", "json/parser", "json/scanner", - "json/token" + "json/token", ] + pruneopts = "" revision = "ef8a98b0bbce4a65b5aa4c368430a80ddc533168" [[projects]] + digest = "1:870d441fe217b8e689d7949fef6e43efbc787e50f200cb1e70dbca9204a1d6be" name = "github.com/inconshreveable/mousetrap" packages = ["."] + pruneopts = "" revision = "76626ae9c91c4f2a10f34cad8ce83ea42c93bb75" version = "v1.0" [[projects]] + digest = "1:961dc3b1d11f969370533390fdf203813162980c858e1dabe827b60940c909a5" name = "github.com/magiconair/properties" packages = ["."] + pruneopts = "" revision = "c2353362d570a7bfa228149c62842019201cfb71" version = "v1.8.0" [[projects]] + digest = "1:71a28fe7d86ace8e51192c97eb4fd376c27ae0ed3a6ff46b41a6da76a0785d78" name = "github.com/marstr/collection" packages = ["."] + pruneopts = "" revision = "871b1cfa2ab97d3d8f54a034280907896190c346" version = "v0.3.3" [[projects]] branch = "master" + digest = "1:5a07891ac7651f2b0db3ca615f88ca80e38a41c0c9f60a6fb123b8cbe3d8d386" name = "github.com/marstr/goalias" packages = ["model"] + pruneopts = "" revision = "8dff9a14db648bfdd58d45515d3eaaee23aad078" [[projects]] + digest = "1:f95025d583786875a71183888acc9d0987fc96f12d4f5afab3d7558797ea1c5a" name = "github.com/marstr/guid" packages = ["."] + pruneopts = "" revision = "8bd9a64bf37eb297b492a4101fb28e80ac0b290f" version = "v1.1.0" [[projects]] branch = "master" + digest = "1:9b1c51ad4f41e364bee3c3281267a73c783711018edd0fd8104268f8782352ad" name = "github.com/marstr/randname" packages = ["."] + pruneopts = "" revision = "3ef1f47af99e66171417047e6f6fa334345e95e7" [[projects]] branch = "master" + digest = "1:99651e95333755cbe5c9768c1b80031300acca64a80870b40309202b32585a5a" name = "github.com/mitchellh/go-homedir" packages = ["."] + pruneopts = "" revision = "3864e76763d94a6df2f9960b16a20a33da9f9a66" [[projects]] branch = "master" + digest = "1:eb9117392ee8e7aa44f78e0db603f70b1050ee0ebda4bd40040befb5b218c546" name = "github.com/mitchellh/mapstructure" packages = ["."] + pruneopts = "" revision = "bb74f1db0675b241733089d5a1faa5dd8b0ef57b" [[projects]] + digest = "1:d60cfeee185019d4fcd35e8c89c83aff576e4723b6100300bf67b05be961388f" name = "github.com/pelletier/go-toml" packages = ["."] + pruneopts = "" revision = "acdc4509485b587f5e675510c4f2c63e90ff68a8" version = "v1.1.0" [[projects]] + digest = "1:7f569d906bdd20d906b606415b7d794f798f91a62fcfb6a4daa6d50690fb7a3f" name = "github.com/satori/go.uuid" packages = ["."] + pruneopts = "" revision = "f58768cc1a7a7e77a3bd49e98cdd21419399b6a3" version = "v1.2.0" [[projects]] + digest = "1:69240630f5a4a6f16a7d6111884e206b0c5b0a233c9ee5fe54956f06c2fd6ac0" name = "github.com/shopspring/decimal" packages = ["."] + pruneopts = "" revision = "69b3a8ad1f5f2c8bd855cb6506d18593064a346b" version = "1.0.1" [[projects]] + digest = "1:d3e2e29bc7342053edc85e1ad751275694a96d58516f749cf3413db1a0eca2ba" name = "github.com/spf13/afero" packages = [ ".", - "mem" + "mem", ] + pruneopts = "" revision = "63644898a8da0bc22138abf860edaf5277b6102e" version = "v1.1.0" [[projects]] + digest = "1:d0b38ba6da419a6d4380700218eeec8623841d44a856bb57369c172fbf692ab4" name = "github.com/spf13/cast" packages = ["."] + pruneopts = "" revision = "8965335b8c7107321228e3e3702cab9832751bac" version = "v1.2.0" [[projects]] + digest = "1:a1403cc8a94b8d7956ee5e9694badef0e7b051af289caad1cf668331e3ffa4f6" name = "github.com/spf13/cobra" packages = ["."] + pruneopts = "" revision = "ef82de70bb3f60c65fb8eebacbb2d122ef517385" version = "v0.0.3" [[projects]] branch = "master" + digest = "1:104517520aab91164020ab6524a5d6b7cafc641b2e42ac6236f6ac1deac4f66a" name = "github.com/spf13/jwalterweatherman" packages = ["."] + pruneopts = "" revision = "7c0cea34c8ece3fbeb2b27ab9b59511d360fb394" [[projects]] + digest = "1:8e243c568f36b09031ec18dff5f7d2769dcf5ca4d624ea511c8e3197dc3d352d" name = "github.com/spf13/pflag" packages = ["."] + pruneopts = "" revision = "583c0c0531f06d5278b7d917446061adc344b5cd" version = "v1.0.1" [[projects]] + digest = "1:3dab237cd3263a290d771d133fed777bb56c22e380b00ebe92e6531d5c8d3d0c" name = "github.com/spf13/viper" packages = ["."] + pruneopts = "" revision = "b5e8006cbee93ec955a89ab31e0e3ce3204f3736" version = "v1.0.2" [[projects]] branch = "master" + digest = "1:e3df40bd62d81f343751b61516cc96a74c8b2a5f4581c9a1a290439816b6f13b" name = "golang.org/x/crypto" packages = [ "pkcs12", - "pkcs12/internal/rc2" + "pkcs12/internal/rc2", ] + pruneopts = "" revision = "5ba7f63082460102a45837dbd1827e10f9479ac0" [[projects]] branch = "master" + digest = "1:bc468e6f6fb109d22b8aa37b1eb9f8e705ebdbe7f462034cfcb72ac73e41b375" name = "golang.org/x/sys" packages = ["unix"] + pruneopts = "" revision = "c11f84a56e43e20a78cee75a7c034031ecf57d1f" [[projects]] + digest = "1:5acd3512b047305d49e8763eef7ba423901e85d5dd2fd1e71778a0ea8de10bd4" name = "golang.org/x/text" packages = [ "internal/gen", @@ -199,36 +252,66 @@ "internal/ucd", "transform", "unicode/cldr", - "unicode/norm" + "unicode/norm", ] + pruneopts = "" revision = "f21a4dfb5e38f5895301dc265a8def02365cc3d0" version = "v0.3.0" [[projects]] branch = "master" + digest = "1:17418952b3f7a2335f7481086d69dc2e5f4dccaa20da6059c18e565f90a0ea6d" name = "golang.org/x/tools" packages = [ "go/ast/astutil", "imports", - "internal/fastwalk" + "internal/fastwalk", ] + pruneopts = "" revision = "a5b4c53f6e8bdcafa95a94671bf2d1203365858b" [[projects]] branch = "v1" + digest = "1:e75566abfb876e81f00290ec153ff994c33bf8886134c1a38a9a9df5c15a2045" name = "gopkg.in/check.v1" packages = ["."] + pruneopts = "" revision = "20d25e2804050c1cd24a7eea1e7a6447dd0e74ec" [[projects]] + digest = "1:f0620375dd1f6251d9973b5f2596228cc8042e887cd7f827e4220bc1ce8c30e2" name = "gopkg.in/yaml.v2" packages = ["."] + pruneopts = "" revision = "5420a8b6744d3b0345ab293f6fcba19c978f1183" version = "v2.2.1" [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "dc109e138913d643d967a53721fe7cd9f742fbd626c39ed53a5fbfa5307b826c" + input-imports = [ + "github.com/Azure/go-autorest/autorest", + "github.com/Azure/go-autorest/autorest/adal", + "github.com/Azure/go-autorest/autorest/azure", + "github.com/Azure/go-autorest/autorest/azure/auth", + "github.com/Azure/go-autorest/autorest/date", + "github.com/Azure/go-autorest/autorest/to", + "github.com/Azure/go-autorest/autorest/validation", + "github.com/dnaeon/go-vcr/cassette", + "github.com/dnaeon/go-vcr/recorder", + "github.com/globalsign/mgo", + "github.com/marstr/collection", + "github.com/marstr/goalias/model", + "github.com/marstr/guid", + "github.com/marstr/randname", + "github.com/mitchellh/go-homedir", + "github.com/satori/go.uuid", + "github.com/shopspring/decimal", + "github.com/spf13/cobra", + "github.com/spf13/viper", + "golang.org/x/crypto/pkcs12", + "golang.org/x/tools/imports", + "gopkg.in/check.v1", + ] solver-name = "gps-cdcl" solver-version = 1