1package servicemap 2 3// Copyright (c) Microsoft and contributors. All rights reserved. 4// 5// Licensed under the Apache License, Version 2.0 (the "License"); 6// you may not use this file except in compliance with the License. 7// You may obtain a copy of the License at 8// http://www.apache.org/licenses/LICENSE-2.0 9// 10// Unless required by applicable law or agreed to in writing, software 11// distributed under the License is distributed on an "AS IS" BASIS, 12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13// 14// See the License for the specific language governing permissions and 15// limitations under the License. 16// 17// Code generated by Microsoft (R) AutoRest Code Generator. 18// Changes may cause incorrect behavior and will be lost if the code is regenerated. 19 20import ( 21 "context" 22 "github.com/Azure/go-autorest/autorest" 23 "github.com/Azure/go-autorest/autorest/azure" 24 "github.com/Azure/go-autorest/autorest/validation" 25 "net/http" 26) 27 28// Deprecated: Please use package github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2015-11-01-preview/servicemap instead. 29// MapsClient is the service Map API Reference 30type MapsClient struct { 31 BaseClient 32} 33 34// Deprecated: Please use package github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2015-11-01-preview/servicemap instead. 35// NewMapsClient creates an instance of the MapsClient client. 36func NewMapsClient(subscriptionID string) MapsClient { 37 return NewMapsClientWithBaseURI(DefaultBaseURI, subscriptionID) 38} 39 40// Deprecated: Please use package github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2015-11-01-preview/servicemap instead. 41// NewMapsClientWithBaseURI creates an instance of the MapsClient client. 42func NewMapsClientWithBaseURI(baseURI string, subscriptionID string) MapsClient { 43 return MapsClient{NewWithBaseURI(baseURI, subscriptionID)} 44} 45 46// Deprecated: Please use package github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2015-11-01-preview/servicemap instead. 47// Generate generates the specified map. 48// 49// resourceGroupName is resource group name within the specified subscriptionId. workspaceName is OMS workspace 50// containing the resources of interest. request is request options. 51func (client MapsClient) Generate(ctx context.Context, resourceGroupName string, workspaceName string, request BasicMapRequest) (result MapResponse, err error) { 52 if err := validation.Validate([]validation.Validation{ 53 {TargetValue: resourceGroupName, 54 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 64, Chain: nil}, 55 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 56 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `[a-zA-Z0-9_-]+`, Chain: nil}}}, 57 {TargetValue: workspaceName, 58 Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 63, Chain: nil}, 59 {Target: "workspaceName", Name: validation.MinLength, Rule: 3, Chain: nil}, 60 {Target: "workspaceName", Name: validation.Pattern, Rule: `[a-zA-Z0-9_][a-zA-Z0-9_-]+[a-zA-Z0-9_]`, Chain: nil}}}}); err != nil { 61 return result, validation.NewError("servicemap.MapsClient", "Generate", err.Error()) 62 } 63 64 req, err := client.GeneratePreparer(ctx, resourceGroupName, workspaceName, request) 65 if err != nil { 66 err = autorest.NewErrorWithError(err, "servicemap.MapsClient", "Generate", nil, "Failure preparing request") 67 return 68 } 69 70 resp, err := client.GenerateSender(req) 71 if err != nil { 72 result.Response = autorest.Response{Response: resp} 73 err = autorest.NewErrorWithError(err, "servicemap.MapsClient", "Generate", resp, "Failure sending request") 74 return 75 } 76 77 result, err = client.GenerateResponder(resp) 78 if err != nil { 79 err = autorest.NewErrorWithError(err, "servicemap.MapsClient", "Generate", resp, "Failure responding to request") 80 } 81 82 return 83} 84 85// Deprecated: Please use package github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2015-11-01-preview/servicemap instead. 86// GeneratePreparer prepares the Generate request. 87func (client MapsClient) GeneratePreparer(ctx context.Context, resourceGroupName string, workspaceName string, request BasicMapRequest) (*http.Request, error) { 88 pathParameters := map[string]interface{}{ 89 "resourceGroupName": autorest.Encode("path", resourceGroupName), 90 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 91 "workspaceName": autorest.Encode("path", workspaceName), 92 } 93 94 const APIVersion = "2015-11-01-preview" 95 queryParameters := map[string]interface{}{ 96 "api-version": APIVersion, 97 } 98 99 preparer := autorest.CreatePreparer( 100 autorest.AsContentType("application/json; charset=utf-8"), 101 autorest.AsPost(), 102 autorest.WithBaseURL(client.BaseURI), 103 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/features/serviceMap/generateMap", pathParameters), 104 autorest.WithJSON(request), 105 autorest.WithQueryParameters(queryParameters)) 106 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 107} 108 109// Deprecated: Please use package github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2015-11-01-preview/servicemap instead. 110// GenerateSender sends the Generate request. The method will close the 111// http.Response Body if it receives an error. 112func (client MapsClient) GenerateSender(req *http.Request) (*http.Response, error) { 113 return autorest.SendWithSender(client, req, 114 azure.DoRetryWithRegistration(client.Client)) 115} 116 117// Deprecated: Please use package github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2015-11-01-preview/servicemap instead. 118// GenerateResponder handles the response to the Generate request. The method always 119// closes the http.Response Body. 120func (client MapsClient) GenerateResponder(resp *http.Response) (result MapResponse, err error) { 121 err = autorest.Respond( 122 resp, 123 client.ByInspecting(), 124 azure.WithErrorUnlessStatusCode(http.StatusOK), 125 autorest.ByUnmarshallingJSON(&result), 126 autorest.ByClosing()) 127 result.Response = autorest.Response{Response: resp} 128 return 129} 130