diff --git a/services/appinsights/mgmt/2015-05-01/insights/insightsapi/interfaces.go b/services/appinsights/mgmt/2015-05-01/insights/insightsapi/interfaces.go index 1d64b841dc37..0a6aeda597ca 100644 --- a/services/appinsights/mgmt/2015-05-01/insights/insightsapi/interfaces.go +++ b/services/appinsights/mgmt/2015-05-01/insights/insightsapi/interfaces.go @@ -182,3 +182,15 @@ type WorkbooksClientAPI interface { } var _ WorkbooksClientAPI = (*insights.WorkbooksClient)(nil) + +// MyWorkbooksClientAPI contains the set of methods on the MyWorkbooksClient type. +type MyWorkbooksClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, workbookProperties insights.MyWorkbook) (result insights.MyWorkbook, err error) + Delete(ctx context.Context, resourceGroupName string, resourceName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, resourceName string) (result insights.MyWorkbook, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string, category insights.CategoryType, tags []string, canFetchContent *bool) (result insights.MyWorkbooksListResult, err error) + ListBySubscription(ctx context.Context, category insights.CategoryType, tags []string, canFetchContent *bool) (result insights.MyWorkbooksListResult, err error) + Update(ctx context.Context, resourceGroupName string, resourceName string, workbookProperties insights.MyWorkbook) (result insights.MyWorkbook, err error) +} + +var _ MyWorkbooksClientAPI = (*insights.MyWorkbooksClient)(nil) diff --git a/services/appinsights/mgmt/2015-05-01/insights/models.go b/services/appinsights/mgmt/2015-05-01/insights/models.go index beb562667a1a..ae221dc2ce2a 100644 --- a/services/appinsights/mgmt/2015-05-01/insights/models.go +++ b/services/appinsights/mgmt/2015-05-01/insights/models.go @@ -187,8 +187,8 @@ func (aic *ApplicationInsightsComponent) UnmarshalJSON(body []byte) error { return nil } -// ApplicationInsightsComponentAnalyticsItem properties that define an Analytics item that is associated to an -// Application Insights component. +// ApplicationInsightsComponentAnalyticsItem properties that define an Analytics item that is associated to +// an Application Insights component. type ApplicationInsightsComponentAnalyticsItem struct { autorest.Response `json:"-"` // ID - Internally assigned unique id of the item definition. @@ -234,14 +234,15 @@ func (aicai ApplicationInsightsComponentAnalyticsItem) MarshalJSON() ([]byte, er return json.Marshal(objectMap) } -// ApplicationInsightsComponentAnalyticsItemProperties a set of properties that can be defined in the context -// of a specific item type. Each type may have its own properties. +// ApplicationInsightsComponentAnalyticsItemProperties a set of properties that can be defined in the +// context of a specific item type. Each type may have its own properties. type ApplicationInsightsComponentAnalyticsItemProperties struct { // FunctionAlias - A function alias, used when the type of the item is Function FunctionAlias *string `json:"functionAlias,omitempty"` } -// ApplicationInsightsComponentAPIKey properties that define an API key of an Application Insights Component. +// ApplicationInsightsComponentAPIKey properties that define an API key of an Application Insights +// Component. type ApplicationInsightsComponentAPIKey struct { autorest.Response `json:"-"` // ID - READ-ONLY; The unique ID of the API key inside an Application Insights component. It is auto generated when the API key is created. @@ -334,7 +335,8 @@ func (aicdvc ApplicationInsightsComponentDataVolumeCap) MarshalJSON() ([]byte, e return json.Marshal(objectMap) } -// ApplicationInsightsComponentExportConfiguration properties that define a Continuous Export configuration. +// ApplicationInsightsComponentExportConfiguration properties that define a Continuous Export +// configuration. type ApplicationInsightsComponentExportConfiguration struct { autorest.Response `json:"-"` // ExportID - READ-ONLY; The unique ID of the export configuration inside an Application Insights component. It is auto generated when the Continuous Export configuration is created. @@ -389,8 +391,8 @@ func (aicec ApplicationInsightsComponentExportConfiguration) MarshalJSON() ([]by return json.Marshal(objectMap) } -// ApplicationInsightsComponentExportRequest an Application Insights component Continuous Export configuration -// request definition. +// ApplicationInsightsComponentExportRequest an Application Insights component Continuous Export +// configuration request definition. type ApplicationInsightsComponentExportRequest struct { // RecordTypes - The document types to be exported, as comma separated values. Allowed values include 'Requests', 'Event', 'Exceptions', 'Metrics', 'PageViews', 'PageViewPerformance', 'Rdd', 'PerformanceCounters', 'Availability', 'Messages'. RecordTypes *string `json:"RecordTypes,omitempty"` @@ -412,8 +414,8 @@ type ApplicationInsightsComponentExportRequest struct { DestinationAccountID *string `json:"DestinationAccountId,omitempty"` } -// ApplicationInsightsComponentFavorite properties that define a favorite that is associated to an Application -// Insights component. +// ApplicationInsightsComponentFavorite properties that define a favorite that is associated to an +// Application Insights component. type ApplicationInsightsComponentFavorite struct { autorest.Response `json:"-"` // Name - The user-defined name of the favorite. @@ -698,8 +700,11 @@ func (page ApplicationInsightsComponentListResultPage) Values() []ApplicationIns } // Creates a new instance of the ApplicationInsightsComponentListResultPage type. -func NewApplicationInsightsComponentListResultPage(getNextPage func(context.Context, ApplicationInsightsComponentListResult) (ApplicationInsightsComponentListResult, error)) ApplicationInsightsComponentListResultPage { - return ApplicationInsightsComponentListResultPage{fn: getNextPage} +func NewApplicationInsightsComponentListResultPage(cur ApplicationInsightsComponentListResult, getNextPage func(context.Context, ApplicationInsightsComponentListResult) (ApplicationInsightsComponentListResult, error)) ApplicationInsightsComponentListResultPage { + return ApplicationInsightsComponentListResultPage{ + fn: getNextPage, + aiclr: cur, + } } // ApplicationInsightsComponentProactiveDetectionConfiguration properties that define a ProactiveDetection @@ -741,7 +746,8 @@ type ApplicationInsightsComponentProactiveDetectionConfigurationRuleDefinitions SupportsEmailNotifications *bool `json:"SupportsEmailNotifications,omitempty"` } -// ApplicationInsightsComponentProperties properties that define an Application Insights component resource. +// ApplicationInsightsComponentProperties properties that define an Application Insights component +// resource. type ApplicationInsightsComponentProperties struct { // ApplicationID - READ-ONLY; The unique ID of your application. This field mirrors the 'Name' field and cannot be changed. ApplicationID *string `json:"ApplicationId,omitempty"` @@ -969,6 +975,226 @@ type ListApplicationInsightsComponentProactiveDetectionConfiguration struct { Value *[]ApplicationInsightsComponentProactiveDetectionConfiguration `json:"value,omitempty"` } +// MyWorkbook an Application Insights private workbook definition. +type MyWorkbook struct { + autorest.Response `json:"-"` + // Kind - The kind of workbook. Choices are user and shared. Possible values include: 'SharedTypeKindUser', 'SharedTypeKindShared' + Kind SharedTypeKind `json:"kind,omitempty"` + // MyWorkbookProperties - Metadata describing a workbook for an Azure resource. + *MyWorkbookProperties `json:"properties,omitempty"` + // 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 MyWorkbook. +func (mw MyWorkbook) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mw.Kind != "" { + objectMap["kind"] = mw.Kind + } + if mw.MyWorkbookProperties != nil { + objectMap["properties"] = mw.MyWorkbookProperties + } + if mw.ID != nil { + objectMap["id"] = mw.ID + } + if mw.Name != nil { + objectMap["name"] = mw.Name + } + if mw.Type != nil { + objectMap["type"] = mw.Type + } + if mw.Location != nil { + objectMap["location"] = mw.Location + } + if mw.Tags != nil { + objectMap["tags"] = mw.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for MyWorkbook struct. +func (mw *MyWorkbook) 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 + } + mw.Kind = kind + } + case "properties": + if v != nil { + var myWorkbookProperties MyWorkbookProperties + err = json.Unmarshal(*v, &myWorkbookProperties) + if err != nil { + return err + } + mw.MyWorkbookProperties = &myWorkbookProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + mw.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mw.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + mw.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + mw.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + mw.Tags = tags + } + } + } + + return nil +} + +// MyWorkbookError error message body that will indicate why the operation failed. +type MyWorkbookError 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"` + // Details - The list of invalid fields send in request, in case of validation error. + Details *[]ErrorFieldContract `json:"details,omitempty"` +} + +// MyWorkbookProperties properties that contain a private workbook. +type MyWorkbookProperties struct { + // DisplayName - The user-defined name of the private workbook. + DisplayName *string `json:"displayName,omitempty"` + // SerializedData - Configuration of this particular private workbook. Configuration data is a string containing valid JSON + SerializedData *string `json:"serializedData,omitempty"` + // Version - This instance's version of the data model. This can change as new features are added that can be marked private workbook. + Version *string `json:"version,omitempty"` + // TimeModified - READ-ONLY; Date and time in UTC of the last modification that was made to this private workbook definition. + TimeModified *string `json:"timeModified,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 private workbook definition + Tags *[]string `json:"tags,omitempty"` + // UserID - READ-ONLY; Unique user id of the specific user that owns this private workbook. + UserID *string `json:"userId,omitempty"` + // SourceID - Optional resourceId for a source resource. + SourceID *string `json:"sourceId,omitempty"` +} + +// MarshalJSON is the custom marshaler for MyWorkbookProperties. +func (mwp MyWorkbookProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mwp.DisplayName != nil { + objectMap["displayName"] = mwp.DisplayName + } + if mwp.SerializedData != nil { + objectMap["serializedData"] = mwp.SerializedData + } + if mwp.Version != nil { + objectMap["version"] = mwp.Version + } + if mwp.Category != nil { + objectMap["category"] = mwp.Category + } + if mwp.Tags != nil { + objectMap["tags"] = mwp.Tags + } + if mwp.SourceID != nil { + objectMap["sourceId"] = mwp.SourceID + } + return json.Marshal(objectMap) +} + +// MyWorkbookResource an azure resource object +type MyWorkbookResource 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 MyWorkbookResource. +func (mwr MyWorkbookResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mwr.ID != nil { + objectMap["id"] = mwr.ID + } + if mwr.Name != nil { + objectMap["name"] = mwr.Name + } + if mwr.Type != nil { + objectMap["type"] = mwr.Type + } + if mwr.Location != nil { + objectMap["location"] = mwr.Location + } + if mwr.Tags != nil { + objectMap["tags"] = mwr.Tags + } + return json.Marshal(objectMap) +} + +// MyWorkbooksListResult workbook list result. +type MyWorkbooksListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; An array of private workbooks. + Value *[]MyWorkbook `json:"value,omitempty"` +} + // Operation CDN REST API operation type Operation struct { // Name - Operation name: {provider}/{resource}/{operation} @@ -987,8 +1213,8 @@ type OperationDisplay struct { Operation *string `json:"operation,omitempty"` } -// OperationListResult result of the request to list CDN operations. It contains a list of operations and a URL -// link to get the next set of results. +// OperationListResult result of the request to list CDN operations. It contains a list of operations and a +// URL link to get the next set of results. type OperationListResult struct { autorest.Response `json:"-"` // Value - List of CDN operations supported by the CDN resource provider. @@ -1140,8 +1366,11 @@ func (page OperationListResultPage) Values() []Operation { } // Creates a new instance of the OperationListResultPage type. -func NewOperationListResultPage(getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage { - return OperationListResultPage{fn: getNextPage} +func NewOperationListResultPage(cur OperationListResult, getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage { + return OperationListResultPage{ + fn: getNextPage, + olr: cur, + } } // PrivateLinkScopedResource the private link scope resource reference. @@ -1283,8 +1512,8 @@ func (wt *WebTest) UnmarshalJSON(body []byte) error { return nil } -// WebTestGeolocation geo-physical location to run a web test from. You must specify one or more locations for -// the test to run from. +// WebTestGeolocation geo-physical location to run a web test from. You must specify one or more locations +// for the test to run from. type WebTestGeolocation struct { // Location - Location ID for the webtest to run from. Location *string `json:"Id,omitempty"` @@ -1442,8 +1671,11 @@ func (page WebTestListResultPage) Values() []WebTest { } // Creates a new instance of the WebTestListResultPage type. -func NewWebTestListResultPage(getNextPage func(context.Context, WebTestListResult) (WebTestListResult, error)) WebTestListResultPage { - return WebTestListResultPage{fn: getNextPage} +func NewWebTestListResultPage(cur WebTestListResult, getNextPage func(context.Context, WebTestListResult) (WebTestListResult, error)) WebTestListResultPage { + return WebTestListResultPage{ + fn: getNextPage, + wtlr: cur, + } } // WebTestProperties metadata describing a web test for an Azure resource. diff --git a/services/appinsights/mgmt/2015-05-01/insights/myworkbooks.go b/services/appinsights/mgmt/2015-05-01/insights/myworkbooks.go new file mode 100644 index 000000000000..c6c257a9b080 --- /dev/null +++ b/services/appinsights/mgmt/2015-05-01/insights/myworkbooks.go @@ -0,0 +1,576 @@ +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" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// MyWorkbooksClient is the composite Swagger for Application Insights Management Client +type MyWorkbooksClient struct { + BaseClient +} + +// NewMyWorkbooksClient creates an instance of the MyWorkbooksClient client. +func NewMyWorkbooksClient(subscriptionID string) MyWorkbooksClient { + return NewMyWorkbooksClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewMyWorkbooksClientWithBaseURI creates an instance of the MyWorkbooksClient client using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewMyWorkbooksClientWithBaseURI(baseURI string, subscriptionID string) MyWorkbooksClient { + return MyWorkbooksClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create a new private workbook. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the Application Insights component resource. +// workbookProperties - properties that need to be specified to create a new private workbook. +func (client MyWorkbooksClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, workbookProperties MyWorkbook) (result MyWorkbook, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MyWorkbooksClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: workbookProperties, + Constraints: []validation.Constraint{{Target: "workbookProperties.MyWorkbookProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "workbookProperties.MyWorkbookProperties.DisplayName", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "workbookProperties.MyWorkbookProperties.SerializedData", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "workbookProperties.MyWorkbookProperties.Category", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("insights.MyWorkbooksClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, resourceName, workbookProperties) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MyWorkbooksClient", "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.MyWorkbooksClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MyWorkbooksClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client MyWorkbooksClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, workbookProperties MyWorkbook) (*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}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/myWorkbooks/{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 MyWorkbooksClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client MyWorkbooksClient) CreateOrUpdateResponder(resp *http.Response) (result MyWorkbook, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete a private workbook. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the Application Insights component resource. +func (client MyWorkbooksClient) Delete(ctx context.Context, resourceGroupName string, resourceName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MyWorkbooksClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.MyWorkbooksClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MyWorkbooksClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "insights.MyWorkbooksClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MyWorkbooksClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client MyWorkbooksClient) 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}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/myWorkbooks/{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 MyWorkbooksClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client MyWorkbooksClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get a single private workbook by its resourceName. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the Application Insights component resource. +func (client MyWorkbooksClient) Get(ctx context.Context, resourceGroupName string, resourceName string) (result MyWorkbook, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MyWorkbooksClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.MyWorkbooksClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MyWorkbooksClient", "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.MyWorkbooksClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MyWorkbooksClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client MyWorkbooksClient) 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}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/myWorkbooks/{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 MyWorkbooksClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client MyWorkbooksClient) GetResponder(resp *http.Response) (result MyWorkbook, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup get all private workbooks defined within a specified resource group and category. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// category - category of workbook to return. +// 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 MyWorkbooksClient) ListByResourceGroup(ctx context.Context, resourceGroupName string, category CategoryType, tags []string, canFetchContent *bool) (result MyWorkbooksListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MyWorkbooksClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.MyWorkbooksClient", "ListByResourceGroup", err.Error()) + } + + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName, category, tags, canFetchContent) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MyWorkbooksClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.MyWorkbooksClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MyWorkbooksClient", "ListByResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client MyWorkbooksClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string, category CategoryType, tags []string, canFetchContent *bool) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + "category": autorest.Encode("query", category), + } + if tags != nil && len(tags) > 0 { + queryParameters["tags"] = autorest.Encode("query", tags, ",") + } + if canFetchContent != nil { + queryParameters["canFetchContent"] = autorest.Encode("query", *canFetchContent) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/myWorkbooks", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client MyWorkbooksClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client MyWorkbooksClient) ListByResourceGroupResponder(resp *http.Response) (result MyWorkbooksListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListBySubscription get all private workbooks defined within a specified subscription and category. +// Parameters: +// category - category of workbook to return. +// 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 MyWorkbooksClient) ListBySubscription(ctx context.Context, category CategoryType, tags []string, canFetchContent *bool) (result MyWorkbooksListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MyWorkbooksClient.ListBySubscription") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.MyWorkbooksClient", "ListBySubscription", err.Error()) + } + + req, err := client.ListBySubscriptionPreparer(ctx, category, tags, canFetchContent) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MyWorkbooksClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.MyWorkbooksClient", "ListBySubscription", resp, "Failure sending request") + return + } + + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MyWorkbooksClient", "ListBySubscription", resp, "Failure responding to request") + } + + return +} + +// ListBySubscriptionPreparer prepares the ListBySubscription request. +func (client MyWorkbooksClient) ListBySubscriptionPreparer(ctx context.Context, category CategoryType, tags []string, canFetchContent *bool) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + "category": autorest.Encode("query", category), + } + if tags != nil && len(tags) > 0 { + queryParameters["tags"] = autorest.Encode("query", tags, ",") + } + if canFetchContent != nil { + queryParameters["canFetchContent"] = autorest.Encode("query", *canFetchContent) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Insights/myWorkbooks", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySubscriptionSender sends the ListBySubscription request. The method will close the +// http.Response Body if it receives an error. +func (client MyWorkbooksClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always +// closes the http.Response Body. +func (client MyWorkbooksClient) ListBySubscriptionResponder(resp *http.Response) (result MyWorkbooksListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update updates a private workbook that has already been added. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the Application Insights component resource. +// workbookProperties - properties that need to be specified to create a new private workbook. +func (client MyWorkbooksClient) Update(ctx context.Context, resourceGroupName string, resourceName string, workbookProperties MyWorkbook) (result MyWorkbook, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MyWorkbooksClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.MyWorkbooksClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, resourceName, workbookProperties) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MyWorkbooksClient", "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.MyWorkbooksClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MyWorkbooksClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client MyWorkbooksClient) UpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, workbookProperties MyWorkbook) (*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}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/myWorkbooks/{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 MyWorkbooksClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client MyWorkbooksClient) UpdateResponder(resp *http.Response) (result MyWorkbook, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +}