diff --git a/sdk/resourcemanager/elastic/armelastic/CHANGELOG.md b/sdk/resourcemanager/elastic/armelastic/CHANGELOG.md index cec5dc5b008b..4931ec7e4fe5 100644 --- a/sdk/resourcemanager/elastic/armelastic/CHANGELOG.md +++ b/sdk/resourcemanager/elastic/armelastic/CHANGELOG.md @@ -1,5 +1,37 @@ # Release History +## 0.10.0 (2023-11-13) +### Breaking Changes + +- Function `timeRFC3339.MarshalText` has been removed +- Function `*timeRFC3339.Parse` has been removed +- Function `*timeRFC3339.UnmarshalText` has been removed + +### Features Added + +- New function `NewBillingInfoClient(string, azcore.TokenCredential, *arm.ClientOptions) (*BillingInfoClient, error)` +- New function `*BillingInfoClient.Get(context.Context, string, string, *BillingInfoClientGetOptions) (BillingInfoClientGetResponse, error)` +- New function `*ClientFactory.NewBillingInfoClient() *BillingInfoClient` +- New function `*ClientFactory.NewConnectedPartnerResourcesClient() *ConnectedPartnerResourcesClient` +- New function `NewConnectedPartnerResourcesClient(string, azcore.TokenCredential, *arm.ClientOptions) (*ConnectedPartnerResourcesClient, error)` +- New function `*ConnectedPartnerResourcesClient.NewListPager(string, string, *ConnectedPartnerResourcesClientListOptions) *runtime.Pager[ConnectedPartnerResourcesClientListResponse]` +- New function `*OrganizationsClient.GetElasticToAzureSubscriptionMapping(context.Context, *OrganizationsClientGetElasticToAzureSubscriptionMappingOptions) (OrganizationsClientGetElasticToAzureSubscriptionMappingResponse, error)` +- New function `dateTimeRFC3339.MarshalText() ([]byte, error)` +- New function `*dateTimeRFC3339.Parse(string) error` +- New function `*dateTimeRFC3339.UnmarshalText([]byte) error` +- New struct `BillingInfoResponse` +- New struct `ConnectedPartnerResourceProperties` +- New struct `ConnectedPartnerResourcesListFormat` +- New struct `ConnectedPartnerResourcesListResponse` +- New struct `OrganizationToAzureSubscriptionMappingResponse` +- New struct `OrganizationToAzureSubscriptionMappingResponseProperties` +- New struct `PartnerBillingEntity` +- New struct `PlanDetails` +- New field `ElasticsearchEndPoint` in struct `DeploymentInfoResponse` +- New field `BilledAzureSubscriptionID`, `MarketplaceStatus`, `Subscribed` in struct `MarketplaceSaaSInfo` +- New field `PlanDetails`, `SaaSAzureSubscriptionStatus`, `SourceCampaignID`, `SourceCampaignName` in struct `MonitorProperties` + + ## 0.9.0 (2023-05-26) ### Breaking Changes diff --git a/sdk/resourcemanager/elastic/armelastic/alltrafficfilters_client.go b/sdk/resourcemanager/elastic/armelastic/alltrafficfilters_client.go index 35043c5ab9c8..8d6bb5873676 100644 --- a/sdk/resourcemanager/elastic/armelastic/alltrafficfilters_client.go +++ b/sdk/resourcemanager/elastic/armelastic/alltrafficfilters_client.go @@ -13,7 +13,7 @@ // 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. -// DO NOT EDIT. +// Code generated by @autorest/go. DO NOT EDIT. package armelastic @@ -37,11 +37,11 @@ type AllTrafficFiltersClient struct { } // NewAllTrafficFiltersClient creates a new instance of AllTrafficFiltersClient with the specified values. -// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewAllTrafficFiltersClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AllTrafficFiltersClient, error) { - cl, err := arm.NewClient(moduleName+".AllTrafficFiltersClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -55,23 +55,30 @@ func NewAllTrafficFiltersClient(subscriptionID string, credential azcore.TokenCr // List - Get the list of all traffic filters for the account. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-02-01-preview -// - resourceGroupName - The name of the resource group to which the Elastic resource belongs. +// Generated from API version 2023-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - monitorName - Monitor resource name // - options - AllTrafficFiltersClientListOptions contains the optional parameters for the AllTrafficFiltersClient.List method. func (client *AllTrafficFiltersClient) List(ctx context.Context, resourceGroupName string, monitorName string, options *AllTrafficFiltersClientListOptions) (AllTrafficFiltersClientListResponse, error) { + var err error + const operationName = "AllTrafficFiltersClient.List" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.listCreateRequest(ctx, resourceGroupName, monitorName, options) if err != nil { return AllTrafficFiltersClientListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return AllTrafficFiltersClientListResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return AllTrafficFiltersClientListResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return AllTrafficFiltersClientListResponse{}, err } - return client.listHandleResponse(resp) + resp, err := client.listHandleResponse(httpResp) + return resp, err } // listCreateRequest creates the List request. @@ -94,7 +101,7 @@ func (client *AllTrafficFiltersClient) listCreateRequest(ctx context.Context, re return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-02-01-preview") + reqQP.Set("api-version", "2023-11-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/elastic/armelastic/alltrafficfilters_client_example_test.go b/sdk/resourcemanager/elastic/armelastic/alltrafficfilters_client_example_test.go deleted file mode 100644 index 39bfa37165cb..000000000000 --- a/sdk/resourcemanager/elastic/armelastic/alltrafficfilters_client_example_test.go +++ /dev/null @@ -1,68 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. 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. -// DO NOT EDIT. - -package armelastic_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/dbd896bc9a795bcb3ec7db0a340b517fd3059620/specification/elastic/resource-manager/Microsoft.Elastic/preview/2023-02-01-preview/examples/AllTrafficFilters_list.json -func ExampleAllTrafficFiltersClient_List() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armelastic.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAllTrafficFiltersClient().List(ctx, "myResourceGroup", "myMonitor", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.TrafficFilterResponse = armelastic.TrafficFilterResponse{ - // Rulesets: []*armelastic.TrafficFilter{ - // { - // Name: to.Ptr("IPFromApi"), - // Type: to.Ptr(armelastic.TypeIP), - // Description: to.Ptr("created from azure"), - // ID: to.Ptr("31d91b5afb6f4c2eaaf104c97b1991dd"), - // IncludeByDefault: to.Ptr(false), - // Region: to.Ptr("azure-eastus"), - // Rules: []*armelastic.TrafficFilterRule{ - // { - // Description: to.Ptr("Allow inbound traffic from IP address 192.168.131.0"), - // ID: to.Ptr("f0297dad72af4a5e964cddf817f35e65"), - // Source: to.Ptr("192.168.131.0"), - // }, - // { - // Description: to.Ptr("Allow inbound traffic from IP address block 192.168.132.6/22"), - // ID: to.Ptr("f9c00169f0e54931ae72aabde326b589"), - // Source: to.Ptr("192.168.132.6/22"), - // }}, - // }}, - // } -} diff --git a/sdk/resourcemanager/elastic/armelastic/associatetrafficfilter_client.go b/sdk/resourcemanager/elastic/armelastic/associatetrafficfilter_client.go index ab797dfbf776..9b7afbc0fc03 100644 --- a/sdk/resourcemanager/elastic/armelastic/associatetrafficfilter_client.go +++ b/sdk/resourcemanager/elastic/armelastic/associatetrafficfilter_client.go @@ -13,7 +13,7 @@ // 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. -// DO NOT EDIT. +// Code generated by @autorest/go. DO NOT EDIT. package armelastic @@ -37,11 +37,11 @@ type AssociateTrafficFilterClient struct { } // NewAssociateTrafficFilterClient creates a new instance of AssociateTrafficFilterClient with the specified values. -// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewAssociateTrafficFilterClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AssociateTrafficFilterClient, error) { - cl, err := arm.NewClient(moduleName+".AssociateTrafficFilterClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -55,8 +55,8 @@ func NewAssociateTrafficFilterClient(subscriptionID string, credential azcore.To // BeginAssociate - Associate traffic filter for the given deployment. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-02-01-preview -// - resourceGroupName - The name of the resource group to which the Elastic resource belongs. +// Generated from API version 2023-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - monitorName - Monitor resource name // - options - AssociateTrafficFilterClientBeginAssociateOptions contains the optional parameters for the AssociateTrafficFilterClient.BeginAssociate // method. @@ -66,31 +66,41 @@ func (client *AssociateTrafficFilterClient) BeginAssociate(ctx context.Context, if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[AssociateTrafficFilterClientAssociateResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[AssociateTrafficFilterClientAssociateResponse]{ FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[AssociateTrafficFilterClientAssociateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[AssociateTrafficFilterClientAssociateResponse]{ + Tracer: client.internal.Tracer(), + }) } } // Associate - Associate traffic filter for the given deployment. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-02-01-preview +// Generated from API version 2023-11-01-preview func (client *AssociateTrafficFilterClient) associate(ctx context.Context, resourceGroupName string, monitorName string, options *AssociateTrafficFilterClientBeginAssociateOptions) (*http.Response, error) { + var err error + const operationName = "AssociateTrafficFilterClient.BeginAssociate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.associateCreateRequest(ctx, resourceGroupName, monitorName, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // associateCreateRequest creates the Associate request. @@ -113,7 +123,7 @@ func (client *AssociateTrafficFilterClient) associateCreateRequest(ctx context.C return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-02-01-preview") + reqQP.Set("api-version", "2023-11-01-preview") if options != nil && options.RulesetID != nil { reqQP.Set("rulesetId", *options.RulesetID) } diff --git a/sdk/resourcemanager/elastic/armelastic/associatetrafficfilter_client_example_test.go b/sdk/resourcemanager/elastic/armelastic/associatetrafficfilter_client_example_test.go deleted file mode 100644 index 47fe391df6bf..000000000000 --- a/sdk/resourcemanager/elastic/armelastic/associatetrafficfilter_client_example_test.go +++ /dev/null @@ -1,48 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. 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. -// DO NOT EDIT. - -package armelastic_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/dbd896bc9a795bcb3ec7db0a340b517fd3059620/specification/elastic/resource-manager/Microsoft.Elastic/preview/2023-02-01-preview/examples/AssociateTrafficFilter_Update.json -func ExampleAssociateTrafficFilterClient_BeginAssociate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armelastic.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewAssociateTrafficFilterClient().BeginAssociate(ctx, "myResourceGroup", "myMonitor", &armelastic.AssociateTrafficFilterClientBeginAssociateOptions{RulesetID: to.Ptr("31d91b5afb6f4c2eaaf104c97b1991dd")}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} diff --git a/sdk/resourcemanager/elastic/armelastic/autorest.md b/sdk/resourcemanager/elastic/armelastic/autorest.md index 592d503f07db..bd163c8f97f4 100644 --- a/sdk/resourcemanager/elastic/armelastic/autorest.md +++ b/sdk/resourcemanager/elastic/armelastic/autorest.md @@ -5,9 +5,8 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/dbd896bc9a795bcb3ec7db0a340b517fd3059620/specification/elastic/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/dbd896bc9a795bcb3ec7db0a340b517fd3059620/specification/elastic/resource-manager/readme.go.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/elastic/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/elastic/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 0.9.0 -tag: package-2023-02-01-preview +module-version: 0.10.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/elastic/armelastic/billinginfo_client.go b/sdk/resourcemanager/elastic/armelastic/billinginfo_client.go new file mode 100644 index 000000000000..a1e7a078056c --- /dev/null +++ b/sdk/resourcemanager/elastic/armelastic/billinginfo_client.go @@ -0,0 +1,117 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. 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. +// Code generated by @autorest/go. DO NOT EDIT. + +package armelastic + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// BillingInfoClient contains the methods for the BillingInfo group. +// Don't use this type directly, use NewBillingInfoClient() instead. +type BillingInfoClient struct { + internal *arm.Client + subscriptionID string +} + +// NewBillingInfoClient creates a new instance of BillingInfoClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewBillingInfoClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*BillingInfoClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &BillingInfoClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// Get - Get marketplace and organization info mapped to the given monitor. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - monitorName - Monitor resource name +// - options - BillingInfoClientGetOptions contains the optional parameters for the BillingInfoClient.Get method. +func (client *BillingInfoClient) Get(ctx context.Context, resourceGroupName string, monitorName string, options *BillingInfoClientGetOptions) (BillingInfoClientGetResponse, error) { + var err error + const operationName = "BillingInfoClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, monitorName, options) + if err != nil { + return BillingInfoClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return BillingInfoClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return BillingInfoClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *BillingInfoClient) getCreateRequest(ctx context.Context, resourceGroupName string, monitorName string, options *BillingInfoClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/getBillingInfo" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if monitorName == "" { + return nil, errors.New("parameter monitorName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{monitorName}", url.PathEscape(monitorName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *BillingInfoClient) getHandleResponse(resp *http.Response) (BillingInfoClientGetResponse, error) { + result := BillingInfoClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.BillingInfoResponse); err != nil { + return BillingInfoClientGetResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/elastic/armelastic/client_factory.go b/sdk/resourcemanager/elastic/armelastic/client_factory.go index 8cfd0bda8c78..18c876529c56 100644 --- a/sdk/resourcemanager/elastic/armelastic/client_factory.go +++ b/sdk/resourcemanager/elastic/armelastic/client_factory.go @@ -13,7 +13,7 @@ // 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. -// DO NOT EDIT. +// Code generated by @autorest/go. DO NOT EDIT. package armelastic @@ -32,11 +32,11 @@ type ClientFactory struct { // NewClientFactory creates a new instance of ClientFactory with the specified values. // The parameter values will be propagated to any client created from this factory. -// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { - _, err := arm.NewClient(moduleName+".ClientFactory", moduleVersion, credential, options) + _, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -46,107 +46,140 @@ func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, }, nil } -func (c *ClientFactory) NewOperationsClient() *OperationsClient { - subClient, _ := NewOperationsClient(c.credential, c.options) +// NewAllTrafficFiltersClient creates a new instance of AllTrafficFiltersClient. +func (c *ClientFactory) NewAllTrafficFiltersClient() *AllTrafficFiltersClient { + subClient, _ := NewAllTrafficFiltersClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewMonitorsClient() *MonitorsClient { - subClient, _ := NewMonitorsClient(c.subscriptionID, c.credential, c.options) +// NewAssociateTrafficFilterClient creates a new instance of AssociateTrafficFilterClient. +func (c *ClientFactory) NewAssociateTrafficFilterClient() *AssociateTrafficFilterClient { + subClient, _ := NewAssociateTrafficFilterClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewVersionsClient() *VersionsClient { - subClient, _ := NewVersionsClient(c.subscriptionID, c.credential, c.options) +// NewBillingInfoClient creates a new instance of BillingInfoClient. +func (c *ClientFactory) NewBillingInfoClient() *BillingInfoClient { + subClient, _ := NewBillingInfoClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewMonitoredResourcesClient() *MonitoredResourcesClient { - subClient, _ := NewMonitoredResourcesClient(c.subscriptionID, c.credential, c.options) +// NewConnectedPartnerResourcesClient creates a new instance of ConnectedPartnerResourcesClient. +func (c *ClientFactory) NewConnectedPartnerResourcesClient() *ConnectedPartnerResourcesClient { + subClient, _ := NewConnectedPartnerResourcesClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewDeploymentInfoClient() *DeploymentInfoClient { - subClient, _ := NewDeploymentInfoClient(c.subscriptionID, c.credential, c.options) +// NewCreateAndAssociateIPFilterClient creates a new instance of CreateAndAssociateIPFilterClient. +func (c *ClientFactory) NewCreateAndAssociateIPFilterClient() *CreateAndAssociateIPFilterClient { + subClient, _ := NewCreateAndAssociateIPFilterClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewExternalUserClient() *ExternalUserClient { - subClient, _ := NewExternalUserClient(c.subscriptionID, c.credential, c.options) +// NewCreateAndAssociatePLFilterClient creates a new instance of CreateAndAssociatePLFilterClient. +func (c *ClientFactory) NewCreateAndAssociatePLFilterClient() *CreateAndAssociatePLFilterClient { + subClient, _ := NewCreateAndAssociatePLFilterClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewTagRulesClient() *TagRulesClient { - subClient, _ := NewTagRulesClient(c.subscriptionID, c.credential, c.options) +// NewDeploymentInfoClient creates a new instance of DeploymentInfoClient. +func (c *ClientFactory) NewDeploymentInfoClient() *DeploymentInfoClient { + subClient, _ := NewDeploymentInfoClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewVMHostClient() *VMHostClient { - subClient, _ := NewVMHostClient(c.subscriptionID, c.credential, c.options) +// NewDetachAndDeleteTrafficFilterClient creates a new instance of DetachAndDeleteTrafficFilterClient. +func (c *ClientFactory) NewDetachAndDeleteTrafficFilterClient() *DetachAndDeleteTrafficFilterClient { + subClient, _ := NewDetachAndDeleteTrafficFilterClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewVMIngestionClient() *VMIngestionClient { - subClient, _ := NewVMIngestionClient(c.subscriptionID, c.credential, c.options) +// NewDetachTrafficFilterClient creates a new instance of DetachTrafficFilterClient. +func (c *ClientFactory) NewDetachTrafficFilterClient() *DetachTrafficFilterClient { + subClient, _ := NewDetachTrafficFilterClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewVMCollectionClient() *VMCollectionClient { - subClient, _ := NewVMCollectionClient(c.subscriptionID, c.credential, c.options) +// NewExternalUserClient creates a new instance of ExternalUserClient. +func (c *ClientFactory) NewExternalUserClient() *ExternalUserClient { + subClient, _ := NewExternalUserClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewUpgradableVersionsClient() *UpgradableVersionsClient { - subClient, _ := NewUpgradableVersionsClient(c.subscriptionID, c.credential, c.options) +// NewListAssociatedTrafficFiltersClient creates a new instance of ListAssociatedTrafficFiltersClient. +func (c *ClientFactory) NewListAssociatedTrafficFiltersClient() *ListAssociatedTrafficFiltersClient { + subClient, _ := NewListAssociatedTrafficFiltersClient(c.subscriptionID, c.credential, c.options) return subClient } +// NewMonitorClient creates a new instance of MonitorClient. func (c *ClientFactory) NewMonitorClient() *MonitorClient { subClient, _ := NewMonitorClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewAllTrafficFiltersClient() *AllTrafficFiltersClient { - subClient, _ := NewAllTrafficFiltersClient(c.subscriptionID, c.credential, c.options) +// NewMonitoredResourcesClient creates a new instance of MonitoredResourcesClient. +func (c *ClientFactory) NewMonitoredResourcesClient() *MonitoredResourcesClient { + subClient, _ := NewMonitoredResourcesClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewListAssociatedTrafficFiltersClient() *ListAssociatedTrafficFiltersClient { - subClient, _ := NewListAssociatedTrafficFiltersClient(c.subscriptionID, c.credential, c.options) +// NewMonitorsClient creates a new instance of MonitorsClient. +func (c *ClientFactory) NewMonitorsClient() *MonitorsClient { + subClient, _ := NewMonitorsClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewCreateAndAssociateIPFilterClient() *CreateAndAssociateIPFilterClient { - subClient, _ := NewCreateAndAssociateIPFilterClient(c.subscriptionID, c.credential, c.options) +// NewOperationsClient creates a new instance of OperationsClient. +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + subClient, _ := NewOperationsClient(c.credential, c.options) return subClient } -func (c *ClientFactory) NewCreateAndAssociatePLFilterClient() *CreateAndAssociatePLFilterClient { - subClient, _ := NewCreateAndAssociatePLFilterClient(c.subscriptionID, c.credential, c.options) +// NewOrganizationsClient creates a new instance of OrganizationsClient. +func (c *ClientFactory) NewOrganizationsClient() *OrganizationsClient { + subClient, _ := NewOrganizationsClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewAssociateTrafficFilterClient() *AssociateTrafficFilterClient { - subClient, _ := NewAssociateTrafficFilterClient(c.subscriptionID, c.credential, c.options) +// NewTagRulesClient creates a new instance of TagRulesClient. +func (c *ClientFactory) NewTagRulesClient() *TagRulesClient { + subClient, _ := NewTagRulesClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewDetachAndDeleteTrafficFilterClient() *DetachAndDeleteTrafficFilterClient { - subClient, _ := NewDetachAndDeleteTrafficFilterClient(c.subscriptionID, c.credential, c.options) +// NewTrafficFiltersClient creates a new instance of TrafficFiltersClient. +func (c *ClientFactory) NewTrafficFiltersClient() *TrafficFiltersClient { + subClient, _ := NewTrafficFiltersClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewDetachTrafficFilterClient() *DetachTrafficFilterClient { - subClient, _ := NewDetachTrafficFilterClient(c.subscriptionID, c.credential, c.options) +// NewUpgradableVersionsClient creates a new instance of UpgradableVersionsClient. +func (c *ClientFactory) NewUpgradableVersionsClient() *UpgradableVersionsClient { + subClient, _ := NewUpgradableVersionsClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewTrafficFiltersClient() *TrafficFiltersClient { - subClient, _ := NewTrafficFiltersClient(c.subscriptionID, c.credential, c.options) +// NewVMCollectionClient creates a new instance of VMCollectionClient. +func (c *ClientFactory) NewVMCollectionClient() *VMCollectionClient { + subClient, _ := NewVMCollectionClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewOrganizationsClient() *OrganizationsClient { - subClient, _ := NewOrganizationsClient(c.subscriptionID, c.credential, c.options) +// NewVMHostClient creates a new instance of VMHostClient. +func (c *ClientFactory) NewVMHostClient() *VMHostClient { + subClient, _ := NewVMHostClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +// NewVMIngestionClient creates a new instance of VMIngestionClient. +func (c *ClientFactory) NewVMIngestionClient() *VMIngestionClient { + subClient, _ := NewVMIngestionClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +// NewVersionsClient creates a new instance of VersionsClient. +func (c *ClientFactory) NewVersionsClient() *VersionsClient { + subClient, _ := NewVersionsClient(c.subscriptionID, c.credential, c.options) return subClient } diff --git a/sdk/resourcemanager/elastic/armelastic/connectedpartnerresources_client.go b/sdk/resourcemanager/elastic/armelastic/connectedpartnerresources_client.go new file mode 100644 index 000000000000..9ac1a0692208 --- /dev/null +++ b/sdk/resourcemanager/elastic/armelastic/connectedpartnerresources_client.go @@ -0,0 +1,119 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. 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. +// Code generated by @autorest/go. DO NOT EDIT. + +package armelastic + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// ConnectedPartnerResourcesClient contains the methods for the ConnectedPartnerResources group. +// Don't use this type directly, use NewConnectedPartnerResourcesClient() instead. +type ConnectedPartnerResourcesClient struct { + internal *arm.Client + subscriptionID string +} + +// NewConnectedPartnerResourcesClient creates a new instance of ConnectedPartnerResourcesClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewConnectedPartnerResourcesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ConnectedPartnerResourcesClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &ConnectedPartnerResourcesClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// NewListPager - List of all active deployments that are associated with the marketplace subscription linked to the given +// monitor. +// +// Generated from API version 2023-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - monitorName - Monitor resource name +// - options - ConnectedPartnerResourcesClientListOptions contains the optional parameters for the ConnectedPartnerResourcesClient.NewListPager +// method. +func (client *ConnectedPartnerResourcesClient) NewListPager(resourceGroupName string, monitorName string, options *ConnectedPartnerResourcesClientListOptions) *runtime.Pager[ConnectedPartnerResourcesClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[ConnectedPartnerResourcesClientListResponse]{ + More: func(page ConnectedPartnerResourcesClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ConnectedPartnerResourcesClientListResponse) (ConnectedPartnerResourcesClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ConnectedPartnerResourcesClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, monitorName, options) + }, nil) + if err != nil { + return ConnectedPartnerResourcesClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *ConnectedPartnerResourcesClient) listCreateRequest(ctx context.Context, resourceGroupName string, monitorName string, options *ConnectedPartnerResourcesClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/listConnectedPartnerResources" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if monitorName == "" { + return nil, errors.New("parameter monitorName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{monitorName}", url.PathEscape(monitorName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *ConnectedPartnerResourcesClient) listHandleResponse(resp *http.Response) (ConnectedPartnerResourcesClientListResponse, error) { + result := ConnectedPartnerResourcesClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ConnectedPartnerResourcesListResponse); err != nil { + return ConnectedPartnerResourcesClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/elastic/armelastic/constants.go b/sdk/resourcemanager/elastic/armelastic/constants.go index 895fd3ac361e..f76f64ba1f94 100644 --- a/sdk/resourcemanager/elastic/armelastic/constants.go +++ b/sdk/resourcemanager/elastic/armelastic/constants.go @@ -13,13 +13,13 @@ // 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. -// DO NOT EDIT. +// Code generated by @autorest/go. DO NOT EDIT. package armelastic const ( - moduleName = "armelastic" - moduleVersion = "v0.9.0" + moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" + moduleVersion = "v0.10.0" ) // CreatedByType - The type of identity that created the resource. diff --git a/sdk/resourcemanager/elastic/armelastic/createandassociateipfilter_client.go b/sdk/resourcemanager/elastic/armelastic/createandassociateipfilter_client.go index e198ee3c6121..0cdddcc7afcc 100644 --- a/sdk/resourcemanager/elastic/armelastic/createandassociateipfilter_client.go +++ b/sdk/resourcemanager/elastic/armelastic/createandassociateipfilter_client.go @@ -13,7 +13,7 @@ // 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. -// DO NOT EDIT. +// Code generated by @autorest/go. DO NOT EDIT. package armelastic @@ -37,11 +37,11 @@ type CreateAndAssociateIPFilterClient struct { } // NewCreateAndAssociateIPFilterClient creates a new instance of CreateAndAssociateIPFilterClient with the specified values. -// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewCreateAndAssociateIPFilterClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*CreateAndAssociateIPFilterClient, error) { - cl, err := arm.NewClient(moduleName+".CreateAndAssociateIPFilterClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -55,8 +55,8 @@ func NewCreateAndAssociateIPFilterClient(subscriptionID string, credential azcor // BeginCreate - Create and Associate IP traffic filter for the given deployment. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-02-01-preview -// - resourceGroupName - The name of the resource group to which the Elastic resource belongs. +// Generated from API version 2023-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - monitorName - Monitor resource name // - options - CreateAndAssociateIPFilterClientBeginCreateOptions contains the optional parameters for the CreateAndAssociateIPFilterClient.BeginCreate // method. @@ -66,31 +66,41 @@ func (client *CreateAndAssociateIPFilterClient) BeginCreate(ctx context.Context, if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CreateAndAssociateIPFilterClientCreateResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CreateAndAssociateIPFilterClientCreateResponse]{ FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[CreateAndAssociateIPFilterClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[CreateAndAssociateIPFilterClientCreateResponse]{ + Tracer: client.internal.Tracer(), + }) } } // Create - Create and Associate IP traffic filter for the given deployment. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-02-01-preview +// Generated from API version 2023-11-01-preview func (client *CreateAndAssociateIPFilterClient) create(ctx context.Context, resourceGroupName string, monitorName string, options *CreateAndAssociateIPFilterClientBeginCreateOptions) (*http.Response, error) { + var err error + const operationName = "CreateAndAssociateIPFilterClient.BeginCreate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.createCreateRequest(ctx, resourceGroupName, monitorName, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // createCreateRequest creates the Create request. @@ -113,7 +123,7 @@ func (client *CreateAndAssociateIPFilterClient) createCreateRequest(ctx context. return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-02-01-preview") + reqQP.Set("api-version", "2023-11-01-preview") if options != nil && options.IPs != nil { reqQP.Set("ips", *options.IPs) } diff --git a/sdk/resourcemanager/elastic/armelastic/createandassociateipfilter_client_example_test.go b/sdk/resourcemanager/elastic/armelastic/createandassociateipfilter_client_example_test.go deleted file mode 100644 index 8a78cd615ad5..000000000000 --- a/sdk/resourcemanager/elastic/armelastic/createandassociateipfilter_client_example_test.go +++ /dev/null @@ -1,50 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. 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. -// DO NOT EDIT. - -package armelastic_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/dbd896bc9a795bcb3ec7db0a340b517fd3059620/specification/elastic/resource-manager/Microsoft.Elastic/preview/2023-02-01-preview/examples/IPTrafficFilter_Create.json -func ExampleCreateAndAssociateIPFilterClient_BeginCreate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armelastic.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewCreateAndAssociateIPFilterClient().BeginCreate(ctx, "myResourceGroup", "myMonitor", &armelastic.CreateAndAssociateIPFilterClientBeginCreateOptions{IPs: to.Ptr("192.168.131.0, 192.168.132.6/22"), - Name: nil, - }) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} diff --git a/sdk/resourcemanager/elastic/armelastic/createandassociateplfilter_client.go b/sdk/resourcemanager/elastic/armelastic/createandassociateplfilter_client.go index 0c5315a78784..f158893e3ccb 100644 --- a/sdk/resourcemanager/elastic/armelastic/createandassociateplfilter_client.go +++ b/sdk/resourcemanager/elastic/armelastic/createandassociateplfilter_client.go @@ -13,7 +13,7 @@ // 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. -// DO NOT EDIT. +// Code generated by @autorest/go. DO NOT EDIT. package armelastic @@ -37,11 +37,11 @@ type CreateAndAssociatePLFilterClient struct { } // NewCreateAndAssociatePLFilterClient creates a new instance of CreateAndAssociatePLFilterClient with the specified values. -// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewCreateAndAssociatePLFilterClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*CreateAndAssociatePLFilterClient, error) { - cl, err := arm.NewClient(moduleName+".CreateAndAssociatePLFilterClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -55,8 +55,8 @@ func NewCreateAndAssociatePLFilterClient(subscriptionID string, credential azcor // BeginCreate - Create and Associate private link traffic filter for the given deployment. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-02-01-preview -// - resourceGroupName - The name of the resource group to which the Elastic resource belongs. +// Generated from API version 2023-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - monitorName - Monitor resource name // - options - CreateAndAssociatePLFilterClientBeginCreateOptions contains the optional parameters for the CreateAndAssociatePLFilterClient.BeginCreate // method. @@ -66,31 +66,41 @@ func (client *CreateAndAssociatePLFilterClient) BeginCreate(ctx context.Context, if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CreateAndAssociatePLFilterClientCreateResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CreateAndAssociatePLFilterClientCreateResponse]{ FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[CreateAndAssociatePLFilterClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[CreateAndAssociatePLFilterClientCreateResponse]{ + Tracer: client.internal.Tracer(), + }) } } // Create - Create and Associate private link traffic filter for the given deployment. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-02-01-preview +// Generated from API version 2023-11-01-preview func (client *CreateAndAssociatePLFilterClient) create(ctx context.Context, resourceGroupName string, monitorName string, options *CreateAndAssociatePLFilterClientBeginCreateOptions) (*http.Response, error) { + var err error + const operationName = "CreateAndAssociatePLFilterClient.BeginCreate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.createCreateRequest(ctx, resourceGroupName, monitorName, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // createCreateRequest creates the Create request. @@ -113,7 +123,7 @@ func (client *CreateAndAssociatePLFilterClient) createCreateRequest(ctx context. return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-02-01-preview") + reqQP.Set("api-version", "2023-11-01-preview") if options != nil && options.Name != nil { reqQP.Set("name", *options.Name) } diff --git a/sdk/resourcemanager/elastic/armelastic/createandassociateplfilter_client_example_test.go b/sdk/resourcemanager/elastic/armelastic/createandassociateplfilter_client_example_test.go deleted file mode 100644 index 693ef28405d0..000000000000 --- a/sdk/resourcemanager/elastic/armelastic/createandassociateplfilter_client_example_test.go +++ /dev/null @@ -1,51 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. 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. -// DO NOT EDIT. - -package armelastic_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/dbd896bc9a795bcb3ec7db0a340b517fd3059620/specification/elastic/resource-manager/Microsoft.Elastic/preview/2023-02-01-preview/examples/PrivateLinkTrafficFilters_Create.json -func ExampleCreateAndAssociatePLFilterClient_BeginCreate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armelastic.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewCreateAndAssociatePLFilterClient().BeginCreate(ctx, "myResourceGroup", "myMonitor", &armelastic.CreateAndAssociatePLFilterClientBeginCreateOptions{Name: nil, - PrivateEndpointGUID: to.Ptr("fdb54d3b-e85e-4d08-8958-0d2f7g523df9"), - PrivateEndpointName: to.Ptr("myPrivateEndpoint"), - }) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} diff --git a/sdk/resourcemanager/elastic/armelastic/deploymentinfo_client.go b/sdk/resourcemanager/elastic/armelastic/deploymentinfo_client.go index 646c34348db8..499cfc87663e 100644 --- a/sdk/resourcemanager/elastic/armelastic/deploymentinfo_client.go +++ b/sdk/resourcemanager/elastic/armelastic/deploymentinfo_client.go @@ -13,7 +13,7 @@ // 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. -// DO NOT EDIT. +// Code generated by @autorest/go. DO NOT EDIT. package armelastic @@ -37,11 +37,11 @@ type DeploymentInfoClient struct { } // NewDeploymentInfoClient creates a new instance of DeploymentInfoClient with the specified values. -// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewDeploymentInfoClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DeploymentInfoClient, error) { - cl, err := arm.NewClient(moduleName+".DeploymentInfoClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -55,23 +55,30 @@ func NewDeploymentInfoClient(subscriptionID string, credential azcore.TokenCrede // List - Fetch information regarding Elastic cloud deployment corresponding to the Elastic monitor resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-02-01-preview -// - resourceGroupName - The name of the resource group to which the Elastic resource belongs. +// Generated from API version 2023-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - monitorName - Monitor resource name // - options - DeploymentInfoClientListOptions contains the optional parameters for the DeploymentInfoClient.List method. func (client *DeploymentInfoClient) List(ctx context.Context, resourceGroupName string, monitorName string, options *DeploymentInfoClientListOptions) (DeploymentInfoClientListResponse, error) { + var err error + const operationName = "DeploymentInfoClient.List" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.listCreateRequest(ctx, resourceGroupName, monitorName, options) if err != nil { return DeploymentInfoClientListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return DeploymentInfoClientListResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return DeploymentInfoClientListResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DeploymentInfoClientListResponse{}, err } - return client.listHandleResponse(resp) + resp, err := client.listHandleResponse(httpResp) + return resp, err } // listCreateRequest creates the List request. @@ -94,7 +101,7 @@ func (client *DeploymentInfoClient) listCreateRequest(ctx context.Context, resou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-02-01-preview") + reqQP.Set("api-version", "2023-11-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/elastic/armelastic/deploymentinfo_client_example_test.go b/sdk/resourcemanager/elastic/armelastic/deploymentinfo_client_example_test.go deleted file mode 100644 index b7d5353a4855..000000000000 --- a/sdk/resourcemanager/elastic/armelastic/deploymentinfo_client_example_test.go +++ /dev/null @@ -1,60 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. 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. -// DO NOT EDIT. - -package armelastic_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/dbd896bc9a795bcb3ec7db0a340b517fd3059620/specification/elastic/resource-manager/Microsoft.Elastic/preview/2023-02-01-preview/examples/DeploymentInfo_List.json -func ExampleDeploymentInfoClient_List() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armelastic.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewDeploymentInfoClient().List(ctx, "myResourceGroup", "myMonitor", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.DeploymentInfoResponse = armelastic.DeploymentInfoResponse{ - // DeploymentURL: to.Ptr("https://endpoint.eastus.kb.azure.elastic-cloud.com:9243"), - // DiskCapacity: to.Ptr("245760"), - // MarketplaceSaasInfo: &armelastic.MarketplaceSaaSInfo{ - // MarketplaceName: to.Ptr("MP_RESOURCE"), - // MarketplaceResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.SaaS/resources/AzElastic_b1190c8f"), - // MarketplaceSubscription: &armelastic.MarketplaceSaaSInfoMarketplaceSubscription{ - // ID: to.Ptr("12345678-1234-1234-1234-123456789012"), - // }, - // }, - // MemoryCapacity: to.Ptr("1024"), - // Status: to.Ptr(armelastic.ElasticDeploymentStatusHealthy), - // Version: to.Ptr("7.9.3"), - // } -} diff --git a/sdk/resourcemanager/elastic/armelastic/detachanddeletetrafficfilter_client.go b/sdk/resourcemanager/elastic/armelastic/detachanddeletetrafficfilter_client.go index d45f00970f43..77aa77251cbf 100644 --- a/sdk/resourcemanager/elastic/armelastic/detachanddeletetrafficfilter_client.go +++ b/sdk/resourcemanager/elastic/armelastic/detachanddeletetrafficfilter_client.go @@ -13,7 +13,7 @@ // 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. -// DO NOT EDIT. +// Code generated by @autorest/go. DO NOT EDIT. package armelastic @@ -37,11 +37,11 @@ type DetachAndDeleteTrafficFilterClient struct { } // NewDetachAndDeleteTrafficFilterClient creates a new instance of DetachAndDeleteTrafficFilterClient with the specified values. -// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewDetachAndDeleteTrafficFilterClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DetachAndDeleteTrafficFilterClient, error) { - cl, err := arm.NewClient(moduleName+".DetachAndDeleteTrafficFilterClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -55,22 +55,28 @@ func NewDetachAndDeleteTrafficFilterClient(subscriptionID string, credential azc // Delete - Detach and Delete traffic filter from the given deployment. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-02-01-preview -// - resourceGroupName - The name of the resource group to which the Elastic resource belongs. +// Generated from API version 2023-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - monitorName - Monitor resource name // - options - DetachAndDeleteTrafficFilterClientDeleteOptions contains the optional parameters for the DetachAndDeleteTrafficFilterClient.Delete // method. func (client *DetachAndDeleteTrafficFilterClient) Delete(ctx context.Context, resourceGroupName string, monitorName string, options *DetachAndDeleteTrafficFilterClientDeleteOptions) (DetachAndDeleteTrafficFilterClientDeleteResponse, error) { + var err error + const operationName = "DetachAndDeleteTrafficFilterClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.deleteCreateRequest(ctx, resourceGroupName, monitorName, options) if err != nil { return DetachAndDeleteTrafficFilterClientDeleteResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return DetachAndDeleteTrafficFilterClientDeleteResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return DetachAndDeleteTrafficFilterClientDeleteResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DetachAndDeleteTrafficFilterClientDeleteResponse{}, err } return DetachAndDeleteTrafficFilterClientDeleteResponse{}, nil } @@ -95,7 +101,7 @@ func (client *DetachAndDeleteTrafficFilterClient) deleteCreateRequest(ctx contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-02-01-preview") + reqQP.Set("api-version", "2023-11-01-preview") if options != nil && options.RulesetID != nil { reqQP.Set("rulesetId", *options.RulesetID) } diff --git a/sdk/resourcemanager/elastic/armelastic/detachanddeletetrafficfilter_client_example_test.go b/sdk/resourcemanager/elastic/armelastic/detachanddeletetrafficfilter_client_example_test.go deleted file mode 100644 index 933258b9d66e..000000000000 --- a/sdk/resourcemanager/elastic/armelastic/detachanddeletetrafficfilter_client_example_test.go +++ /dev/null @@ -1,44 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. 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. -// DO NOT EDIT. - -package armelastic_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/dbd896bc9a795bcb3ec7db0a340b517fd3059620/specification/elastic/resource-manager/Microsoft.Elastic/preview/2023-02-01-preview/examples/DetachAndDeleteTrafficFilter_Delete.json -func ExampleDetachAndDeleteTrafficFilterClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armelastic.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewDetachAndDeleteTrafficFilterClient().Delete(ctx, "myResourceGroup", "myMonitor", &armelastic.DetachAndDeleteTrafficFilterClientDeleteOptions{RulesetID: to.Ptr("31d91b5afb6f4c2eaaf104c97b1991dd")}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/elastic/armelastic/detachtrafficfilter_client.go b/sdk/resourcemanager/elastic/armelastic/detachtrafficfilter_client.go index e648e7e51168..7226c7535b65 100644 --- a/sdk/resourcemanager/elastic/armelastic/detachtrafficfilter_client.go +++ b/sdk/resourcemanager/elastic/armelastic/detachtrafficfilter_client.go @@ -13,7 +13,7 @@ // 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. -// DO NOT EDIT. +// Code generated by @autorest/go. DO NOT EDIT. package armelastic @@ -37,11 +37,11 @@ type DetachTrafficFilterClient struct { } // NewDetachTrafficFilterClient creates a new instance of DetachTrafficFilterClient with the specified values. -// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewDetachTrafficFilterClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DetachTrafficFilterClient, error) { - cl, err := arm.NewClient(moduleName+".DetachTrafficFilterClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -55,8 +55,8 @@ func NewDetachTrafficFilterClient(subscriptionID string, credential azcore.Token // BeginUpdate - Detach traffic filter for the given deployment. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-02-01-preview -// - resourceGroupName - The name of the resource group to which the Elastic resource belongs. +// Generated from API version 2023-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - monitorName - Monitor resource name // - options - DetachTrafficFilterClientBeginUpdateOptions contains the optional parameters for the DetachTrafficFilterClient.BeginUpdate // method. @@ -66,31 +66,41 @@ func (client *DetachTrafficFilterClient) BeginUpdate(ctx context.Context, resour if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DetachTrafficFilterClientUpdateResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DetachTrafficFilterClientUpdateResponse]{ FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[DetachTrafficFilterClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[DetachTrafficFilterClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) } } // Update - Detach traffic filter for the given deployment. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-02-01-preview +// Generated from API version 2023-11-01-preview func (client *DetachTrafficFilterClient) update(ctx context.Context, resourceGroupName string, monitorName string, options *DetachTrafficFilterClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "DetachTrafficFilterClient.BeginUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.updateCreateRequest(ctx, resourceGroupName, monitorName, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // updateCreateRequest creates the Update request. @@ -113,7 +123,7 @@ func (client *DetachTrafficFilterClient) updateCreateRequest(ctx context.Context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-02-01-preview") + reqQP.Set("api-version", "2023-11-01-preview") if options != nil && options.RulesetID != nil { reqQP.Set("rulesetId", *options.RulesetID) } diff --git a/sdk/resourcemanager/elastic/armelastic/detachtrafficfilter_client_example_test.go b/sdk/resourcemanager/elastic/armelastic/detachtrafficfilter_client_example_test.go deleted file mode 100644 index b2c3421bd874..000000000000 --- a/sdk/resourcemanager/elastic/armelastic/detachtrafficfilter_client_example_test.go +++ /dev/null @@ -1,48 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. 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. -// DO NOT EDIT. - -package armelastic_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/dbd896bc9a795bcb3ec7db0a340b517fd3059620/specification/elastic/resource-manager/Microsoft.Elastic/preview/2023-02-01-preview/examples/DetachTrafficFilters_Update.json -func ExampleDetachTrafficFilterClient_BeginUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armelastic.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewDetachTrafficFilterClient().BeginUpdate(ctx, "myResourceGroup", "myMonitor", &armelastic.DetachTrafficFilterClientBeginUpdateOptions{RulesetID: to.Ptr("31d91b5afb6f4c2eaaf104c97b1991dd")}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} diff --git a/sdk/resourcemanager/elastic/armelastic/externaluser_client.go b/sdk/resourcemanager/elastic/armelastic/externaluser_client.go index ef2c0fafd268..485f374949f0 100644 --- a/sdk/resourcemanager/elastic/armelastic/externaluser_client.go +++ b/sdk/resourcemanager/elastic/armelastic/externaluser_client.go @@ -13,7 +13,7 @@ // 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. -// DO NOT EDIT. +// Code generated by @autorest/go. DO NOT EDIT. package armelastic @@ -37,11 +37,11 @@ type ExternalUserClient struct { } // NewExternalUserClient creates a new instance of ExternalUserClient with the specified values. -// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewExternalUserClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ExternalUserClient, error) { - cl, err := arm.NewClient(moduleName+".ExternalUserClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -56,24 +56,31 @@ func NewExternalUserClient(subscriptionID string, credential azcore.TokenCredent // deployment // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-02-01-preview -// - resourceGroupName - The name of the resource group to which the Elastic resource belongs. +// Generated from API version 2023-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - monitorName - Monitor resource name // - options - ExternalUserClientCreateOrUpdateOptions contains the optional parameters for the ExternalUserClient.CreateOrUpdate // method. func (client *ExternalUserClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, monitorName string, options *ExternalUserClientCreateOrUpdateOptions) (ExternalUserClientCreateOrUpdateResponse, error) { + var err error + const operationName = "ExternalUserClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, monitorName, options) if err != nil { return ExternalUserClientCreateOrUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ExternalUserClientCreateOrUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ExternalUserClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ExternalUserClientCreateOrUpdateResponse{}, err } - return client.createOrUpdateHandleResponse(resp) + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err } // createOrUpdateCreateRequest creates the CreateOrUpdate request. @@ -96,11 +103,14 @@ func (client *ExternalUserClient) createOrUpdateCreateRequest(ctx context.Contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-02-01-preview") + reqQP.Set("api-version", "2023-11-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.Body != nil { - return req, runtime.MarshalAsJSON(req, *options.Body) + if err := runtime.MarshalAsJSON(req, *options.Body); err != nil { + return nil, err + } + return req, nil } return req, nil } diff --git a/sdk/resourcemanager/elastic/armelastic/externaluser_client_example_test.go b/sdk/resourcemanager/elastic/armelastic/externaluser_client_example_test.go deleted file mode 100644 index d6c1e069c50c..000000000000 --- a/sdk/resourcemanager/elastic/armelastic/externaluser_client_example_test.go +++ /dev/null @@ -1,49 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. 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. -// DO NOT EDIT. - -package armelastic_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/dbd896bc9a795bcb3ec7db0a340b517fd3059620/specification/elastic/resource-manager/Microsoft.Elastic/preview/2023-02-01-preview/examples/ExternalUserInfo.json -func ExampleExternalUserClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armelastic.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExternalUserClient().CreateOrUpdate(ctx, "myResourceGroup", "myMonitor", &armelastic.ExternalUserClientCreateOrUpdateOptions{Body: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ExternalUserCreationResponse = armelastic.ExternalUserCreationResponse{ - // Created: to.Ptr(true), - // } -} diff --git a/sdk/resourcemanager/elastic/armelastic/fake/alltrafficfilters_server.go b/sdk/resourcemanager/elastic/armelastic/fake/alltrafficfilters_server.go new file mode 100644 index 000000000000..501ff813887f --- /dev/null +++ b/sdk/resourcemanager/elastic/armelastic/fake/alltrafficfilters_server.go @@ -0,0 +1,109 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. 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. +// Code generated by @autorest/go. DO NOT EDIT. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" + "net/http" + "net/url" + "regexp" +) + +// AllTrafficFiltersServer is a fake server for instances of the armelastic.AllTrafficFiltersClient type. +type AllTrafficFiltersServer struct { + // List is the fake for method AllTrafficFiltersClient.List + // HTTP status codes to indicate success: http.StatusOK + List func(ctx context.Context, resourceGroupName string, monitorName string, options *armelastic.AllTrafficFiltersClientListOptions) (resp azfake.Responder[armelastic.AllTrafficFiltersClientListResponse], errResp azfake.ErrorResponder) +} + +// NewAllTrafficFiltersServerTransport creates a new instance of AllTrafficFiltersServerTransport with the provided implementation. +// The returned AllTrafficFiltersServerTransport instance is connected to an instance of armelastic.AllTrafficFiltersClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewAllTrafficFiltersServerTransport(srv *AllTrafficFiltersServer) *AllTrafficFiltersServerTransport { + return &AllTrafficFiltersServerTransport{srv: srv} +} + +// AllTrafficFiltersServerTransport connects instances of armelastic.AllTrafficFiltersClient to instances of AllTrafficFiltersServer. +// Don't use this type directly, use NewAllTrafficFiltersServerTransport instead. +type AllTrafficFiltersServerTransport struct { + srv *AllTrafficFiltersServer +} + +// Do implements the policy.Transporter interface for AllTrafficFiltersServerTransport. +func (a *AllTrafficFiltersServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "AllTrafficFiltersClient.List": + resp, err = a.dispatchList(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (a *AllTrafficFiltersServerTransport) dispatchList(req *http.Request) (*http.Response, error) { + if a.srv.List == nil { + return nil, &nonRetriableError{errors.New("fake for method List not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Elastic/monitors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listAllTrafficFilters` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + monitorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("monitorName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.List(req.Context(), resourceGroupNameParam, monitorNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).TrafficFilterResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/elastic/armelastic/fake/associatetrafficfilter_server.go b/sdk/resourcemanager/elastic/armelastic/fake/associatetrafficfilter_server.go new file mode 100644 index 000000000000..0656f62eb826 --- /dev/null +++ b/sdk/resourcemanager/elastic/armelastic/fake/associatetrafficfilter_server.go @@ -0,0 +1,136 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. 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. +// Code generated by @autorest/go. DO NOT EDIT. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" + "net/http" + "net/url" + "regexp" +) + +// AssociateTrafficFilterServer is a fake server for instances of the armelastic.AssociateTrafficFilterClient type. +type AssociateTrafficFilterServer struct { + // BeginAssociate is the fake for method AssociateTrafficFilterClient.BeginAssociate + // HTTP status codes to indicate success: http.StatusAccepted + BeginAssociate func(ctx context.Context, resourceGroupName string, monitorName string, options *armelastic.AssociateTrafficFilterClientBeginAssociateOptions) (resp azfake.PollerResponder[armelastic.AssociateTrafficFilterClientAssociateResponse], errResp azfake.ErrorResponder) +} + +// NewAssociateTrafficFilterServerTransport creates a new instance of AssociateTrafficFilterServerTransport with the provided implementation. +// The returned AssociateTrafficFilterServerTransport instance is connected to an instance of armelastic.AssociateTrafficFilterClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewAssociateTrafficFilterServerTransport(srv *AssociateTrafficFilterServer) *AssociateTrafficFilterServerTransport { + return &AssociateTrafficFilterServerTransport{ + srv: srv, + beginAssociate: newTracker[azfake.PollerResponder[armelastic.AssociateTrafficFilterClientAssociateResponse]](), + } +} + +// AssociateTrafficFilterServerTransport connects instances of armelastic.AssociateTrafficFilterClient to instances of AssociateTrafficFilterServer. +// Don't use this type directly, use NewAssociateTrafficFilterServerTransport instead. +type AssociateTrafficFilterServerTransport struct { + srv *AssociateTrafficFilterServer + beginAssociate *tracker[azfake.PollerResponder[armelastic.AssociateTrafficFilterClientAssociateResponse]] +} + +// Do implements the policy.Transporter interface for AssociateTrafficFilterServerTransport. +func (a *AssociateTrafficFilterServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "AssociateTrafficFilterClient.BeginAssociate": + resp, err = a.dispatchBeginAssociate(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (a *AssociateTrafficFilterServerTransport) dispatchBeginAssociate(req *http.Request) (*http.Response, error) { + if a.srv.BeginAssociate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginAssociate not implemented")} + } + beginAssociate := a.beginAssociate.get(req) + if beginAssociate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Elastic/monitors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/associateTrafficFilter` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + monitorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("monitorName")]) + if err != nil { + return nil, err + } + rulesetIDUnescaped, err := url.QueryUnescape(qp.Get("rulesetId")) + if err != nil { + return nil, err + } + rulesetIDParam := getOptional(rulesetIDUnescaped) + var options *armelastic.AssociateTrafficFilterClientBeginAssociateOptions + if rulesetIDParam != nil { + options = &armelastic.AssociateTrafficFilterClientBeginAssociateOptions{ + RulesetID: rulesetIDParam, + } + } + respr, errRespr := a.srv.BeginAssociate(req.Context(), resourceGroupNameParam, monitorNameParam, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginAssociate = &respr + a.beginAssociate.add(req, beginAssociate) + } + + resp, err := server.PollerResponderNext(beginAssociate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusAccepted}, resp.StatusCode) { + a.beginAssociate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginAssociate) { + a.beginAssociate.remove(req) + } + + return resp, nil +} diff --git a/sdk/resourcemanager/elastic/armelastic/fake/billinginfo_server.go b/sdk/resourcemanager/elastic/armelastic/fake/billinginfo_server.go new file mode 100644 index 000000000000..74603783340c --- /dev/null +++ b/sdk/resourcemanager/elastic/armelastic/fake/billinginfo_server.go @@ -0,0 +1,109 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. 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. +// Code generated by @autorest/go. DO NOT EDIT. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" + "net/http" + "net/url" + "regexp" +) + +// BillingInfoServer is a fake server for instances of the armelastic.BillingInfoClient type. +type BillingInfoServer struct { + // Get is the fake for method BillingInfoClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, monitorName string, options *armelastic.BillingInfoClientGetOptions) (resp azfake.Responder[armelastic.BillingInfoClientGetResponse], errResp azfake.ErrorResponder) +} + +// NewBillingInfoServerTransport creates a new instance of BillingInfoServerTransport with the provided implementation. +// The returned BillingInfoServerTransport instance is connected to an instance of armelastic.BillingInfoClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewBillingInfoServerTransport(srv *BillingInfoServer) *BillingInfoServerTransport { + return &BillingInfoServerTransport{srv: srv} +} + +// BillingInfoServerTransport connects instances of armelastic.BillingInfoClient to instances of BillingInfoServer. +// Don't use this type directly, use NewBillingInfoServerTransport instead. +type BillingInfoServerTransport struct { + srv *BillingInfoServer +} + +// Do implements the policy.Transporter interface for BillingInfoServerTransport. +func (b *BillingInfoServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "BillingInfoClient.Get": + resp, err = b.dispatchGet(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (b *BillingInfoServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if b.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Elastic/monitors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/getBillingInfo` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + monitorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("monitorName")]) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.Get(req.Context(), resourceGroupNameParam, monitorNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).BillingInfoResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/elastic/armelastic/fake/connectedpartnerresources_server.go b/sdk/resourcemanager/elastic/armelastic/fake/connectedpartnerresources_server.go new file mode 100644 index 000000000000..eeb82387642d --- /dev/null +++ b/sdk/resourcemanager/elastic/armelastic/fake/connectedpartnerresources_server.go @@ -0,0 +1,121 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. 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. +// Code generated by @autorest/go. DO NOT EDIT. + +package fake + +import ( + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" + "net/http" + "net/url" + "regexp" +) + +// ConnectedPartnerResourcesServer is a fake server for instances of the armelastic.ConnectedPartnerResourcesClient type. +type ConnectedPartnerResourcesServer struct { + // NewListPager is the fake for method ConnectedPartnerResourcesClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, monitorName string, options *armelastic.ConnectedPartnerResourcesClientListOptions) (resp azfake.PagerResponder[armelastic.ConnectedPartnerResourcesClientListResponse]) +} + +// NewConnectedPartnerResourcesServerTransport creates a new instance of ConnectedPartnerResourcesServerTransport with the provided implementation. +// The returned ConnectedPartnerResourcesServerTransport instance is connected to an instance of armelastic.ConnectedPartnerResourcesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewConnectedPartnerResourcesServerTransport(srv *ConnectedPartnerResourcesServer) *ConnectedPartnerResourcesServerTransport { + return &ConnectedPartnerResourcesServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armelastic.ConnectedPartnerResourcesClientListResponse]](), + } +} + +// ConnectedPartnerResourcesServerTransport connects instances of armelastic.ConnectedPartnerResourcesClient to instances of ConnectedPartnerResourcesServer. +// Don't use this type directly, use NewConnectedPartnerResourcesServerTransport instead. +type ConnectedPartnerResourcesServerTransport struct { + srv *ConnectedPartnerResourcesServer + newListPager *tracker[azfake.PagerResponder[armelastic.ConnectedPartnerResourcesClientListResponse]] +} + +// Do implements the policy.Transporter interface for ConnectedPartnerResourcesServerTransport. +func (c *ConnectedPartnerResourcesServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "ConnectedPartnerResourcesClient.NewListPager": + resp, err = c.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (c *ConnectedPartnerResourcesServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if c.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := c.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Elastic/monitors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listConnectedPartnerResources` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + monitorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("monitorName")]) + if err != nil { + return nil, err + } + resp := c.srv.NewListPager(resourceGroupNameParam, monitorNameParam, nil) + newListPager = &resp + c.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armelastic.ConnectedPartnerResourcesClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + c.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + c.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/elastic/armelastic/fake/createandassociateipfilter_server.go b/sdk/resourcemanager/elastic/armelastic/fake/createandassociateipfilter_server.go new file mode 100644 index 000000000000..fad7d328c8d2 --- /dev/null +++ b/sdk/resourcemanager/elastic/armelastic/fake/createandassociateipfilter_server.go @@ -0,0 +1,142 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. 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. +// Code generated by @autorest/go. DO NOT EDIT. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" + "net/http" + "net/url" + "regexp" +) + +// CreateAndAssociateIPFilterServer is a fake server for instances of the armelastic.CreateAndAssociateIPFilterClient type. +type CreateAndAssociateIPFilterServer struct { + // BeginCreate is the fake for method CreateAndAssociateIPFilterClient.BeginCreate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginCreate func(ctx context.Context, resourceGroupName string, monitorName string, options *armelastic.CreateAndAssociateIPFilterClientBeginCreateOptions) (resp azfake.PollerResponder[armelastic.CreateAndAssociateIPFilterClientCreateResponse], errResp azfake.ErrorResponder) +} + +// NewCreateAndAssociateIPFilterServerTransport creates a new instance of CreateAndAssociateIPFilterServerTransport with the provided implementation. +// The returned CreateAndAssociateIPFilterServerTransport instance is connected to an instance of armelastic.CreateAndAssociateIPFilterClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewCreateAndAssociateIPFilterServerTransport(srv *CreateAndAssociateIPFilterServer) *CreateAndAssociateIPFilterServerTransport { + return &CreateAndAssociateIPFilterServerTransport{ + srv: srv, + beginCreate: newTracker[azfake.PollerResponder[armelastic.CreateAndAssociateIPFilterClientCreateResponse]](), + } +} + +// CreateAndAssociateIPFilterServerTransport connects instances of armelastic.CreateAndAssociateIPFilterClient to instances of CreateAndAssociateIPFilterServer. +// Don't use this type directly, use NewCreateAndAssociateIPFilterServerTransport instead. +type CreateAndAssociateIPFilterServerTransport struct { + srv *CreateAndAssociateIPFilterServer + beginCreate *tracker[azfake.PollerResponder[armelastic.CreateAndAssociateIPFilterClientCreateResponse]] +} + +// Do implements the policy.Transporter interface for CreateAndAssociateIPFilterServerTransport. +func (c *CreateAndAssociateIPFilterServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "CreateAndAssociateIPFilterClient.BeginCreate": + resp, err = c.dispatchBeginCreate(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (c *CreateAndAssociateIPFilterServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) { + if c.srv.BeginCreate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreate not implemented")} + } + beginCreate := c.beginCreate.get(req) + if beginCreate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Elastic/monitors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/createAndAssociateIPFilter` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + monitorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("monitorName")]) + if err != nil { + return nil, err + } + iPsUnescaped, err := url.QueryUnescape(qp.Get("ips")) + if err != nil { + return nil, err + } + iPsParam := getOptional(iPsUnescaped) + nameUnescaped, err := url.QueryUnescape(qp.Get("name")) + if err != nil { + return nil, err + } + nameParam := getOptional(nameUnescaped) + var options *armelastic.CreateAndAssociateIPFilterClientBeginCreateOptions + if iPsParam != nil || nameParam != nil { + options = &armelastic.CreateAndAssociateIPFilterClientBeginCreateOptions{ + IPs: iPsParam, + Name: nameParam, + } + } + respr, errRespr := c.srv.BeginCreate(req.Context(), resourceGroupNameParam, monitorNameParam, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreate = &respr + c.beginCreate.add(req, beginCreate) + } + + resp, err := server.PollerResponderNext(beginCreate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + c.beginCreate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreate) { + c.beginCreate.remove(req) + } + + return resp, nil +} diff --git a/sdk/resourcemanager/elastic/armelastic/fake/createandassociateplfilter_server.go b/sdk/resourcemanager/elastic/armelastic/fake/createandassociateplfilter_server.go new file mode 100644 index 000000000000..9a0ecbebc0d1 --- /dev/null +++ b/sdk/resourcemanager/elastic/armelastic/fake/createandassociateplfilter_server.go @@ -0,0 +1,148 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. 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. +// Code generated by @autorest/go. DO NOT EDIT. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" + "net/http" + "net/url" + "regexp" +) + +// CreateAndAssociatePLFilterServer is a fake server for instances of the armelastic.CreateAndAssociatePLFilterClient type. +type CreateAndAssociatePLFilterServer struct { + // BeginCreate is the fake for method CreateAndAssociatePLFilterClient.BeginCreate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginCreate func(ctx context.Context, resourceGroupName string, monitorName string, options *armelastic.CreateAndAssociatePLFilterClientBeginCreateOptions) (resp azfake.PollerResponder[armelastic.CreateAndAssociatePLFilterClientCreateResponse], errResp azfake.ErrorResponder) +} + +// NewCreateAndAssociatePLFilterServerTransport creates a new instance of CreateAndAssociatePLFilterServerTransport with the provided implementation. +// The returned CreateAndAssociatePLFilterServerTransport instance is connected to an instance of armelastic.CreateAndAssociatePLFilterClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewCreateAndAssociatePLFilterServerTransport(srv *CreateAndAssociatePLFilterServer) *CreateAndAssociatePLFilterServerTransport { + return &CreateAndAssociatePLFilterServerTransport{ + srv: srv, + beginCreate: newTracker[azfake.PollerResponder[armelastic.CreateAndAssociatePLFilterClientCreateResponse]](), + } +} + +// CreateAndAssociatePLFilterServerTransport connects instances of armelastic.CreateAndAssociatePLFilterClient to instances of CreateAndAssociatePLFilterServer. +// Don't use this type directly, use NewCreateAndAssociatePLFilterServerTransport instead. +type CreateAndAssociatePLFilterServerTransport struct { + srv *CreateAndAssociatePLFilterServer + beginCreate *tracker[azfake.PollerResponder[armelastic.CreateAndAssociatePLFilterClientCreateResponse]] +} + +// Do implements the policy.Transporter interface for CreateAndAssociatePLFilterServerTransport. +func (c *CreateAndAssociatePLFilterServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "CreateAndAssociatePLFilterClient.BeginCreate": + resp, err = c.dispatchBeginCreate(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (c *CreateAndAssociatePLFilterServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) { + if c.srv.BeginCreate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreate not implemented")} + } + beginCreate := c.beginCreate.get(req) + if beginCreate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Elastic/monitors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/createAndAssociatePLFilter` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + monitorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("monitorName")]) + if err != nil { + return nil, err + } + nameUnescaped, err := url.QueryUnescape(qp.Get("name")) + if err != nil { + return nil, err + } + nameParam := getOptional(nameUnescaped) + privateEndpointGUIDUnescaped, err := url.QueryUnescape(qp.Get("privateEndpointGuid")) + if err != nil { + return nil, err + } + privateEndpointGUIDParam := getOptional(privateEndpointGUIDUnescaped) + privateEndpointNameUnescaped, err := url.QueryUnescape(qp.Get("privateEndpointName")) + if err != nil { + return nil, err + } + privateEndpointNameParam := getOptional(privateEndpointNameUnescaped) + var options *armelastic.CreateAndAssociatePLFilterClientBeginCreateOptions + if nameParam != nil || privateEndpointGUIDParam != nil || privateEndpointNameParam != nil { + options = &armelastic.CreateAndAssociatePLFilterClientBeginCreateOptions{ + Name: nameParam, + PrivateEndpointGUID: privateEndpointGUIDParam, + PrivateEndpointName: privateEndpointNameParam, + } + } + respr, errRespr := c.srv.BeginCreate(req.Context(), resourceGroupNameParam, monitorNameParam, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreate = &respr + c.beginCreate.add(req, beginCreate) + } + + resp, err := server.PollerResponderNext(beginCreate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + c.beginCreate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreate) { + c.beginCreate.remove(req) + } + + return resp, nil +} diff --git a/sdk/resourcemanager/elastic/armelastic/fake/deploymentinfo_server.go b/sdk/resourcemanager/elastic/armelastic/fake/deploymentinfo_server.go new file mode 100644 index 000000000000..246fdf6ee87b --- /dev/null +++ b/sdk/resourcemanager/elastic/armelastic/fake/deploymentinfo_server.go @@ -0,0 +1,109 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. 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. +// Code generated by @autorest/go. DO NOT EDIT. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" + "net/http" + "net/url" + "regexp" +) + +// DeploymentInfoServer is a fake server for instances of the armelastic.DeploymentInfoClient type. +type DeploymentInfoServer struct { + // List is the fake for method DeploymentInfoClient.List + // HTTP status codes to indicate success: http.StatusOK + List func(ctx context.Context, resourceGroupName string, monitorName string, options *armelastic.DeploymentInfoClientListOptions) (resp azfake.Responder[armelastic.DeploymentInfoClientListResponse], errResp azfake.ErrorResponder) +} + +// NewDeploymentInfoServerTransport creates a new instance of DeploymentInfoServerTransport with the provided implementation. +// The returned DeploymentInfoServerTransport instance is connected to an instance of armelastic.DeploymentInfoClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewDeploymentInfoServerTransport(srv *DeploymentInfoServer) *DeploymentInfoServerTransport { + return &DeploymentInfoServerTransport{srv: srv} +} + +// DeploymentInfoServerTransport connects instances of armelastic.DeploymentInfoClient to instances of DeploymentInfoServer. +// Don't use this type directly, use NewDeploymentInfoServerTransport instead. +type DeploymentInfoServerTransport struct { + srv *DeploymentInfoServer +} + +// Do implements the policy.Transporter interface for DeploymentInfoServerTransport. +func (d *DeploymentInfoServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "DeploymentInfoClient.List": + resp, err = d.dispatchList(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (d *DeploymentInfoServerTransport) dispatchList(req *http.Request) (*http.Response, error) { + if d.srv.List == nil { + return nil, &nonRetriableError{errors.New("fake for method List not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Elastic/monitors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listDeploymentInfo` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + monitorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("monitorName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.List(req.Context(), resourceGroupNameParam, monitorNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).DeploymentInfoResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/elastic/armelastic/fake/detachanddeletetrafficfilter_server.go b/sdk/resourcemanager/elastic/armelastic/fake/detachanddeletetrafficfilter_server.go new file mode 100644 index 000000000000..802fb96bd011 --- /dev/null +++ b/sdk/resourcemanager/elastic/armelastic/fake/detachanddeletetrafficfilter_server.go @@ -0,0 +1,121 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. 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. +// Code generated by @autorest/go. DO NOT EDIT. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" + "net/http" + "net/url" + "regexp" +) + +// DetachAndDeleteTrafficFilterServer is a fake server for instances of the armelastic.DetachAndDeleteTrafficFilterClient type. +type DetachAndDeleteTrafficFilterServer struct { + // Delete is the fake for method DetachAndDeleteTrafficFilterClient.Delete + // HTTP status codes to indicate success: http.StatusOK + Delete func(ctx context.Context, resourceGroupName string, monitorName string, options *armelastic.DetachAndDeleteTrafficFilterClientDeleteOptions) (resp azfake.Responder[armelastic.DetachAndDeleteTrafficFilterClientDeleteResponse], errResp azfake.ErrorResponder) +} + +// NewDetachAndDeleteTrafficFilterServerTransport creates a new instance of DetachAndDeleteTrafficFilterServerTransport with the provided implementation. +// The returned DetachAndDeleteTrafficFilterServerTransport instance is connected to an instance of armelastic.DetachAndDeleteTrafficFilterClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewDetachAndDeleteTrafficFilterServerTransport(srv *DetachAndDeleteTrafficFilterServer) *DetachAndDeleteTrafficFilterServerTransport { + return &DetachAndDeleteTrafficFilterServerTransport{srv: srv} +} + +// DetachAndDeleteTrafficFilterServerTransport connects instances of armelastic.DetachAndDeleteTrafficFilterClient to instances of DetachAndDeleteTrafficFilterServer. +// Don't use this type directly, use NewDetachAndDeleteTrafficFilterServerTransport instead. +type DetachAndDeleteTrafficFilterServerTransport struct { + srv *DetachAndDeleteTrafficFilterServer +} + +// Do implements the policy.Transporter interface for DetachAndDeleteTrafficFilterServerTransport. +func (d *DetachAndDeleteTrafficFilterServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "DetachAndDeleteTrafficFilterClient.Delete": + resp, err = d.dispatchDelete(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (d *DetachAndDeleteTrafficFilterServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if d.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Elastic/monitors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/detachAndDeleteTrafficFilter` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + monitorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("monitorName")]) + if err != nil { + return nil, err + } + rulesetIDUnescaped, err := url.QueryUnescape(qp.Get("rulesetId")) + if err != nil { + return nil, err + } + rulesetIDParam := getOptional(rulesetIDUnescaped) + var options *armelastic.DetachAndDeleteTrafficFilterClientDeleteOptions + if rulesetIDParam != nil { + options = &armelastic.DetachAndDeleteTrafficFilterClientDeleteOptions{ + RulesetID: rulesetIDParam, + } + } + respr, errRespr := d.srv.Delete(req.Context(), resourceGroupNameParam, monitorNameParam, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/elastic/armelastic/fake/detachtrafficfilter_server.go b/sdk/resourcemanager/elastic/armelastic/fake/detachtrafficfilter_server.go new file mode 100644 index 000000000000..baa8b1149703 --- /dev/null +++ b/sdk/resourcemanager/elastic/armelastic/fake/detachtrafficfilter_server.go @@ -0,0 +1,136 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. 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. +// Code generated by @autorest/go. DO NOT EDIT. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" + "net/http" + "net/url" + "regexp" +) + +// DetachTrafficFilterServer is a fake server for instances of the armelastic.DetachTrafficFilterClient type. +type DetachTrafficFilterServer struct { + // BeginUpdate is the fake for method DetachTrafficFilterClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusAccepted + BeginUpdate func(ctx context.Context, resourceGroupName string, monitorName string, options *armelastic.DetachTrafficFilterClientBeginUpdateOptions) (resp azfake.PollerResponder[armelastic.DetachTrafficFilterClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewDetachTrafficFilterServerTransport creates a new instance of DetachTrafficFilterServerTransport with the provided implementation. +// The returned DetachTrafficFilterServerTransport instance is connected to an instance of armelastic.DetachTrafficFilterClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewDetachTrafficFilterServerTransport(srv *DetachTrafficFilterServer) *DetachTrafficFilterServerTransport { + return &DetachTrafficFilterServerTransport{ + srv: srv, + beginUpdate: newTracker[azfake.PollerResponder[armelastic.DetachTrafficFilterClientUpdateResponse]](), + } +} + +// DetachTrafficFilterServerTransport connects instances of armelastic.DetachTrafficFilterClient to instances of DetachTrafficFilterServer. +// Don't use this type directly, use NewDetachTrafficFilterServerTransport instead. +type DetachTrafficFilterServerTransport struct { + srv *DetachTrafficFilterServer + beginUpdate *tracker[azfake.PollerResponder[armelastic.DetachTrafficFilterClientUpdateResponse]] +} + +// Do implements the policy.Transporter interface for DetachTrafficFilterServerTransport. +func (d *DetachTrafficFilterServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "DetachTrafficFilterClient.BeginUpdate": + resp, err = d.dispatchBeginUpdate(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (d *DetachTrafficFilterServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if d.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} + } + beginUpdate := d.beginUpdate.get(req) + if beginUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Elastic/monitors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/detachTrafficFilter` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + monitorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("monitorName")]) + if err != nil { + return nil, err + } + rulesetIDUnescaped, err := url.QueryUnescape(qp.Get("rulesetId")) + if err != nil { + return nil, err + } + rulesetIDParam := getOptional(rulesetIDUnescaped) + var options *armelastic.DetachTrafficFilterClientBeginUpdateOptions + if rulesetIDParam != nil { + options = &armelastic.DetachTrafficFilterClientBeginUpdateOptions{ + RulesetID: rulesetIDParam, + } + } + respr, errRespr := d.srv.BeginUpdate(req.Context(), resourceGroupNameParam, monitorNameParam, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdate = &respr + d.beginUpdate.add(req, beginUpdate) + } + + resp, err := server.PollerResponderNext(beginUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusAccepted}, resp.StatusCode) { + d.beginUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginUpdate) { + d.beginUpdate.remove(req) + } + + return resp, nil +} diff --git a/sdk/resourcemanager/elastic/armelastic/fake/externaluser_server.go b/sdk/resourcemanager/elastic/armelastic/fake/externaluser_server.go new file mode 100644 index 000000000000..a609380b1959 --- /dev/null +++ b/sdk/resourcemanager/elastic/armelastic/fake/externaluser_server.go @@ -0,0 +1,120 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. 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. +// Code generated by @autorest/go. DO NOT EDIT. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" + "net/http" + "net/url" + "reflect" + "regexp" +) + +// ExternalUserServer is a fake server for instances of the armelastic.ExternalUserClient type. +type ExternalUserServer struct { + // CreateOrUpdate is the fake for method ExternalUserClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK + CreateOrUpdate func(ctx context.Context, resourceGroupName string, monitorName string, options *armelastic.ExternalUserClientCreateOrUpdateOptions) (resp azfake.Responder[armelastic.ExternalUserClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewExternalUserServerTransport creates a new instance of ExternalUserServerTransport with the provided implementation. +// The returned ExternalUserServerTransport instance is connected to an instance of armelastic.ExternalUserClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewExternalUserServerTransport(srv *ExternalUserServer) *ExternalUserServerTransport { + return &ExternalUserServerTransport{srv: srv} +} + +// ExternalUserServerTransport connects instances of armelastic.ExternalUserClient to instances of ExternalUserServer. +// Don't use this type directly, use NewExternalUserServerTransport instead. +type ExternalUserServerTransport struct { + srv *ExternalUserServer +} + +// Do implements the policy.Transporter interface for ExternalUserServerTransport. +func (e *ExternalUserServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "ExternalUserClient.CreateOrUpdate": + resp, err = e.dispatchCreateOrUpdate(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (e *ExternalUserServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if e.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Elastic/monitors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/createOrUpdateExternalUser` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armelastic.ExternalUserInfo](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + monitorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("monitorName")]) + if err != nil { + return nil, err + } + var options *armelastic.ExternalUserClientCreateOrUpdateOptions + if !reflect.ValueOf(body).IsZero() { + options = &armelastic.ExternalUserClientCreateOrUpdateOptions{ + Body: &body, + } + } + respr, errRespr := e.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, monitorNameParam, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ExternalUserCreationResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/elastic/armelastic/fake/internal.go b/sdk/resourcemanager/elastic/armelastic/fake/internal.go new file mode 100644 index 000000000000..69a6dd16b023 --- /dev/null +++ b/sdk/resourcemanager/elastic/armelastic/fake/internal.go @@ -0,0 +1,81 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. 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. +// Code generated by @autorest/go. DO NOT EDIT. + +package fake + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "net/http" + "reflect" + "sync" +) + +type nonRetriableError struct { + error +} + +func (nonRetriableError) NonRetriable() { + // marker method +} + +func contains[T comparable](s []T, v T) bool { + for _, vv := range s { + if vv == v { + return true + } + } + return false +} + +func getOptional[T any](v T) *T { + if reflect.ValueOf(v).IsZero() { + return nil + } + return &v +} + +func newTracker[T any]() *tracker[T] { + return &tracker[T]{ + items: map[string]*T{}, + } +} + +type tracker[T any] struct { + items map[string]*T + mu sync.Mutex +} + +func (p *tracker[T]) get(req *http.Request) *T { + p.mu.Lock() + defer p.mu.Unlock() + if item, ok := p.items[server.SanitizePagerPollerPath(req.URL.Path)]; ok { + return item + } + return nil +} + +func (p *tracker[T]) add(req *http.Request, item *T) { + p.mu.Lock() + defer p.mu.Unlock() + p.items[server.SanitizePagerPollerPath(req.URL.Path)] = item +} + +func (p *tracker[T]) remove(req *http.Request) { + p.mu.Lock() + defer p.mu.Unlock() + delete(p.items, server.SanitizePagerPollerPath(req.URL.Path)) +} diff --git a/sdk/resourcemanager/elastic/armelastic/fake/listassociatedtrafficfilters_server.go b/sdk/resourcemanager/elastic/armelastic/fake/listassociatedtrafficfilters_server.go new file mode 100644 index 000000000000..4c122d240449 --- /dev/null +++ b/sdk/resourcemanager/elastic/armelastic/fake/listassociatedtrafficfilters_server.go @@ -0,0 +1,109 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. 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. +// Code generated by @autorest/go. DO NOT EDIT. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" + "net/http" + "net/url" + "regexp" +) + +// ListAssociatedTrafficFiltersServer is a fake server for instances of the armelastic.ListAssociatedTrafficFiltersClient type. +type ListAssociatedTrafficFiltersServer struct { + // List is the fake for method ListAssociatedTrafficFiltersClient.List + // HTTP status codes to indicate success: http.StatusOK + List func(ctx context.Context, resourceGroupName string, monitorName string, options *armelastic.ListAssociatedTrafficFiltersClientListOptions) (resp azfake.Responder[armelastic.ListAssociatedTrafficFiltersClientListResponse], errResp azfake.ErrorResponder) +} + +// NewListAssociatedTrafficFiltersServerTransport creates a new instance of ListAssociatedTrafficFiltersServerTransport with the provided implementation. +// The returned ListAssociatedTrafficFiltersServerTransport instance is connected to an instance of armelastic.ListAssociatedTrafficFiltersClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewListAssociatedTrafficFiltersServerTransport(srv *ListAssociatedTrafficFiltersServer) *ListAssociatedTrafficFiltersServerTransport { + return &ListAssociatedTrafficFiltersServerTransport{srv: srv} +} + +// ListAssociatedTrafficFiltersServerTransport connects instances of armelastic.ListAssociatedTrafficFiltersClient to instances of ListAssociatedTrafficFiltersServer. +// Don't use this type directly, use NewListAssociatedTrafficFiltersServerTransport instead. +type ListAssociatedTrafficFiltersServerTransport struct { + srv *ListAssociatedTrafficFiltersServer +} + +// Do implements the policy.Transporter interface for ListAssociatedTrafficFiltersServerTransport. +func (l *ListAssociatedTrafficFiltersServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "ListAssociatedTrafficFiltersClient.List": + resp, err = l.dispatchList(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (l *ListAssociatedTrafficFiltersServerTransport) dispatchList(req *http.Request) (*http.Response, error) { + if l.srv.List == nil { + return nil, &nonRetriableError{errors.New("fake for method List not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Elastic/monitors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listAssociatedTrafficFilters` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + monitorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("monitorName")]) + if err != nil { + return nil, err + } + respr, errRespr := l.srv.List(req.Context(), resourceGroupNameParam, monitorNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).TrafficFilterResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/elastic/armelastic/fake/monitor_server.go b/sdk/resourcemanager/elastic/armelastic/fake/monitor_server.go new file mode 100644 index 000000000000..fb88b4f56c80 --- /dev/null +++ b/sdk/resourcemanager/elastic/armelastic/fake/monitor_server.go @@ -0,0 +1,135 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. 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. +// Code generated by @autorest/go. DO NOT EDIT. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" + "net/http" + "net/url" + "reflect" + "regexp" +) + +// MonitorServer is a fake server for instances of the armelastic.MonitorClient type. +type MonitorServer struct { + // BeginUpgrade is the fake for method MonitorClient.BeginUpgrade + // HTTP status codes to indicate success: http.StatusAccepted + BeginUpgrade func(ctx context.Context, resourceGroupName string, monitorName string, options *armelastic.MonitorClientBeginUpgradeOptions) (resp azfake.PollerResponder[armelastic.MonitorClientUpgradeResponse], errResp azfake.ErrorResponder) +} + +// NewMonitorServerTransport creates a new instance of MonitorServerTransport with the provided implementation. +// The returned MonitorServerTransport instance is connected to an instance of armelastic.MonitorClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewMonitorServerTransport(srv *MonitorServer) *MonitorServerTransport { + return &MonitorServerTransport{ + srv: srv, + beginUpgrade: newTracker[azfake.PollerResponder[armelastic.MonitorClientUpgradeResponse]](), + } +} + +// MonitorServerTransport connects instances of armelastic.MonitorClient to instances of MonitorServer. +// Don't use this type directly, use NewMonitorServerTransport instead. +type MonitorServerTransport struct { + srv *MonitorServer + beginUpgrade *tracker[azfake.PollerResponder[armelastic.MonitorClientUpgradeResponse]] +} + +// Do implements the policy.Transporter interface for MonitorServerTransport. +func (m *MonitorServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "MonitorClient.BeginUpgrade": + resp, err = m.dispatchBeginUpgrade(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (m *MonitorServerTransport) dispatchBeginUpgrade(req *http.Request) (*http.Response, error) { + if m.srv.BeginUpgrade == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpgrade not implemented")} + } + beginUpgrade := m.beginUpgrade.get(req) + if beginUpgrade == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Elastic/monitors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/upgrade` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armelastic.MonitorUpgrade](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + monitorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("monitorName")]) + if err != nil { + return nil, err + } + var options *armelastic.MonitorClientBeginUpgradeOptions + if !reflect.ValueOf(body).IsZero() { + options = &armelastic.MonitorClientBeginUpgradeOptions{ + Body: &body, + } + } + respr, errRespr := m.srv.BeginUpgrade(req.Context(), resourceGroupNameParam, monitorNameParam, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpgrade = &respr + m.beginUpgrade.add(req, beginUpgrade) + } + + resp, err := server.PollerResponderNext(beginUpgrade, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusAccepted}, resp.StatusCode) { + m.beginUpgrade.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginUpgrade) { + m.beginUpgrade.remove(req) + } + + return resp, nil +} diff --git a/sdk/resourcemanager/elastic/armelastic/fake/monitoredresources_server.go b/sdk/resourcemanager/elastic/armelastic/fake/monitoredresources_server.go new file mode 100644 index 000000000000..0b2f5d6268c2 --- /dev/null +++ b/sdk/resourcemanager/elastic/armelastic/fake/monitoredresources_server.go @@ -0,0 +1,121 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. 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. +// Code generated by @autorest/go. DO NOT EDIT. + +package fake + +import ( + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" + "net/http" + "net/url" + "regexp" +) + +// MonitoredResourcesServer is a fake server for instances of the armelastic.MonitoredResourcesClient type. +type MonitoredResourcesServer struct { + // NewListPager is the fake for method MonitoredResourcesClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, monitorName string, options *armelastic.MonitoredResourcesClientListOptions) (resp azfake.PagerResponder[armelastic.MonitoredResourcesClientListResponse]) +} + +// NewMonitoredResourcesServerTransport creates a new instance of MonitoredResourcesServerTransport with the provided implementation. +// The returned MonitoredResourcesServerTransport instance is connected to an instance of armelastic.MonitoredResourcesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewMonitoredResourcesServerTransport(srv *MonitoredResourcesServer) *MonitoredResourcesServerTransport { + return &MonitoredResourcesServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armelastic.MonitoredResourcesClientListResponse]](), + } +} + +// MonitoredResourcesServerTransport connects instances of armelastic.MonitoredResourcesClient to instances of MonitoredResourcesServer. +// Don't use this type directly, use NewMonitoredResourcesServerTransport instead. +type MonitoredResourcesServerTransport struct { + srv *MonitoredResourcesServer + newListPager *tracker[azfake.PagerResponder[armelastic.MonitoredResourcesClientListResponse]] +} + +// Do implements the policy.Transporter interface for MonitoredResourcesServerTransport. +func (m *MonitoredResourcesServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "MonitoredResourcesClient.NewListPager": + resp, err = m.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (m *MonitoredResourcesServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if m.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := m.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Elastic/monitors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listMonitoredResources` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + monitorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("monitorName")]) + if err != nil { + return nil, err + } + resp := m.srv.NewListPager(resourceGroupNameParam, monitorNameParam, nil) + newListPager = &resp + m.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armelastic.MonitoredResourcesClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + m.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + m.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/elastic/armelastic/fake/monitors_server.go b/sdk/resourcemanager/elastic/armelastic/fake/monitors_server.go new file mode 100644 index 000000000000..1f6084995781 --- /dev/null +++ b/sdk/resourcemanager/elastic/armelastic/fake/monitors_server.go @@ -0,0 +1,362 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. 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. +// Code generated by @autorest/go. DO NOT EDIT. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" + "net/http" + "net/url" + "reflect" + "regexp" +) + +// MonitorsServer is a fake server for instances of the armelastic.MonitorsClient type. +type MonitorsServer struct { + // BeginCreate is the fake for method MonitorsClient.BeginCreate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreate func(ctx context.Context, resourceGroupName string, monitorName string, options *armelastic.MonitorsClientBeginCreateOptions) (resp azfake.PollerResponder[armelastic.MonitorsClientCreateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method MonitorsClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, monitorName string, options *armelastic.MonitorsClientBeginDeleteOptions) (resp azfake.PollerResponder[armelastic.MonitorsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method MonitorsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, monitorName string, options *armelastic.MonitorsClientGetOptions) (resp azfake.Responder[armelastic.MonitorsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method MonitorsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(options *armelastic.MonitorsClientListOptions) (resp azfake.PagerResponder[armelastic.MonitorsClientListResponse]) + + // NewListByResourceGroupPager is the fake for method MonitorsClient.NewListByResourceGroupPager + // HTTP status codes to indicate success: http.StatusOK + NewListByResourceGroupPager func(resourceGroupName string, options *armelastic.MonitorsClientListByResourceGroupOptions) (resp azfake.PagerResponder[armelastic.MonitorsClientListByResourceGroupResponse]) + + // Update is the fake for method MonitorsClient.Update + // HTTP status codes to indicate success: http.StatusOK + Update func(ctx context.Context, resourceGroupName string, monitorName string, options *armelastic.MonitorsClientUpdateOptions) (resp azfake.Responder[armelastic.MonitorsClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewMonitorsServerTransport creates a new instance of MonitorsServerTransport with the provided implementation. +// The returned MonitorsServerTransport instance is connected to an instance of armelastic.MonitorsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewMonitorsServerTransport(srv *MonitorsServer) *MonitorsServerTransport { + return &MonitorsServerTransport{ + srv: srv, + beginCreate: newTracker[azfake.PollerResponder[armelastic.MonitorsClientCreateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armelastic.MonitorsClientDeleteResponse]](), + newListPager: newTracker[azfake.PagerResponder[armelastic.MonitorsClientListResponse]](), + newListByResourceGroupPager: newTracker[azfake.PagerResponder[armelastic.MonitorsClientListByResourceGroupResponse]](), + } +} + +// MonitorsServerTransport connects instances of armelastic.MonitorsClient to instances of MonitorsServer. +// Don't use this type directly, use NewMonitorsServerTransport instead. +type MonitorsServerTransport struct { + srv *MonitorsServer + beginCreate *tracker[azfake.PollerResponder[armelastic.MonitorsClientCreateResponse]] + beginDelete *tracker[azfake.PollerResponder[armelastic.MonitorsClientDeleteResponse]] + newListPager *tracker[azfake.PagerResponder[armelastic.MonitorsClientListResponse]] + newListByResourceGroupPager *tracker[azfake.PagerResponder[armelastic.MonitorsClientListByResourceGroupResponse]] +} + +// Do implements the policy.Transporter interface for MonitorsServerTransport. +func (m *MonitorsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "MonitorsClient.BeginCreate": + resp, err = m.dispatchBeginCreate(req) + case "MonitorsClient.BeginDelete": + resp, err = m.dispatchBeginDelete(req) + case "MonitorsClient.Get": + resp, err = m.dispatchGet(req) + case "MonitorsClient.NewListPager": + resp, err = m.dispatchNewListPager(req) + case "MonitorsClient.NewListByResourceGroupPager": + resp, err = m.dispatchNewListByResourceGroupPager(req) + case "MonitorsClient.Update": + resp, err = m.dispatchUpdate(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (m *MonitorsServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) { + if m.srv.BeginCreate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreate not implemented")} + } + beginCreate := m.beginCreate.get(req) + if beginCreate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Elastic/monitors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armelastic.MonitorResource](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + monitorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("monitorName")]) + if err != nil { + return nil, err + } + var options *armelastic.MonitorsClientBeginCreateOptions + if !reflect.ValueOf(body).IsZero() { + options = &armelastic.MonitorsClientBeginCreateOptions{ + Body: &body, + } + } + respr, errRespr := m.srv.BeginCreate(req.Context(), resourceGroupNameParam, monitorNameParam, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreate = &respr + m.beginCreate.add(req, beginCreate) + } + + resp, err := server.PollerResponderNext(beginCreate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + m.beginCreate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreate) { + m.beginCreate.remove(req) + } + + return resp, nil +} + +func (m *MonitorsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if m.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := m.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Elastic/monitors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + monitorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("monitorName")]) + if err != nil { + return nil, err + } + respr, errRespr := m.srv.BeginDelete(req.Context(), resourceGroupNameParam, monitorNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + m.beginDelete.add(req, beginDelete) + } + + resp, err := server.PollerResponderNext(beginDelete, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + m.beginDelete.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDelete) { + m.beginDelete.remove(req) + } + + return resp, nil +} + +func (m *MonitorsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if m.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Elastic/monitors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + monitorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("monitorName")]) + if err != nil { + return nil, err + } + respr, errRespr := m.srv.Get(req.Context(), resourceGroupNameParam, monitorNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).MonitorResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (m *MonitorsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if m.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := m.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Elastic/monitors` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resp := m.srv.NewListPager(nil) + newListPager = &resp + m.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armelastic.MonitorsClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + m.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + m.newListPager.remove(req) + } + return resp, nil +} + +func (m *MonitorsServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) { + if m.srv.NewListByResourceGroupPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByResourceGroupPager not implemented")} + } + newListByResourceGroupPager := m.newListByResourceGroupPager.get(req) + if newListByResourceGroupPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Elastic/monitors` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resp := m.srv.NewListByResourceGroupPager(resourceGroupNameParam, nil) + newListByResourceGroupPager = &resp + m.newListByResourceGroupPager.add(req, newListByResourceGroupPager) + server.PagerResponderInjectNextLinks(newListByResourceGroupPager, req, func(page *armelastic.MonitorsClientListByResourceGroupResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByResourceGroupPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + m.newListByResourceGroupPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByResourceGroupPager) { + m.newListByResourceGroupPager.remove(req) + } + return resp, nil +} + +func (m *MonitorsServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { + if m.srv.Update == nil { + return nil, &nonRetriableError{errors.New("fake for method Update not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Elastic/monitors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armelastic.MonitorResourceUpdateParameters](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + monitorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("monitorName")]) + if err != nil { + return nil, err + } + var options *armelastic.MonitorsClientUpdateOptions + if !reflect.ValueOf(body).IsZero() { + options = &armelastic.MonitorsClientUpdateOptions{ + Body: &body, + } + } + respr, errRespr := m.srv.Update(req.Context(), resourceGroupNameParam, monitorNameParam, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).MonitorResource, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/elastic/armelastic/fake/operations_server.go b/sdk/resourcemanager/elastic/armelastic/fake/operations_server.go new file mode 100644 index 000000000000..101294d9c04d --- /dev/null +++ b/sdk/resourcemanager/elastic/armelastic/fake/operations_server.go @@ -0,0 +1,105 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. 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. +// Code generated by @autorest/go. DO NOT EDIT. + +package fake + +import ( + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" + "net/http" +) + +// OperationsServer is a fake server for instances of the armelastic.OperationsClient type. +type OperationsServer struct { + // NewListPager is the fake for method OperationsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(options *armelastic.OperationsClientListOptions) (resp azfake.PagerResponder[armelastic.OperationsClientListResponse]) +} + +// NewOperationsServerTransport creates a new instance of OperationsServerTransport with the provided implementation. +// The returned OperationsServerTransport instance is connected to an instance of armelastic.OperationsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewOperationsServerTransport(srv *OperationsServer) *OperationsServerTransport { + return &OperationsServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armelastic.OperationsClientListResponse]](), + } +} + +// OperationsServerTransport connects instances of armelastic.OperationsClient to instances of OperationsServer. +// Don't use this type directly, use NewOperationsServerTransport instead. +type OperationsServerTransport struct { + srv *OperationsServer + newListPager *tracker[azfake.PagerResponder[armelastic.OperationsClientListResponse]] +} + +// Do implements the policy.Transporter interface for OperationsServerTransport. +func (o *OperationsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "OperationsClient.NewListPager": + resp, err = o.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if o.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := o.newListPager.get(req) + if newListPager == nil { + resp := o.srv.NewListPager(nil) + newListPager = &resp + o.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armelastic.OperationsClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + o.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + o.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/elastic/armelastic/fake/organizations_server.go b/sdk/resourcemanager/elastic/armelastic/fake/organizations_server.go new file mode 100644 index 000000000000..67b41ccaa4fe --- /dev/null +++ b/sdk/resourcemanager/elastic/armelastic/fake/organizations_server.go @@ -0,0 +1,142 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. 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. +// Code generated by @autorest/go. DO NOT EDIT. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" + "net/http" + "reflect" + "regexp" +) + +// OrganizationsServer is a fake server for instances of the armelastic.OrganizationsClient type. +type OrganizationsServer struct { + // GetAPIKey is the fake for method OrganizationsClient.GetAPIKey + // HTTP status codes to indicate success: http.StatusOK + GetAPIKey func(ctx context.Context, options *armelastic.OrganizationsClientGetAPIKeyOptions) (resp azfake.Responder[armelastic.OrganizationsClientGetAPIKeyResponse], errResp azfake.ErrorResponder) + + // GetElasticToAzureSubscriptionMapping is the fake for method OrganizationsClient.GetElasticToAzureSubscriptionMapping + // HTTP status codes to indicate success: http.StatusOK + GetElasticToAzureSubscriptionMapping func(ctx context.Context, options *armelastic.OrganizationsClientGetElasticToAzureSubscriptionMappingOptions) (resp azfake.Responder[armelastic.OrganizationsClientGetElasticToAzureSubscriptionMappingResponse], errResp azfake.ErrorResponder) +} + +// NewOrganizationsServerTransport creates a new instance of OrganizationsServerTransport with the provided implementation. +// The returned OrganizationsServerTransport instance is connected to an instance of armelastic.OrganizationsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewOrganizationsServerTransport(srv *OrganizationsServer) *OrganizationsServerTransport { + return &OrganizationsServerTransport{srv: srv} +} + +// OrganizationsServerTransport connects instances of armelastic.OrganizationsClient to instances of OrganizationsServer. +// Don't use this type directly, use NewOrganizationsServerTransport instead. +type OrganizationsServerTransport struct { + srv *OrganizationsServer +} + +// Do implements the policy.Transporter interface for OrganizationsServerTransport. +func (o *OrganizationsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "OrganizationsClient.GetAPIKey": + resp, err = o.dispatchGetAPIKey(req) + case "OrganizationsClient.GetElasticToAzureSubscriptionMapping": + resp, err = o.dispatchGetElasticToAzureSubscriptionMapping(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (o *OrganizationsServerTransport) dispatchGetAPIKey(req *http.Request) (*http.Response, error) { + if o.srv.GetAPIKey == nil { + return nil, &nonRetriableError{errors.New("fake for method GetAPIKey not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Elastic/getOrganizationApiKey` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armelastic.UserEmailID](req) + if err != nil { + return nil, err + } + var options *armelastic.OrganizationsClientGetAPIKeyOptions + if !reflect.ValueOf(body).IsZero() { + options = &armelastic.OrganizationsClientGetAPIKeyOptions{ + Body: &body, + } + } + respr, errRespr := o.srv.GetAPIKey(req.Context(), options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).UserAPIKeyResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (o *OrganizationsServerTransport) dispatchGetElasticToAzureSubscriptionMapping(req *http.Request) (*http.Response, error) { + if o.srv.GetElasticToAzureSubscriptionMapping == nil { + return nil, &nonRetriableError{errors.New("fake for method GetElasticToAzureSubscriptionMapping not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Elastic/getElasticOrganizationToAzureSubscriptionMapping` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := o.srv.GetElasticToAzureSubscriptionMapping(req.Context(), nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).OrganizationToAzureSubscriptionMappingResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/elastic/armelastic/fake/server_factory.go b/sdk/resourcemanager/elastic/armelastic/fake/server_factory.go new file mode 100644 index 000000000000..1656b2d5ede9 --- /dev/null +++ b/sdk/resourcemanager/elastic/armelastic/fake/server_factory.go @@ -0,0 +1,220 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. 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. +// Code generated by @autorest/go. DO NOT EDIT. + +package fake + +import ( + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "strings" + "sync" +) + +// ServerFactory is a fake server for instances of the armelastic.ClientFactory type. +type ServerFactory struct { + AllTrafficFiltersServer AllTrafficFiltersServer + AssociateTrafficFilterServer AssociateTrafficFilterServer + BillingInfoServer BillingInfoServer + ConnectedPartnerResourcesServer ConnectedPartnerResourcesServer + CreateAndAssociateIPFilterServer CreateAndAssociateIPFilterServer + CreateAndAssociatePLFilterServer CreateAndAssociatePLFilterServer + DeploymentInfoServer DeploymentInfoServer + DetachAndDeleteTrafficFilterServer DetachAndDeleteTrafficFilterServer + DetachTrafficFilterServer DetachTrafficFilterServer + ExternalUserServer ExternalUserServer + ListAssociatedTrafficFiltersServer ListAssociatedTrafficFiltersServer + MonitorServer MonitorServer + MonitoredResourcesServer MonitoredResourcesServer + MonitorsServer MonitorsServer + OperationsServer OperationsServer + OrganizationsServer OrganizationsServer + TagRulesServer TagRulesServer + TrafficFiltersServer TrafficFiltersServer + UpgradableVersionsServer UpgradableVersionsServer + VMCollectionServer VMCollectionServer + VMHostServer VMHostServer + VMIngestionServer VMIngestionServer + VersionsServer VersionsServer +} + +// NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. +// The returned ServerFactoryTransport instance is connected to an instance of armelastic.ClientFactory via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewServerFactoryTransport(srv *ServerFactory) *ServerFactoryTransport { + return &ServerFactoryTransport{ + srv: srv, + } +} + +// ServerFactoryTransport connects instances of armelastic.ClientFactory to instances of ServerFactory. +// Don't use this type directly, use NewServerFactoryTransport instead. +type ServerFactoryTransport struct { + srv *ServerFactory + trMu sync.Mutex + trAllTrafficFiltersServer *AllTrafficFiltersServerTransport + trAssociateTrafficFilterServer *AssociateTrafficFilterServerTransport + trBillingInfoServer *BillingInfoServerTransport + trConnectedPartnerResourcesServer *ConnectedPartnerResourcesServerTransport + trCreateAndAssociateIPFilterServer *CreateAndAssociateIPFilterServerTransport + trCreateAndAssociatePLFilterServer *CreateAndAssociatePLFilterServerTransport + trDeploymentInfoServer *DeploymentInfoServerTransport + trDetachAndDeleteTrafficFilterServer *DetachAndDeleteTrafficFilterServerTransport + trDetachTrafficFilterServer *DetachTrafficFilterServerTransport + trExternalUserServer *ExternalUserServerTransport + trListAssociatedTrafficFiltersServer *ListAssociatedTrafficFiltersServerTransport + trMonitorServer *MonitorServerTransport + trMonitoredResourcesServer *MonitoredResourcesServerTransport + trMonitorsServer *MonitorsServerTransport + trOperationsServer *OperationsServerTransport + trOrganizationsServer *OrganizationsServerTransport + trTagRulesServer *TagRulesServerTransport + trTrafficFiltersServer *TrafficFiltersServerTransport + trUpgradableVersionsServer *UpgradableVersionsServerTransport + trVMCollectionServer *VMCollectionServerTransport + trVMHostServer *VMHostServerTransport + trVMIngestionServer *VMIngestionServerTransport + trVersionsServer *VersionsServerTransport +} + +// Do implements the policy.Transporter interface for ServerFactoryTransport. +func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + client := method[:strings.Index(method, ".")] + var resp *http.Response + var err error + + switch client { + case "AllTrafficFiltersClient": + initServer(s, &s.trAllTrafficFiltersServer, func() *AllTrafficFiltersServerTransport { + return NewAllTrafficFiltersServerTransport(&s.srv.AllTrafficFiltersServer) + }) + resp, err = s.trAllTrafficFiltersServer.Do(req) + case "AssociateTrafficFilterClient": + initServer(s, &s.trAssociateTrafficFilterServer, func() *AssociateTrafficFilterServerTransport { + return NewAssociateTrafficFilterServerTransport(&s.srv.AssociateTrafficFilterServer) + }) + resp, err = s.trAssociateTrafficFilterServer.Do(req) + case "BillingInfoClient": + initServer(s, &s.trBillingInfoServer, func() *BillingInfoServerTransport { return NewBillingInfoServerTransport(&s.srv.BillingInfoServer) }) + resp, err = s.trBillingInfoServer.Do(req) + case "ConnectedPartnerResourcesClient": + initServer(s, &s.trConnectedPartnerResourcesServer, func() *ConnectedPartnerResourcesServerTransport { + return NewConnectedPartnerResourcesServerTransport(&s.srv.ConnectedPartnerResourcesServer) + }) + resp, err = s.trConnectedPartnerResourcesServer.Do(req) + case "CreateAndAssociateIPFilterClient": + initServer(s, &s.trCreateAndAssociateIPFilterServer, func() *CreateAndAssociateIPFilterServerTransport { + return NewCreateAndAssociateIPFilterServerTransport(&s.srv.CreateAndAssociateIPFilterServer) + }) + resp, err = s.trCreateAndAssociateIPFilterServer.Do(req) + case "CreateAndAssociatePLFilterClient": + initServer(s, &s.trCreateAndAssociatePLFilterServer, func() *CreateAndAssociatePLFilterServerTransport { + return NewCreateAndAssociatePLFilterServerTransport(&s.srv.CreateAndAssociatePLFilterServer) + }) + resp, err = s.trCreateAndAssociatePLFilterServer.Do(req) + case "DeploymentInfoClient": + initServer(s, &s.trDeploymentInfoServer, func() *DeploymentInfoServerTransport { + return NewDeploymentInfoServerTransport(&s.srv.DeploymentInfoServer) + }) + resp, err = s.trDeploymentInfoServer.Do(req) + case "DetachAndDeleteTrafficFilterClient": + initServer(s, &s.trDetachAndDeleteTrafficFilterServer, func() *DetachAndDeleteTrafficFilterServerTransport { + return NewDetachAndDeleteTrafficFilterServerTransport(&s.srv.DetachAndDeleteTrafficFilterServer) + }) + resp, err = s.trDetachAndDeleteTrafficFilterServer.Do(req) + case "DetachTrafficFilterClient": + initServer(s, &s.trDetachTrafficFilterServer, func() *DetachTrafficFilterServerTransport { + return NewDetachTrafficFilterServerTransport(&s.srv.DetachTrafficFilterServer) + }) + resp, err = s.trDetachTrafficFilterServer.Do(req) + case "ExternalUserClient": + initServer(s, &s.trExternalUserServer, func() *ExternalUserServerTransport { return NewExternalUserServerTransport(&s.srv.ExternalUserServer) }) + resp, err = s.trExternalUserServer.Do(req) + case "ListAssociatedTrafficFiltersClient": + initServer(s, &s.trListAssociatedTrafficFiltersServer, func() *ListAssociatedTrafficFiltersServerTransport { + return NewListAssociatedTrafficFiltersServerTransport(&s.srv.ListAssociatedTrafficFiltersServer) + }) + resp, err = s.trListAssociatedTrafficFiltersServer.Do(req) + case "MonitorClient": + initServer(s, &s.trMonitorServer, func() *MonitorServerTransport { return NewMonitorServerTransport(&s.srv.MonitorServer) }) + resp, err = s.trMonitorServer.Do(req) + case "MonitoredResourcesClient": + initServer(s, &s.trMonitoredResourcesServer, func() *MonitoredResourcesServerTransport { + return NewMonitoredResourcesServerTransport(&s.srv.MonitoredResourcesServer) + }) + resp, err = s.trMonitoredResourcesServer.Do(req) + case "MonitorsClient": + initServer(s, &s.trMonitorsServer, func() *MonitorsServerTransport { return NewMonitorsServerTransport(&s.srv.MonitorsServer) }) + resp, err = s.trMonitorsServer.Do(req) + case "OperationsClient": + initServer(s, &s.trOperationsServer, func() *OperationsServerTransport { return NewOperationsServerTransport(&s.srv.OperationsServer) }) + resp, err = s.trOperationsServer.Do(req) + case "OrganizationsClient": + initServer(s, &s.trOrganizationsServer, func() *OrganizationsServerTransport { + return NewOrganizationsServerTransport(&s.srv.OrganizationsServer) + }) + resp, err = s.trOrganizationsServer.Do(req) + case "TagRulesClient": + initServer(s, &s.trTagRulesServer, func() *TagRulesServerTransport { return NewTagRulesServerTransport(&s.srv.TagRulesServer) }) + resp, err = s.trTagRulesServer.Do(req) + case "TrafficFiltersClient": + initServer(s, &s.trTrafficFiltersServer, func() *TrafficFiltersServerTransport { + return NewTrafficFiltersServerTransport(&s.srv.TrafficFiltersServer) + }) + resp, err = s.trTrafficFiltersServer.Do(req) + case "UpgradableVersionsClient": + initServer(s, &s.trUpgradableVersionsServer, func() *UpgradableVersionsServerTransport { + return NewUpgradableVersionsServerTransport(&s.srv.UpgradableVersionsServer) + }) + resp, err = s.trUpgradableVersionsServer.Do(req) + case "VMCollectionClient": + initServer(s, &s.trVMCollectionServer, func() *VMCollectionServerTransport { return NewVMCollectionServerTransport(&s.srv.VMCollectionServer) }) + resp, err = s.trVMCollectionServer.Do(req) + case "VMHostClient": + initServer(s, &s.trVMHostServer, func() *VMHostServerTransport { return NewVMHostServerTransport(&s.srv.VMHostServer) }) + resp, err = s.trVMHostServer.Do(req) + case "VMIngestionClient": + initServer(s, &s.trVMIngestionServer, func() *VMIngestionServerTransport { return NewVMIngestionServerTransport(&s.srv.VMIngestionServer) }) + resp, err = s.trVMIngestionServer.Do(req) + case "VersionsClient": + initServer(s, &s.trVersionsServer, func() *VersionsServerTransport { return NewVersionsServerTransport(&s.srv.VersionsServer) }) + resp, err = s.trVersionsServer.Do(req) + default: + err = fmt.Errorf("unhandled client %s", client) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func initServer[T any](s *ServerFactoryTransport, dst **T, src func() *T) { + s.trMu.Lock() + if *dst == nil { + *dst = src() + } + s.trMu.Unlock() +} diff --git a/sdk/resourcemanager/elastic/armelastic/fake/tagrules_server.go b/sdk/resourcemanager/elastic/armelastic/fake/tagrules_server.go new file mode 100644 index 000000000000..a95d12dae0f1 --- /dev/null +++ b/sdk/resourcemanager/elastic/armelastic/fake/tagrules_server.go @@ -0,0 +1,275 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. 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. +// Code generated by @autorest/go. DO NOT EDIT. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" + "net/http" + "net/url" + "reflect" + "regexp" +) + +// TagRulesServer is a fake server for instances of the armelastic.TagRulesClient type. +type TagRulesServer struct { + // CreateOrUpdate is the fake for method TagRulesClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK + CreateOrUpdate func(ctx context.Context, resourceGroupName string, monitorName string, ruleSetName string, options *armelastic.TagRulesClientCreateOrUpdateOptions) (resp azfake.Responder[armelastic.TagRulesClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method TagRulesClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, monitorName string, ruleSetName string, options *armelastic.TagRulesClientBeginDeleteOptions) (resp azfake.PollerResponder[armelastic.TagRulesClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method TagRulesClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, monitorName string, ruleSetName string, options *armelastic.TagRulesClientGetOptions) (resp azfake.Responder[armelastic.TagRulesClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method TagRulesClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, monitorName string, options *armelastic.TagRulesClientListOptions) (resp azfake.PagerResponder[armelastic.TagRulesClientListResponse]) +} + +// NewTagRulesServerTransport creates a new instance of TagRulesServerTransport with the provided implementation. +// The returned TagRulesServerTransport instance is connected to an instance of armelastic.TagRulesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewTagRulesServerTransport(srv *TagRulesServer) *TagRulesServerTransport { + return &TagRulesServerTransport{ + srv: srv, + beginDelete: newTracker[azfake.PollerResponder[armelastic.TagRulesClientDeleteResponse]](), + newListPager: newTracker[azfake.PagerResponder[armelastic.TagRulesClientListResponse]](), + } +} + +// TagRulesServerTransport connects instances of armelastic.TagRulesClient to instances of TagRulesServer. +// Don't use this type directly, use NewTagRulesServerTransport instead. +type TagRulesServerTransport struct { + srv *TagRulesServer + beginDelete *tracker[azfake.PollerResponder[armelastic.TagRulesClientDeleteResponse]] + newListPager *tracker[azfake.PagerResponder[armelastic.TagRulesClientListResponse]] +} + +// Do implements the policy.Transporter interface for TagRulesServerTransport. +func (t *TagRulesServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "TagRulesClient.CreateOrUpdate": + resp, err = t.dispatchCreateOrUpdate(req) + case "TagRulesClient.BeginDelete": + resp, err = t.dispatchBeginDelete(req) + case "TagRulesClient.Get": + resp, err = t.dispatchGet(req) + case "TagRulesClient.NewListPager": + resp, err = t.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (t *TagRulesServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if t.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Elastic/monitors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tagRules/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armelastic.MonitoringTagRules](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + monitorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("monitorName")]) + if err != nil { + return nil, err + } + ruleSetNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("ruleSetName")]) + if err != nil { + return nil, err + } + var options *armelastic.TagRulesClientCreateOrUpdateOptions + if !reflect.ValueOf(body).IsZero() { + options = &armelastic.TagRulesClientCreateOrUpdateOptions{ + Body: &body, + } + } + respr, errRespr := t.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, monitorNameParam, ruleSetNameParam, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).MonitoringTagRules, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (t *TagRulesServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if t.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := t.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Elastic/monitors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tagRules/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + monitorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("monitorName")]) + if err != nil { + return nil, err + } + ruleSetNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("ruleSetName")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.BeginDelete(req.Context(), resourceGroupNameParam, monitorNameParam, ruleSetNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + t.beginDelete.add(req, beginDelete) + } + + resp, err := server.PollerResponderNext(beginDelete, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + t.beginDelete.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDelete) { + t.beginDelete.remove(req) + } + + return resp, nil +} + +func (t *TagRulesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if t.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Elastic/monitors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tagRules/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + monitorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("monitorName")]) + if err != nil { + return nil, err + } + ruleSetNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("ruleSetName")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.Get(req.Context(), resourceGroupNameParam, monitorNameParam, ruleSetNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).MonitoringTagRules, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (t *TagRulesServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if t.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := t.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Elastic/monitors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tagRules` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + monitorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("monitorName")]) + if err != nil { + return nil, err + } + resp := t.srv.NewListPager(resourceGroupNameParam, monitorNameParam, nil) + newListPager = &resp + t.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armelastic.TagRulesClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + t.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + t.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/elastic/armelastic/fake/time_rfc3339.go b/sdk/resourcemanager/elastic/armelastic/fake/time_rfc3339.go new file mode 100644 index 000000000000..02ac9f2d0900 --- /dev/null +++ b/sdk/resourcemanager/elastic/armelastic/fake/time_rfc3339.go @@ -0,0 +1,95 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. 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. +// Code generated by @autorest/go. DO NOT EDIT. + +package fake + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "regexp" + "strings" + "time" +) + +// Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. +var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) + +const ( + utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` + utcDateTime = "2006-01-02T15:04:05.999999999" + dateTimeJSON = `"` + time.RFC3339Nano + `"` +) + +type dateTimeRFC3339 time.Time + +func (t dateTimeRFC3339) MarshalJSON() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalJSON() +} + +func (t dateTimeRFC3339) MarshalText() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalText() +} + +func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { + layout := utcDateTimeJSON + if tzOffsetRegex.Match(data) { + layout = dateTimeJSON + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + layout := utcDateTime + if tzOffsetRegex.Match(data) { + layout = time.RFC3339Nano + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) Parse(layout, value string) error { + p, err := time.Parse(layout, strings.ToUpper(value)) + *t = dateTimeRFC3339(p) + return err +} + +func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { + if t == nil { + return + } else if azcore.IsNullValue(t) { + m[k] = nil + return + } else if reflect.ValueOf(t).IsNil() { + return + } + m[k] = (*dateTimeRFC3339)(t) +} + +func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { + if data == nil || strings.EqualFold(string(data), "null") { + return nil + } + var aux dateTimeRFC3339 + if err := json.Unmarshal(data, &aux); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + *t = (*time.Time)(&aux) + return nil +} diff --git a/sdk/resourcemanager/elastic/armelastic/fake/trafficfilters_server.go b/sdk/resourcemanager/elastic/armelastic/fake/trafficfilters_server.go new file mode 100644 index 000000000000..ebfa00cb7b5f --- /dev/null +++ b/sdk/resourcemanager/elastic/armelastic/fake/trafficfilters_server.go @@ -0,0 +1,121 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. 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. +// Code generated by @autorest/go. DO NOT EDIT. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" + "net/http" + "net/url" + "regexp" +) + +// TrafficFiltersServer is a fake server for instances of the armelastic.TrafficFiltersClient type. +type TrafficFiltersServer struct { + // Delete is the fake for method TrafficFiltersClient.Delete + // HTTP status codes to indicate success: http.StatusOK + Delete func(ctx context.Context, resourceGroupName string, monitorName string, options *armelastic.TrafficFiltersClientDeleteOptions) (resp azfake.Responder[armelastic.TrafficFiltersClientDeleteResponse], errResp azfake.ErrorResponder) +} + +// NewTrafficFiltersServerTransport creates a new instance of TrafficFiltersServerTransport with the provided implementation. +// The returned TrafficFiltersServerTransport instance is connected to an instance of armelastic.TrafficFiltersClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewTrafficFiltersServerTransport(srv *TrafficFiltersServer) *TrafficFiltersServerTransport { + return &TrafficFiltersServerTransport{srv: srv} +} + +// TrafficFiltersServerTransport connects instances of armelastic.TrafficFiltersClient to instances of TrafficFiltersServer. +// Don't use this type directly, use NewTrafficFiltersServerTransport instead. +type TrafficFiltersServerTransport struct { + srv *TrafficFiltersServer +} + +// Do implements the policy.Transporter interface for TrafficFiltersServerTransport. +func (t *TrafficFiltersServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "TrafficFiltersClient.Delete": + resp, err = t.dispatchDelete(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (t *TrafficFiltersServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if t.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Elastic/monitors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/deleteTrafficFilter` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + monitorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("monitorName")]) + if err != nil { + return nil, err + } + rulesetIDUnescaped, err := url.QueryUnescape(qp.Get("rulesetId")) + if err != nil { + return nil, err + } + rulesetIDParam := getOptional(rulesetIDUnescaped) + var options *armelastic.TrafficFiltersClientDeleteOptions + if rulesetIDParam != nil { + options = &armelastic.TrafficFiltersClientDeleteOptions{ + RulesetID: rulesetIDParam, + } + } + respr, errRespr := t.srv.Delete(req.Context(), resourceGroupNameParam, monitorNameParam, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/elastic/armelastic/fake/upgradableversions_server.go b/sdk/resourcemanager/elastic/armelastic/fake/upgradableversions_server.go new file mode 100644 index 000000000000..7d0972022b9d --- /dev/null +++ b/sdk/resourcemanager/elastic/armelastic/fake/upgradableversions_server.go @@ -0,0 +1,109 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. 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. +// Code generated by @autorest/go. DO NOT EDIT. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" + "net/http" + "net/url" + "regexp" +) + +// UpgradableVersionsServer is a fake server for instances of the armelastic.UpgradableVersionsClient type. +type UpgradableVersionsServer struct { + // Details is the fake for method UpgradableVersionsClient.Details + // HTTP status codes to indicate success: http.StatusOK + Details func(ctx context.Context, resourceGroupName string, monitorName string, options *armelastic.UpgradableVersionsClientDetailsOptions) (resp azfake.Responder[armelastic.UpgradableVersionsClientDetailsResponse], errResp azfake.ErrorResponder) +} + +// NewUpgradableVersionsServerTransport creates a new instance of UpgradableVersionsServerTransport with the provided implementation. +// The returned UpgradableVersionsServerTransport instance is connected to an instance of armelastic.UpgradableVersionsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewUpgradableVersionsServerTransport(srv *UpgradableVersionsServer) *UpgradableVersionsServerTransport { + return &UpgradableVersionsServerTransport{srv: srv} +} + +// UpgradableVersionsServerTransport connects instances of armelastic.UpgradableVersionsClient to instances of UpgradableVersionsServer. +// Don't use this type directly, use NewUpgradableVersionsServerTransport instead. +type UpgradableVersionsServerTransport struct { + srv *UpgradableVersionsServer +} + +// Do implements the policy.Transporter interface for UpgradableVersionsServerTransport. +func (u *UpgradableVersionsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "UpgradableVersionsClient.Details": + resp, err = u.dispatchDetails(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (u *UpgradableVersionsServerTransport) dispatchDetails(req *http.Request) (*http.Response, error) { + if u.srv.Details == nil { + return nil, &nonRetriableError{errors.New("fake for method Details not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Elastic/monitors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listUpgradableVersions` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + monitorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("monitorName")]) + if err != nil { + return nil, err + } + respr, errRespr := u.srv.Details(req.Context(), resourceGroupNameParam, monitorNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).UpgradableVersionsList, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/elastic/armelastic/fake/versions_server.go b/sdk/resourcemanager/elastic/armelastic/fake/versions_server.go new file mode 100644 index 000000000000..e19d30b263d2 --- /dev/null +++ b/sdk/resourcemanager/elastic/armelastic/fake/versions_server.go @@ -0,0 +1,118 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. 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. +// Code generated by @autorest/go. DO NOT EDIT. + +package fake + +import ( + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" + "net/http" + "net/url" + "regexp" +) + +// VersionsServer is a fake server for instances of the armelastic.VersionsClient type. +type VersionsServer struct { + // NewListPager is the fake for method VersionsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(region string, options *armelastic.VersionsClientListOptions) (resp azfake.PagerResponder[armelastic.VersionsClientListResponse]) +} + +// NewVersionsServerTransport creates a new instance of VersionsServerTransport with the provided implementation. +// The returned VersionsServerTransport instance is connected to an instance of armelastic.VersionsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewVersionsServerTransport(srv *VersionsServer) *VersionsServerTransport { + return &VersionsServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armelastic.VersionsClientListResponse]](), + } +} + +// VersionsServerTransport connects instances of armelastic.VersionsClient to instances of VersionsServer. +// Don't use this type directly, use NewVersionsServerTransport instead. +type VersionsServerTransport struct { + srv *VersionsServer + newListPager *tracker[azfake.PagerResponder[armelastic.VersionsClientListResponse]] +} + +// Do implements the policy.Transporter interface for VersionsServerTransport. +func (v *VersionsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "VersionsClient.NewListPager": + resp, err = v.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (v *VersionsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if v.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := v.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Elastic/elasticVersions` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + regionParam, err := url.QueryUnescape(qp.Get("region")) + if err != nil { + return nil, err + } + resp := v.srv.NewListPager(regionParam, nil) + newListPager = &resp + v.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armelastic.VersionsClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + v.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + v.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/elastic/armelastic/fake/vmcollection_server.go b/sdk/resourcemanager/elastic/armelastic/fake/vmcollection_server.go new file mode 100644 index 000000000000..a268055f996b --- /dev/null +++ b/sdk/resourcemanager/elastic/armelastic/fake/vmcollection_server.go @@ -0,0 +1,120 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. 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. +// Code generated by @autorest/go. DO NOT EDIT. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" + "net/http" + "net/url" + "reflect" + "regexp" +) + +// VMCollectionServer is a fake server for instances of the armelastic.VMCollectionClient type. +type VMCollectionServer struct { + // Update is the fake for method VMCollectionClient.Update + // HTTP status codes to indicate success: http.StatusOK + Update func(ctx context.Context, resourceGroupName string, monitorName string, options *armelastic.VMCollectionClientUpdateOptions) (resp azfake.Responder[armelastic.VMCollectionClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewVMCollectionServerTransport creates a new instance of VMCollectionServerTransport with the provided implementation. +// The returned VMCollectionServerTransport instance is connected to an instance of armelastic.VMCollectionClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewVMCollectionServerTransport(srv *VMCollectionServer) *VMCollectionServerTransport { + return &VMCollectionServerTransport{srv: srv} +} + +// VMCollectionServerTransport connects instances of armelastic.VMCollectionClient to instances of VMCollectionServer. +// Don't use this type directly, use NewVMCollectionServerTransport instead. +type VMCollectionServerTransport struct { + srv *VMCollectionServer +} + +// Do implements the policy.Transporter interface for VMCollectionServerTransport. +func (v *VMCollectionServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "VMCollectionClient.Update": + resp, err = v.dispatchUpdate(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (v *VMCollectionServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { + if v.srv.Update == nil { + return nil, &nonRetriableError{errors.New("fake for method Update not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Elastic/monitors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/vmCollectionUpdate` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armelastic.VMCollectionUpdate](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + monitorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("monitorName")]) + if err != nil { + return nil, err + } + var options *armelastic.VMCollectionClientUpdateOptions + if !reflect.ValueOf(body).IsZero() { + options = &armelastic.VMCollectionClientUpdateOptions{ + Body: &body, + } + } + respr, errRespr := v.srv.Update(req.Context(), resourceGroupNameParam, monitorNameParam, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/elastic/armelastic/fake/vmhost_server.go b/sdk/resourcemanager/elastic/armelastic/fake/vmhost_server.go new file mode 100644 index 000000000000..2b87a7c3e0b2 --- /dev/null +++ b/sdk/resourcemanager/elastic/armelastic/fake/vmhost_server.go @@ -0,0 +1,121 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. 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. +// Code generated by @autorest/go. DO NOT EDIT. + +package fake + +import ( + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" + "net/http" + "net/url" + "regexp" +) + +// VMHostServer is a fake server for instances of the armelastic.VMHostClient type. +type VMHostServer struct { + // NewListPager is the fake for method VMHostClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, monitorName string, options *armelastic.VMHostClientListOptions) (resp azfake.PagerResponder[armelastic.VMHostClientListResponse]) +} + +// NewVMHostServerTransport creates a new instance of VMHostServerTransport with the provided implementation. +// The returned VMHostServerTransport instance is connected to an instance of armelastic.VMHostClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewVMHostServerTransport(srv *VMHostServer) *VMHostServerTransport { + return &VMHostServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armelastic.VMHostClientListResponse]](), + } +} + +// VMHostServerTransport connects instances of armelastic.VMHostClient to instances of VMHostServer. +// Don't use this type directly, use NewVMHostServerTransport instead. +type VMHostServerTransport struct { + srv *VMHostServer + newListPager *tracker[azfake.PagerResponder[armelastic.VMHostClientListResponse]] +} + +// Do implements the policy.Transporter interface for VMHostServerTransport. +func (v *VMHostServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "VMHostClient.NewListPager": + resp, err = v.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (v *VMHostServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if v.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := v.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Elastic/monitors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listVMHost` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + monitorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("monitorName")]) + if err != nil { + return nil, err + } + resp := v.srv.NewListPager(resourceGroupNameParam, monitorNameParam, nil) + newListPager = &resp + v.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armelastic.VMHostClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + v.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + v.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/elastic/armelastic/fake/vmingestion_server.go b/sdk/resourcemanager/elastic/armelastic/fake/vmingestion_server.go new file mode 100644 index 000000000000..38635ba26664 --- /dev/null +++ b/sdk/resourcemanager/elastic/armelastic/fake/vmingestion_server.go @@ -0,0 +1,109 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. 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. +// Code generated by @autorest/go. DO NOT EDIT. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" + "net/http" + "net/url" + "regexp" +) + +// VMIngestionServer is a fake server for instances of the armelastic.VMIngestionClient type. +type VMIngestionServer struct { + // Details is the fake for method VMIngestionClient.Details + // HTTP status codes to indicate success: http.StatusOK + Details func(ctx context.Context, resourceGroupName string, monitorName string, options *armelastic.VMIngestionClientDetailsOptions) (resp azfake.Responder[armelastic.VMIngestionClientDetailsResponse], errResp azfake.ErrorResponder) +} + +// NewVMIngestionServerTransport creates a new instance of VMIngestionServerTransport with the provided implementation. +// The returned VMIngestionServerTransport instance is connected to an instance of armelastic.VMIngestionClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewVMIngestionServerTransport(srv *VMIngestionServer) *VMIngestionServerTransport { + return &VMIngestionServerTransport{srv: srv} +} + +// VMIngestionServerTransport connects instances of armelastic.VMIngestionClient to instances of VMIngestionServer. +// Don't use this type directly, use NewVMIngestionServerTransport instead. +type VMIngestionServerTransport struct { + srv *VMIngestionServer +} + +// Do implements the policy.Transporter interface for VMIngestionServerTransport. +func (v *VMIngestionServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "VMIngestionClient.Details": + resp, err = v.dispatchDetails(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (v *VMIngestionServerTransport) dispatchDetails(req *http.Request) (*http.Response, error) { + if v.srv.Details == nil { + return nil, &nonRetriableError{errors.New("fake for method Details not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Elastic/monitors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/vmIngestionDetails` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + monitorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("monitorName")]) + if err != nil { + return nil, err + } + respr, errRespr := v.srv.Details(req.Context(), resourceGroupNameParam, monitorNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).VMIngestionDetailsResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/elastic/armelastic/go.mod b/sdk/resourcemanager/elastic/armelastic/go.mod index 05892e3009d6..864f1d72fc36 100644 --- a/sdk/resourcemanager/elastic/armelastic/go.mod +++ b/sdk/resourcemanager/elastic/armelastic/go.mod @@ -2,20 +2,10 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic go 1.18 -require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0 -) +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0 require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0 // indirect - github.com/golang-jwt/jwt/v4 v4.5.0 // indirect - github.com/google/uuid v1.3.0 // indirect - github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect - golang.org/x/crypto v0.7.0 // indirect - golang.org/x/net v0.8.0 // indirect - golang.org/x/sys v0.6.0 // indirect - golang.org/x/text v0.8.0 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0 // indirect + golang.org/x/net v0.17.0 // indirect + golang.org/x/text v0.13.0 // indirect ) diff --git a/sdk/resourcemanager/elastic/armelastic/go.sum b/sdk/resourcemanager/elastic/armelastic/go.sum index 21718b486698..428cd71de305 100644 --- a/sdk/resourcemanager/elastic/armelastic/go.sum +++ b/sdk/resourcemanager/elastic/armelastic/go.sum @@ -1,31 +1,12 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.0 h1:8kDqDngH+DmVBiCtIjCFTGa7MBnsIOkF9IccInFEbjk= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.0/go.mod h1:bjGvMhVMb+EEm3VRNQawDMUyMMjo+S5ewNjflkep/0Q= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0 h1:vcYCAze6p19qBW7MhZybIsqD8sMV8js0NyQM8JDnVtg= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0/go.mod h1:OQeznEEkTZ9OrhHJoDD8ZDq51FHgXjqtP9z6bEwBq9U= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 h1:sXr+ck84g/ZlZUOZiNELInmMgOsuGwdjjVkEIde0OtY= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0/go.mod h1:okt5dMMTOFjX/aovMlrjvvXoPMBVSPzk9185BT0+eZM= -github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0 h1:OBhqkivkhkMqLPymWEppkm7vgPQY2XsHoEkaMQ0AdZY= -github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0 h1:fb8kj/Dh4CSwgsOzHeZY4Xh68cFVbzXx+ONXGMY//4w= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0/go.mod h1:uReU2sSxZExRPBAg3qKzmAucSi51+SP1OhohieR821Q= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0 h1:d81/ng9rET2YqdVkVwkb6EXeRrLJIwyGnJcAlAWKwhs= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0/go.mod h1:s4kgfzA0covAXNicZHDMN58jExvcng2mC/DepXiF1EI= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI= -github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= -github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= -github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= -github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A= -golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= -golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= -golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= -golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= -golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= +golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= +golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/sdk/resourcemanager/elastic/armelastic/listassociatedtrafficfilters_client.go b/sdk/resourcemanager/elastic/armelastic/listassociatedtrafficfilters_client.go index fc2322f6d68e..a30484ba87e2 100644 --- a/sdk/resourcemanager/elastic/armelastic/listassociatedtrafficfilters_client.go +++ b/sdk/resourcemanager/elastic/armelastic/listassociatedtrafficfilters_client.go @@ -13,7 +13,7 @@ // 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. -// DO NOT EDIT. +// Code generated by @autorest/go. DO NOT EDIT. package armelastic @@ -37,11 +37,11 @@ type ListAssociatedTrafficFiltersClient struct { } // NewListAssociatedTrafficFiltersClient creates a new instance of ListAssociatedTrafficFiltersClient with the specified values. -// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewListAssociatedTrafficFiltersClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ListAssociatedTrafficFiltersClient, error) { - cl, err := arm.NewClient(moduleName+".ListAssociatedTrafficFiltersClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -55,24 +55,31 @@ func NewListAssociatedTrafficFiltersClient(subscriptionID string, credential azc // List - Get the list of all associated traffic filters for the given deployment. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-02-01-preview -// - resourceGroupName - The name of the resource group to which the Elastic resource belongs. +// Generated from API version 2023-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - monitorName - Monitor resource name // - options - ListAssociatedTrafficFiltersClientListOptions contains the optional parameters for the ListAssociatedTrafficFiltersClient.List // method. func (client *ListAssociatedTrafficFiltersClient) List(ctx context.Context, resourceGroupName string, monitorName string, options *ListAssociatedTrafficFiltersClientListOptions) (ListAssociatedTrafficFiltersClientListResponse, error) { + var err error + const operationName = "ListAssociatedTrafficFiltersClient.List" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.listCreateRequest(ctx, resourceGroupName, monitorName, options) if err != nil { return ListAssociatedTrafficFiltersClientListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ListAssociatedTrafficFiltersClientListResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ListAssociatedTrafficFiltersClientListResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ListAssociatedTrafficFiltersClientListResponse{}, err } - return client.listHandleResponse(resp) + resp, err := client.listHandleResponse(httpResp) + return resp, err } // listCreateRequest creates the List request. @@ -95,7 +102,7 @@ func (client *ListAssociatedTrafficFiltersClient) listCreateRequest(ctx context. return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-02-01-preview") + reqQP.Set("api-version", "2023-11-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/elastic/armelastic/listassociatedtrafficfilters_client_example_test.go b/sdk/resourcemanager/elastic/armelastic/listassociatedtrafficfilters_client_example_test.go deleted file mode 100644 index 496561a5ee56..000000000000 --- a/sdk/resourcemanager/elastic/armelastic/listassociatedtrafficfilters_client_example_test.go +++ /dev/null @@ -1,68 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. 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. -// DO NOT EDIT. - -package armelastic_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/dbd896bc9a795bcb3ec7db0a340b517fd3059620/specification/elastic/resource-manager/Microsoft.Elastic/preview/2023-02-01-preview/examples/AssociatedFiltersForDeployment_list.json -func ExampleListAssociatedTrafficFiltersClient_List() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armelastic.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewListAssociatedTrafficFiltersClient().List(ctx, "myResourceGroup", "myMonitor", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.TrafficFilterResponse = armelastic.TrafficFilterResponse{ - // Rulesets: []*armelastic.TrafficFilter{ - // { - // Name: to.Ptr("IPFromApi"), - // Type: to.Ptr(armelastic.TypeIP), - // Description: to.Ptr("created from azure"), - // ID: to.Ptr("31d91b5afb6f4c2eaaf104c97b1991dd"), - // IncludeByDefault: to.Ptr(false), - // Region: to.Ptr("azure-eastus"), - // Rules: []*armelastic.TrafficFilterRule{ - // { - // Description: to.Ptr("Allow inbound traffic from IP address 192.168.131.0"), - // ID: to.Ptr("f0297dad72af4a5e964cddf817f35e65"), - // Source: to.Ptr("192.168.131.0"), - // }, - // { - // Description: to.Ptr("Allow inbound traffic from IP address block 192.168.132.6/22"), - // ID: to.Ptr("f9c00169f0e54931ae72aabde326b589"), - // Source: to.Ptr("192.168.132.6/22"), - // }}, - // }}, - // } -} diff --git a/sdk/resourcemanager/elastic/armelastic/models.go b/sdk/resourcemanager/elastic/armelastic/models.go index d07cf564f2d2..dcdba7dc7db1 100644 --- a/sdk/resourcemanager/elastic/armelastic/models.go +++ b/sdk/resourcemanager/elastic/armelastic/models.go @@ -13,24 +13,19 @@ // 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. -// DO NOT EDIT. +// Code generated by @autorest/go. DO NOT EDIT. package armelastic import "time" -// AllTrafficFiltersClientListOptions contains the optional parameters for the AllTrafficFiltersClient.List method. -type AllTrafficFiltersClientListOptions struct { - // placeholder for future optional parameters -} +// BillingInfoResponse - Marketplace Subscription and Organization details to which resource gets billed into. +type BillingInfoResponse struct { + // Marketplace Subscription details + MarketplaceSaasInfo *MarketplaceSaaSInfo -// AssociateTrafficFilterClientBeginAssociateOptions contains the optional parameters for the AssociateTrafficFilterClient.BeginAssociate -// method. -type AssociateTrafficFilterClientBeginAssociateOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string - // Ruleset Id of the filter - RulesetID *string + // Partner Billing Entity details: Organization Info + PartnerBillingEntity *PartnerBillingEntity } // CloudDeployment - Details of the user's elastic deployment associated with the monitor resource. @@ -87,33 +82,34 @@ type CompanyInfo struct { State *string } -// CreateAndAssociateIPFilterClientBeginCreateOptions contains the optional parameters for the CreateAndAssociateIPFilterClient.BeginCreate -// method. -type CreateAndAssociateIPFilterClientBeginCreateOptions struct { - // List of ips - IPs *string - // Name of the traffic filter - Name *string - // Resumes the LRO from the provided token. - ResumeToken string +// ConnectedPartnerResourceProperties - Connected Partner Resource Properties +type ConnectedPartnerResourceProperties struct { + // The azure resource Id of the deployment. + AzureResourceID *string + + // The location of the deployment. + Location *string + + // Elastic deployment name + PartnerDeploymentName *string + + // Deployment URL of the elasticsearch in Elastic cloud deployment. + PartnerDeploymentURI *string } -// CreateAndAssociatePLFilterClientBeginCreateOptions contains the optional parameters for the CreateAndAssociatePLFilterClient.BeginCreate -// method. -type CreateAndAssociatePLFilterClientBeginCreateOptions struct { - // Name of the traffic filter - Name *string - // Guid of the private endpoint - PrivateEndpointGUID *string - // Name of the private endpoint - PrivateEndpointName *string - // Resumes the LRO from the provided token. - ResumeToken string +// ConnectedPartnerResourcesListFormat - Connected Partner Resources List Format +type ConnectedPartnerResourcesListFormat struct { + // Connected Partner Resource Properties + Properties *ConnectedPartnerResourceProperties } -// DeploymentInfoClientListOptions contains the optional parameters for the DeploymentInfoClient.List method. -type DeploymentInfoClientListOptions struct { - // placeholder for future optional parameters +// ConnectedPartnerResourcesListResponse - List of all active elastic deployments. +type ConnectedPartnerResourcesListResponse struct { + // Link to the next set of results, if any. + NextLink *string + + // Results of a list operation. + Value []*ConnectedPartnerResourcesListFormat } // DeploymentInfoResponse - The properties of deployment in Elastic cloud corresponding to the Elastic monitor resource. @@ -124,6 +120,10 @@ type DeploymentInfoResponse struct { // READ-ONLY; Disk capacity of the elasticsearch in Elastic cloud deployment. DiskCapacity *string + // READ-ONLY; Elasticsearch endpoint in Elastic cloud deployment. This is either the aliasedendpoint if available, or the + // serviceurl otherwise. + ElasticsearchEndPoint *string + // READ-ONLY; Marketplace SaaS Info of the resource. MarketplaceSaasInfo *MarketplaceSaaSInfo @@ -137,28 +137,6 @@ type DeploymentInfoResponse struct { Version *string } -// DetachAndDeleteTrafficFilterClientDeleteOptions contains the optional parameters for the DetachAndDeleteTrafficFilterClient.Delete -// method. -type DetachAndDeleteTrafficFilterClientDeleteOptions struct { - // Ruleset Id of the filter - RulesetID *string -} - -// DetachTrafficFilterClientBeginUpdateOptions contains the optional parameters for the DetachTrafficFilterClient.BeginUpdate -// method. -type DetachTrafficFilterClientBeginUpdateOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string - // Ruleset Id of the filter - RulesetID *string -} - -// ExternalUserClientCreateOrUpdateOptions contains the optional parameters for the ExternalUserClient.CreateOrUpdate method. -type ExternalUserClientCreateOrUpdateOptions struct { - // Elastic External User Creation Parameters - Body *ExternalUserInfo -} - // ExternalUserCreationResponse - The properties of the response we got from elastic while creating external user type ExternalUserCreationResponse struct { // READ-ONLY; Shows if user is created or updated @@ -208,12 +186,6 @@ type IdentityProperties struct { TenantID *string } -// ListAssociatedTrafficFiltersClientListOptions contains the optional parameters for the ListAssociatedTrafficFiltersClient.List -// method. -type ListAssociatedTrafficFiltersClientListOptions struct { - // placeholder for future optional parameters -} - // LogRules - Set of rules for sending logs for the Monitor resource. type LogRules struct { // List of filtering tags to be used for capturing logs. This only takes effect if SendActivityLogs flag is enabled. If empty, @@ -234,14 +206,23 @@ type LogRules struct { // MarketplaceSaaSInfo - Marketplace SAAS Info of the resource. type MarketplaceSaaSInfo struct { + // The Azure Subscription ID to which the Marketplace Subscription belongs and gets billed into. + BilledAzureSubscriptionID *string + // Marketplace Subscription Details: SAAS Name MarketplaceName *string // Marketplace Subscription Details: Resource URI MarketplaceResourceID *string + // Marketplace Subscription Details: SaaS Subscription Status + MarketplaceStatus *string + // Marketplace Subscription MarketplaceSubscription *MarketplaceSaaSInfoMarketplaceSubscription + + // Flag specifying if the Marketplace status is subscribed or not. + Subscribed *bool } // MarketplaceSaaSInfoMarketplaceSubscription - Marketplace Subscription @@ -250,14 +231,6 @@ type MarketplaceSaaSInfoMarketplaceSubscription struct { ID *string } -// MonitorClientBeginUpgradeOptions contains the optional parameters for the MonitorClient.BeginUpgrade method. -type MonitorClientBeginUpgradeOptions struct { - // Elastic Monitor Upgrade Parameters - Body *MonitorUpgrade - // Resumes the LRO from the provided token. - ResumeToken string -} - // MonitorProperties - Properties specific to the monitor resource. type MonitorProperties struct { // Elastic cloud properties. @@ -269,9 +242,21 @@ type MonitorProperties struct { // Flag specifying if the resource monitoring is enabled or disabled. MonitoringStatus *MonitoringStatus + // Plan details of the monitor resource. + PlanDetails *PlanDetails + // Provisioning state of the monitor resource. ProvisioningState *ProvisioningState + // Status of Azure Subscription where Marketplace SaaS is located. + SaaSAzureSubscriptionStatus *string + + // A unique identifier associated with the campaign. + SourceCampaignID *string + + // Name of the marketing campaign. + SourceCampaignName *string + // User information. UserInfo *UserInfo @@ -357,11 +342,6 @@ type MonitoredResourceListResponse struct { Value []*MonitoredResource } -// MonitoredResourcesClientListOptions contains the optional parameters for the MonitoredResourcesClient.NewListPager method. -type MonitoredResourcesClientListOptions struct { - // placeholder for future optional parameters -} - // MonitoringTagRules - Capture logs and metrics of Azure resources based on ARM tags. type MonitoringTagRules struct { // Properties of the monitoring tag rules. @@ -398,42 +378,6 @@ type MonitoringTagRulesProperties struct { ProvisioningState *ProvisioningState } -// MonitorsClientBeginCreateOptions contains the optional parameters for the MonitorsClient.BeginCreate method. -type MonitorsClientBeginCreateOptions struct { - // Elastic monitor resource model - Body *MonitorResource - // Resumes the LRO from the provided token. - ResumeToken string -} - -// MonitorsClientBeginDeleteOptions contains the optional parameters for the MonitorsClient.BeginDelete method. -type MonitorsClientBeginDeleteOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// MonitorsClientGetOptions contains the optional parameters for the MonitorsClient.Get method. -type MonitorsClientGetOptions struct { - // placeholder for future optional parameters -} - -// MonitorsClientListByResourceGroupOptions contains the optional parameters for the MonitorsClient.NewListByResourceGroupPager -// method. -type MonitorsClientListByResourceGroupOptions struct { - // placeholder for future optional parameters -} - -// MonitorsClientListOptions contains the optional parameters for the MonitorsClient.NewListPager method. -type MonitorsClientListOptions struct { - // placeholder for future optional parameters -} - -// MonitorsClientUpdateOptions contains the optional parameters for the MonitorsClient.Update method. -type MonitorsClientUpdateOptions struct { - // Elastic resource model update parameters. - Body *MonitorResourceUpdateParameters -} - // OperationDisplay - The object that represents the operation. type OperationDisplay struct { // Description of the operation, e.g., 'Write monitors'. @@ -473,15 +417,58 @@ type OperationResult struct { Origin *string } -// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. -type OperationsClientListOptions struct { - // placeholder for future optional parameters +// OrganizationToAzureSubscriptionMappingResponse - The Azure Subscription ID to which the Organization of the logged in user +// belongs and gets billed into. +type OrganizationToAzureSubscriptionMappingResponse struct { + // The properties of Azure Subscription ID to which the Organization of the logged in user belongs and gets billed into. + Properties *OrganizationToAzureSubscriptionMappingResponseProperties +} + +// OrganizationToAzureSubscriptionMappingResponseProperties - The properties of Azure Subscription ID to which the Organization +// of the logged in user belongs and gets billed into. +type OrganizationToAzureSubscriptionMappingResponseProperties struct { + // The Azure Subscription ID to which the Organization belongs and gets billed into. This is empty for a new user OR a user + // without an Elastic Organization. + BilledAzureSubscriptionID *string + + // The Elastic Organization Id. + ElasticOrganizationID *string + + // The Elastic Organization Name. + ElasticOrganizationName *string + + // READ-ONLY; Marketplace SaaS Info of the resource. + MarketplaceSaasInfo *MarketplaceSaaSInfo +} + +// PartnerBillingEntity - Partner Billing details associated with the resource. +type PartnerBillingEntity struct { + // The Elastic Organization Id. + ID *string + + // The Elastic Organization Name. + Name *string + + // Link to the elastic organization page + PartnerEntityURI *string } -// OrganizationsClientGetAPIKeyOptions contains the optional parameters for the OrganizationsClient.GetAPIKey method. -type OrganizationsClientGetAPIKeyOptions struct { - // Email Id parameter of the User Organization, of which the API Key must be returned - Body *UserEmailID +// PlanDetails - Plan details of the monitor resource. +type PlanDetails struct { + // Offer ID of the plan + OfferID *string + + // Plan ID + PlanID *string + + // Plan Name + PlanName *string + + // Publisher ID of the plan + PublisherID *string + + // Term ID of the plan + TermID *string } // Properties - Elastic Resource Properties. @@ -520,28 +507,6 @@ type SystemData struct { LastModifiedByType *CreatedByType } -// TagRulesClientBeginDeleteOptions contains the optional parameters for the TagRulesClient.BeginDelete method. -type TagRulesClientBeginDeleteOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// TagRulesClientCreateOrUpdateOptions contains the optional parameters for the TagRulesClient.CreateOrUpdate method. -type TagRulesClientCreateOrUpdateOptions struct { - // request body of MonitoringTagRules - Body *MonitoringTagRules -} - -// TagRulesClientGetOptions contains the optional parameters for the TagRulesClient.Get method. -type TagRulesClientGetOptions struct { - // placeholder for future optional parameters -} - -// TagRulesClientListOptions contains the optional parameters for the TagRulesClient.NewListPager method. -type TagRulesClientListOptions struct { - // placeholder for future optional parameters -} - // TrafficFilter - Elastic traffic filter object type TrafficFilter struct { // Description of the elastic filter @@ -590,17 +555,6 @@ type TrafficFilterRule struct { Source *string } -// TrafficFiltersClientDeleteOptions contains the optional parameters for the TrafficFiltersClient.Delete method. -type TrafficFiltersClientDeleteOptions struct { - // Ruleset Id of the filter - RulesetID *string -} - -// UpgradableVersionsClientDetailsOptions contains the optional parameters for the UpgradableVersionsClient.Details method. -type UpgradableVersionsClientDetailsOptions struct { - // placeholder for future optional parameters -} - // UpgradableVersionsList - Stack Versions that this version can upgrade to type UpgradableVersionsList struct { // Current version of the elastic monitor @@ -645,12 +599,6 @@ type UserInfo struct { LastName *string } -// VMCollectionClientUpdateOptions contains the optional parameters for the VMCollectionClient.Update method. -type VMCollectionClientUpdateOptions struct { - // VM resource Id - Body *VMCollectionUpdate -} - // VMCollectionUpdate - Update VM resource collection. type VMCollectionUpdate struct { // Operation to be performed for given VM. @@ -660,11 +608,6 @@ type VMCollectionUpdate struct { VMResourceID *string } -// VMHostClientListOptions contains the optional parameters for the VMHostClient.NewListPager method. -type VMHostClientListOptions struct { - // placeholder for future optional parameters -} - // VMHostListResponse - Response of a list operation. type VMHostListResponse struct { // Link to the next Vm resource Id, if any. @@ -674,11 +617,6 @@ type VMHostListResponse struct { Value []*VMResources } -// VMIngestionClientDetailsOptions contains the optional parameters for the VMIngestionClient.Details method. -type VMIngestionClientDetailsOptions struct { - // placeholder for future optional parameters -} - // VMIngestionDetailsResponse - The vm ingestion details to install an agent. type VMIngestionDetailsResponse struct { // The cloudId of given Elastic monitor resource. @@ -706,11 +644,6 @@ type VersionListProperties struct { Version *string } -// VersionsClientListOptions contains the optional parameters for the VersionsClient.NewListPager method. -type VersionsClientListOptions struct { - // placeholder for future optional parameters -} - // VersionsListResponse - List of elastic versions available in a region. type VersionsListResponse struct { // Link to the next set of results, if any. diff --git a/sdk/resourcemanager/elastic/armelastic/models_serde.go b/sdk/resourcemanager/elastic/armelastic/models_serde.go index 39186452f448..c468a1d074a7 100644 --- a/sdk/resourcemanager/elastic/armelastic/models_serde.go +++ b/sdk/resourcemanager/elastic/armelastic/models_serde.go @@ -13,7 +13,7 @@ // 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. -// DO NOT EDIT. +// Code generated by @autorest/go. DO NOT EDIT. package armelastic @@ -24,6 +24,37 @@ import ( "reflect" ) +// MarshalJSON implements the json.Marshaller interface for type BillingInfoResponse. +func (b BillingInfoResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "marketplaceSaasInfo", b.MarketplaceSaasInfo) + populate(objectMap, "partnerBillingEntity", b.PartnerBillingEntity) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BillingInfoResponse. +func (b *BillingInfoResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "marketplaceSaasInfo": + err = unpopulate(val, "MarketplaceSaasInfo", &b.MarketplaceSaasInfo) + delete(rawMsg, key) + case "partnerBillingEntity": + err = unpopulate(val, "PartnerBillingEntity", &b.PartnerBillingEntity) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type CloudDeployment. func (c CloudDeployment) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -153,11 +184,109 @@ func (c *CompanyInfo) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type ConnectedPartnerResourceProperties. +func (c ConnectedPartnerResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "azureResourceId", c.AzureResourceID) + populate(objectMap, "location", c.Location) + populate(objectMap, "partnerDeploymentName", c.PartnerDeploymentName) + populate(objectMap, "partnerDeploymentUri", c.PartnerDeploymentURI) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ConnectedPartnerResourceProperties. +func (c *ConnectedPartnerResourceProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "azureResourceId": + err = unpopulate(val, "AzureResourceID", &c.AzureResourceID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &c.Location) + delete(rawMsg, key) + case "partnerDeploymentName": + err = unpopulate(val, "PartnerDeploymentName", &c.PartnerDeploymentName) + delete(rawMsg, key) + case "partnerDeploymentUri": + err = unpopulate(val, "PartnerDeploymentURI", &c.PartnerDeploymentURI) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ConnectedPartnerResourcesListFormat. +func (c ConnectedPartnerResourcesListFormat) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", c.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ConnectedPartnerResourcesListFormat. +func (c *ConnectedPartnerResourcesListFormat) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &c.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ConnectedPartnerResourcesListResponse. +func (c ConnectedPartnerResourcesListResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", c.NextLink) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ConnectedPartnerResourcesListResponse. +func (c *ConnectedPartnerResourcesListResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &c.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &c.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type DeploymentInfoResponse. func (d DeploymentInfoResponse) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "deploymentUrl", d.DeploymentURL) populate(objectMap, "diskCapacity", d.DiskCapacity) + populate(objectMap, "elasticsearchEndPoint", d.ElasticsearchEndPoint) populate(objectMap, "marketplaceSaasInfo", d.MarketplaceSaasInfo) populate(objectMap, "memoryCapacity", d.MemoryCapacity) populate(objectMap, "status", d.Status) @@ -180,6 +309,9 @@ func (d *DeploymentInfoResponse) UnmarshalJSON(data []byte) error { case "diskCapacity": err = unpopulate(val, "DiskCapacity", &d.DiskCapacity) delete(rawMsg, key) + case "elasticsearchEndPoint": + err = unpopulate(val, "ElasticsearchEndPoint", &d.ElasticsearchEndPoint) + delete(rawMsg, key) case "marketplaceSaasInfo": err = unpopulate(val, "MarketplaceSaasInfo", &d.MarketplaceSaasInfo) delete(rawMsg, key) @@ -382,9 +514,12 @@ func (l *LogRules) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type MarketplaceSaaSInfo. func (m MarketplaceSaaSInfo) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) + populate(objectMap, "billedAzureSubscriptionId", m.BilledAzureSubscriptionID) populate(objectMap, "marketplaceName", m.MarketplaceName) populate(objectMap, "marketplaceResourceId", m.MarketplaceResourceID) + populate(objectMap, "marketplaceStatus", m.MarketplaceStatus) populate(objectMap, "marketplaceSubscription", m.MarketplaceSubscription) + populate(objectMap, "subscribed", m.Subscribed) return json.Marshal(objectMap) } @@ -397,15 +532,24 @@ func (m *MarketplaceSaaSInfo) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "billedAzureSubscriptionId": + err = unpopulate(val, "BilledAzureSubscriptionID", &m.BilledAzureSubscriptionID) + delete(rawMsg, key) case "marketplaceName": err = unpopulate(val, "MarketplaceName", &m.MarketplaceName) delete(rawMsg, key) case "marketplaceResourceId": err = unpopulate(val, "MarketplaceResourceID", &m.MarketplaceResourceID) delete(rawMsg, key) + case "marketplaceStatus": + err = unpopulate(val, "MarketplaceStatus", &m.MarketplaceStatus) + delete(rawMsg, key) case "marketplaceSubscription": err = unpopulate(val, "MarketplaceSubscription", &m.MarketplaceSubscription) delete(rawMsg, key) + case "subscribed": + err = unpopulate(val, "Subscribed", &m.Subscribed) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", m, err) @@ -449,7 +593,11 @@ func (m MonitorProperties) MarshalJSON() ([]byte, error) { populate(objectMap, "liftrResourceCategory", m.LiftrResourceCategory) populate(objectMap, "liftrResourcePreference", m.LiftrResourcePreference) populate(objectMap, "monitoringStatus", m.MonitoringStatus) + populate(objectMap, "planDetails", m.PlanDetails) populate(objectMap, "provisioningState", m.ProvisioningState) + populate(objectMap, "saaSAzureSubscriptionStatus", m.SaaSAzureSubscriptionStatus) + populate(objectMap, "sourceCampaignId", m.SourceCampaignID) + populate(objectMap, "sourceCampaignName", m.SourceCampaignName) populate(objectMap, "userInfo", m.UserInfo) populate(objectMap, "version", m.Version) return json.Marshal(objectMap) @@ -479,9 +627,21 @@ func (m *MonitorProperties) UnmarshalJSON(data []byte) error { case "monitoringStatus": err = unpopulate(val, "MonitoringStatus", &m.MonitoringStatus) delete(rawMsg, key) + case "planDetails": + err = unpopulate(val, "PlanDetails", &m.PlanDetails) + delete(rawMsg, key) case "provisioningState": err = unpopulate(val, "ProvisioningState", &m.ProvisioningState) delete(rawMsg, key) + case "saaSAzureSubscriptionStatus": + err = unpopulate(val, "SaaSAzureSubscriptionStatus", &m.SaaSAzureSubscriptionStatus) + delete(rawMsg, key) + case "sourceCampaignId": + err = unpopulate(val, "SourceCampaignID", &m.SourceCampaignID) + delete(rawMsg, key) + case "sourceCampaignName": + err = unpopulate(val, "SourceCampaignName", &m.SourceCampaignName) + delete(rawMsg, key) case "userInfo": err = unpopulate(val, "UserInfo", &m.UserInfo) delete(rawMsg, key) @@ -920,6 +1080,150 @@ func (o *OperationResult) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type OrganizationToAzureSubscriptionMappingResponse. +func (o OrganizationToAzureSubscriptionMappingResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", o.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OrganizationToAzureSubscriptionMappingResponse. +func (o *OrganizationToAzureSubscriptionMappingResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &o.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OrganizationToAzureSubscriptionMappingResponseProperties. +func (o OrganizationToAzureSubscriptionMappingResponseProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "billedAzureSubscriptionId", o.BilledAzureSubscriptionID) + populate(objectMap, "elasticOrganizationId", o.ElasticOrganizationID) + populate(objectMap, "elasticOrganizationName", o.ElasticOrganizationName) + populate(objectMap, "marketplaceSaasInfo", o.MarketplaceSaasInfo) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OrganizationToAzureSubscriptionMappingResponseProperties. +func (o *OrganizationToAzureSubscriptionMappingResponseProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "billedAzureSubscriptionId": + err = unpopulate(val, "BilledAzureSubscriptionID", &o.BilledAzureSubscriptionID) + delete(rawMsg, key) + case "elasticOrganizationId": + err = unpopulate(val, "ElasticOrganizationID", &o.ElasticOrganizationID) + delete(rawMsg, key) + case "elasticOrganizationName": + err = unpopulate(val, "ElasticOrganizationName", &o.ElasticOrganizationName) + delete(rawMsg, key) + case "marketplaceSaasInfo": + err = unpopulate(val, "MarketplaceSaasInfo", &o.MarketplaceSaasInfo) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PartnerBillingEntity. +func (p PartnerBillingEntity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", p.ID) + populate(objectMap, "name", p.Name) + populate(objectMap, "partnerEntityUri", p.PartnerEntityURI) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PartnerBillingEntity. +func (p *PartnerBillingEntity) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &p.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "partnerEntityUri": + err = unpopulate(val, "PartnerEntityURI", &p.PartnerEntityURI) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PlanDetails. +func (p PlanDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "offerID", p.OfferID) + populate(objectMap, "planID", p.PlanID) + populate(objectMap, "planName", p.PlanName) + populate(objectMap, "publisherID", p.PublisherID) + populate(objectMap, "termID", p.TermID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PlanDetails. +func (p *PlanDetails) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "offerID": + err = unpopulate(val, "OfferID", &p.OfferID) + delete(rawMsg, key) + case "planID": + err = unpopulate(val, "PlanID", &p.PlanID) + delete(rawMsg, key) + case "planName": + err = unpopulate(val, "PlanName", &p.PlanName) + delete(rawMsg, key) + case "publisherID": + err = unpopulate(val, "PublisherID", &p.PublisherID) + delete(rawMsg, key) + case "termID": + err = unpopulate(val, "TermID", &p.TermID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type Properties. func (p Properties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -981,10 +1285,10 @@ func (r *ResourceSKU) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SystemData. func (s SystemData) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populateDateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) populate(objectMap, "createdBy", s.CreatedBy) populate(objectMap, "createdByType", s.CreatedByType) - populateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populateDateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) populate(objectMap, "lastModifiedBy", s.LastModifiedBy) populate(objectMap, "lastModifiedByType", s.LastModifiedByType) return json.Marshal(objectMap) @@ -1000,7 +1304,7 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { var err error switch key { case "createdAt": - err = unpopulateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) + err = unpopulateDateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) delete(rawMsg, key) case "createdBy": err = unpopulate(val, "CreatedBy", &s.CreatedBy) @@ -1009,7 +1313,7 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { err = unpopulate(val, "CreatedByType", &s.CreatedByType) delete(rawMsg, key) case "lastModifiedAt": - err = unpopulateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) + err = unpopulateDateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) delete(rawMsg, key) case "lastModifiedBy": err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) diff --git a/sdk/resourcemanager/elastic/armelastic/monitor_client.go b/sdk/resourcemanager/elastic/armelastic/monitor_client.go index 87d1b320ca0e..62e0b97a13c6 100644 --- a/sdk/resourcemanager/elastic/armelastic/monitor_client.go +++ b/sdk/resourcemanager/elastic/armelastic/monitor_client.go @@ -13,7 +13,7 @@ // 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. -// DO NOT EDIT. +// Code generated by @autorest/go. DO NOT EDIT. package armelastic @@ -37,11 +37,11 @@ type MonitorClient struct { } // NewMonitorClient creates a new instance of MonitorClient with the specified values. -// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewMonitorClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*MonitorClient, error) { - cl, err := arm.NewClient(moduleName+".MonitorClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -55,8 +55,8 @@ func NewMonitorClient(subscriptionID string, credential azcore.TokenCredential, // BeginUpgrade - Upgradable version for a monitor resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-02-01-preview -// - resourceGroupName - The name of the resource group to which the Elastic resource belongs. +// Generated from API version 2023-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - monitorName - Monitor resource name // - options - MonitorClientBeginUpgradeOptions contains the optional parameters for the MonitorClient.BeginUpgrade method. func (client *MonitorClient) BeginUpgrade(ctx context.Context, resourceGroupName string, monitorName string, options *MonitorClientBeginUpgradeOptions) (*runtime.Poller[MonitorClientUpgradeResponse], error) { @@ -65,29 +65,40 @@ func (client *MonitorClient) BeginUpgrade(ctx context.Context, resourceGroupName if err != nil { return nil, err } - return runtime.NewPoller[MonitorClientUpgradeResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[MonitorClientUpgradeResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[MonitorClientUpgradeResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[MonitorClientUpgradeResponse]{ + Tracer: client.internal.Tracer(), + }) } } // Upgrade - Upgradable version for a monitor resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-02-01-preview +// Generated from API version 2023-11-01-preview func (client *MonitorClient) upgrade(ctx context.Context, resourceGroupName string, monitorName string, options *MonitorClientBeginUpgradeOptions) (*http.Response, error) { + var err error + const operationName = "MonitorClient.BeginUpgrade" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.upgradeCreateRequest(ctx, resourceGroupName, monitorName, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // upgradeCreateRequest creates the Upgrade request. @@ -110,11 +121,14 @@ func (client *MonitorClient) upgradeCreateRequest(ctx context.Context, resourceG return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-02-01-preview") + reqQP.Set("api-version", "2023-11-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.Body != nil { - return req, runtime.MarshalAsJSON(req, *options.Body) + if err := runtime.MarshalAsJSON(req, *options.Body); err != nil { + return nil, err + } + return req, nil } return req, nil } diff --git a/sdk/resourcemanager/elastic/armelastic/monitor_client_example_test.go b/sdk/resourcemanager/elastic/armelastic/monitor_client_example_test.go deleted file mode 100644 index a25d4d71d9d8..000000000000 --- a/sdk/resourcemanager/elastic/armelastic/monitor_client_example_test.go +++ /dev/null @@ -1,47 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. 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. -// DO NOT EDIT. - -package armelastic_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/dbd896bc9a795bcb3ec7db0a340b517fd3059620/specification/elastic/resource-manager/Microsoft.Elastic/preview/2023-02-01-preview/examples/Monitor_Upgrade.json -func ExampleMonitorClient_BeginUpgrade() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armelastic.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewMonitorClient().BeginUpgrade(ctx, "myResourceGroup", "myMonitor", &armelastic.MonitorClientBeginUpgradeOptions{Body: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} diff --git a/sdk/resourcemanager/elastic/armelastic/monitoredresources_client.go b/sdk/resourcemanager/elastic/armelastic/monitoredresources_client.go index 019b137f51ba..73ba3e62c8a2 100644 --- a/sdk/resourcemanager/elastic/armelastic/monitoredresources_client.go +++ b/sdk/resourcemanager/elastic/armelastic/monitoredresources_client.go @@ -13,7 +13,7 @@ // 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. -// DO NOT EDIT. +// Code generated by @autorest/go. DO NOT EDIT. package armelastic @@ -37,11 +37,11 @@ type MonitoredResourcesClient struct { } // NewMonitoredResourcesClient creates a new instance of MonitoredResourcesClient with the specified values. -// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewMonitoredResourcesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*MonitoredResourcesClient, error) { - cl, err := arm.NewClient(moduleName+".MonitoredResourcesClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -54,8 +54,8 @@ func NewMonitoredResourcesClient(subscriptionID string, credential azcore.TokenC // NewListPager - List the resources currently being monitored by the Elastic monitor resource. // -// Generated from API version 2023-02-01-preview -// - resourceGroupName - The name of the resource group to which the Elastic resource belongs. +// Generated from API version 2023-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - monitorName - Monitor resource name // - options - MonitoredResourcesClientListOptions contains the optional parameters for the MonitoredResourcesClient.NewListPager // method. @@ -65,25 +65,20 @@ func (client *MonitoredResourcesClient) NewListPager(resourceGroupName string, m return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *MonitoredResourcesClientListResponse) (MonitoredResourcesClientListResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listCreateRequest(ctx, resourceGroupName, monitorName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "MonitoredResourcesClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, monitorName, options) + }, nil) if err != nil { return MonitoredResourcesClientListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return MonitoredResourcesClientListResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return MonitoredResourcesClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -107,7 +102,7 @@ func (client *MonitoredResourcesClient) listCreateRequest(ctx context.Context, r return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-02-01-preview") + reqQP.Set("api-version", "2023-11-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/elastic/armelastic/monitoredresources_client_example_test.go b/sdk/resourcemanager/elastic/armelastic/monitoredresources_client_example_test.go deleted file mode 100644 index 34f9460e1404..000000000000 --- a/sdk/resourcemanager/elastic/armelastic/monitoredresources_client_example_test.go +++ /dev/null @@ -1,59 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. 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. -// DO NOT EDIT. - -package armelastic_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/dbd896bc9a795bcb3ec7db0a340b517fd3059620/specification/elastic/resource-manager/Microsoft.Elastic/preview/2023-02-01-preview/examples/MonitoredResources_List.json -func ExampleMonitoredResourcesClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armelastic.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewMonitoredResourcesClient().NewListPager("myResourceGroup", "myMonitor", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.MonitoredResourceListResponse = armelastic.MonitoredResourceListResponse{ - // Value: []*armelastic.MonitoredResource{ - // { - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.KeyVault/vaults/myVault"), - // ReasonForLogsStatus: to.Ptr("CapturedByRules"), - // SendingLogs: to.Ptr(armelastic.SendingLogsTrue), - // }}, - // } - } -} diff --git a/sdk/resourcemanager/elastic/armelastic/monitors_client.go b/sdk/resourcemanager/elastic/armelastic/monitors_client.go index 39f968955ba2..ec9daca9c95c 100644 --- a/sdk/resourcemanager/elastic/armelastic/monitors_client.go +++ b/sdk/resourcemanager/elastic/armelastic/monitors_client.go @@ -13,7 +13,7 @@ // 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. -// DO NOT EDIT. +// Code generated by @autorest/go. DO NOT EDIT. package armelastic @@ -37,11 +37,11 @@ type MonitorsClient struct { } // NewMonitorsClient creates a new instance of MonitorsClient with the specified values. -// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewMonitorsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*MonitorsClient, error) { - cl, err := arm.NewClient(moduleName+".MonitorsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -55,8 +55,8 @@ func NewMonitorsClient(subscriptionID string, credential azcore.TokenCredential, // BeginCreate - Create a monitor resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-02-01-preview -// - resourceGroupName - The name of the resource group to which the Elastic resource belongs. +// Generated from API version 2023-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - monitorName - Monitor resource name // - options - MonitorsClientBeginCreateOptions contains the optional parameters for the MonitorsClient.BeginCreate method. func (client *MonitorsClient) BeginCreate(ctx context.Context, resourceGroupName string, monitorName string, options *MonitorsClientBeginCreateOptions) (*runtime.Poller[MonitorsClientCreateResponse], error) { @@ -65,31 +65,41 @@ func (client *MonitorsClient) BeginCreate(ctx context.Context, resourceGroupName if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[MonitorsClientCreateResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[MonitorsClientCreateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[MonitorsClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[MonitorsClientCreateResponse]{ + Tracer: client.internal.Tracer(), + }) } } // Create - Create a monitor resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-02-01-preview +// Generated from API version 2023-11-01-preview func (client *MonitorsClient) create(ctx context.Context, resourceGroupName string, monitorName string, options *MonitorsClientBeginCreateOptions) (*http.Response, error) { + var err error + const operationName = "MonitorsClient.BeginCreate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.createCreateRequest(ctx, resourceGroupName, monitorName, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // createCreateRequest creates the Create request. @@ -112,11 +122,14 @@ func (client *MonitorsClient) createCreateRequest(ctx context.Context, resourceG return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-02-01-preview") + reqQP.Set("api-version", "2023-11-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.Body != nil { - return req, runtime.MarshalAsJSON(req, *options.Body) + if err := runtime.MarshalAsJSON(req, *options.Body); err != nil { + return nil, err + } + return req, nil } return req, nil } @@ -124,8 +137,8 @@ func (client *MonitorsClient) createCreateRequest(ctx context.Context, resourceG // BeginDelete - Delete a monitor resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-02-01-preview -// - resourceGroupName - The name of the resource group to which the Elastic resource belongs. +// Generated from API version 2023-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - monitorName - Monitor resource name // - options - MonitorsClientBeginDeleteOptions contains the optional parameters for the MonitorsClient.BeginDelete method. func (client *MonitorsClient) BeginDelete(ctx context.Context, resourceGroupName string, monitorName string, options *MonitorsClientBeginDeleteOptions) (*runtime.Poller[MonitorsClientDeleteResponse], error) { @@ -134,29 +147,40 @@ func (client *MonitorsClient) BeginDelete(ctx context.Context, resourceGroupName if err != nil { return nil, err } - return runtime.NewPoller[MonitorsClientDeleteResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[MonitorsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[MonitorsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[MonitorsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) } } // Delete - Delete a monitor resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-02-01-preview +// Generated from API version 2023-11-01-preview func (client *MonitorsClient) deleteOperation(ctx context.Context, resourceGroupName string, monitorName string, options *MonitorsClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "MonitorsClient.BeginDelete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.deleteCreateRequest(ctx, resourceGroupName, monitorName, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // deleteCreateRequest creates the Delete request. @@ -179,7 +203,7 @@ func (client *MonitorsClient) deleteCreateRequest(ctx context.Context, resourceG return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-02-01-preview") + reqQP.Set("api-version", "2023-11-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -188,23 +212,30 @@ func (client *MonitorsClient) deleteCreateRequest(ctx context.Context, resourceG // Get - Get the properties of a specific monitor resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-02-01-preview -// - resourceGroupName - The name of the resource group to which the Elastic resource belongs. +// Generated from API version 2023-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - monitorName - Monitor resource name // - options - MonitorsClientGetOptions contains the optional parameters for the MonitorsClient.Get method. func (client *MonitorsClient) Get(ctx context.Context, resourceGroupName string, monitorName string, options *MonitorsClientGetOptions) (MonitorsClientGetResponse, error) { + var err error + const operationName = "MonitorsClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.getCreateRequest(ctx, resourceGroupName, monitorName, options) if err != nil { return MonitorsClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return MonitorsClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return MonitorsClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return MonitorsClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -227,7 +258,7 @@ func (client *MonitorsClient) getCreateRequest(ctx context.Context, resourceGrou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-02-01-preview") + reqQP.Set("api-version", "2023-11-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -244,7 +275,7 @@ func (client *MonitorsClient) getHandleResponse(resp *http.Response) (MonitorsCl // NewListPager - List all monitors under the specified subscription. // -// Generated from API version 2023-02-01-preview +// Generated from API version 2023-11-01-preview // - options - MonitorsClientListOptions contains the optional parameters for the MonitorsClient.NewListPager method. func (client *MonitorsClient) NewListPager(options *MonitorsClientListOptions) *runtime.Pager[MonitorsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[MonitorsClientListResponse]{ @@ -252,25 +283,20 @@ func (client *MonitorsClient) NewListPager(options *MonitorsClientListOptions) * return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *MonitorsClientListResponse) (MonitorsClientListResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listCreateRequest(ctx, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "MonitorsClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, nil) if err != nil { return MonitorsClientListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return MonitorsClientListResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return MonitorsClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -286,7 +312,7 @@ func (client *MonitorsClient) listCreateRequest(ctx context.Context, options *Mo return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-02-01-preview") + reqQP.Set("api-version", "2023-11-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -303,8 +329,8 @@ func (client *MonitorsClient) listHandleResponse(resp *http.Response) (MonitorsC // NewListByResourceGroupPager - List all monitors under the specified resource group. // -// Generated from API version 2023-02-01-preview -// - resourceGroupName - The name of the resource group to which the Elastic resource belongs. +// Generated from API version 2023-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - options - MonitorsClientListByResourceGroupOptions contains the optional parameters for the MonitorsClient.NewListByResourceGroupPager // method. func (client *MonitorsClient) NewListByResourceGroupPager(resourceGroupName string, options *MonitorsClientListByResourceGroupOptions) *runtime.Pager[MonitorsClientListByResourceGroupResponse] { @@ -313,25 +339,20 @@ func (client *MonitorsClient) NewListByResourceGroupPager(resourceGroupName stri return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *MonitorsClientListByResourceGroupResponse) (MonitorsClientListByResourceGroupResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) - } - if err != nil { - return MonitorsClientListByResourceGroupResponse{}, err + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "MonitorsClient.NewListByResourceGroupPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink } - resp, err := client.internal.Pipeline().Do(req) + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + }, nil) if err != nil { return MonitorsClientListByResourceGroupResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return MonitorsClientListByResourceGroupResponse{}, runtime.NewResponseError(resp) - } return client.listByResourceGroupHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -351,7 +372,7 @@ func (client *MonitorsClient) listByResourceGroupCreateRequest(ctx context.Conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-02-01-preview") + reqQP.Set("api-version", "2023-11-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -369,23 +390,30 @@ func (client *MonitorsClient) listByResourceGroupHandleResponse(resp *http.Respo // Update - Update a monitor resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-02-01-preview -// - resourceGroupName - The name of the resource group to which the Elastic resource belongs. +// Generated from API version 2023-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - monitorName - Monitor resource name // - options - MonitorsClientUpdateOptions contains the optional parameters for the MonitorsClient.Update method. func (client *MonitorsClient) Update(ctx context.Context, resourceGroupName string, monitorName string, options *MonitorsClientUpdateOptions) (MonitorsClientUpdateResponse, error) { + var err error + const operationName = "MonitorsClient.Update" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.updateCreateRequest(ctx, resourceGroupName, monitorName, options) if err != nil { return MonitorsClientUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return MonitorsClientUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return MonitorsClientUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return MonitorsClientUpdateResponse{}, err } - return client.updateHandleResponse(resp) + resp, err := client.updateHandleResponse(httpResp) + return resp, err } // updateCreateRequest creates the Update request. @@ -408,11 +436,14 @@ func (client *MonitorsClient) updateCreateRequest(ctx context.Context, resourceG return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-02-01-preview") + reqQP.Set("api-version", "2023-11-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.Body != nil { - return req, runtime.MarshalAsJSON(req, *options.Body) + if err := runtime.MarshalAsJSON(req, *options.Body); err != nil { + return nil, err + } + return req, nil } return req, nil } diff --git a/sdk/resourcemanager/elastic/armelastic/monitors_client_example_test.go b/sdk/resourcemanager/elastic/armelastic/monitors_client_example_test.go deleted file mode 100644 index 4a5567fc9a3c..000000000000 --- a/sdk/resourcemanager/elastic/armelastic/monitors_client_example_test.go +++ /dev/null @@ -1,325 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. 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. -// DO NOT EDIT. - -package armelastic_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/dbd896bc9a795bcb3ec7db0a340b517fd3059620/specification/elastic/resource-manager/Microsoft.Elastic/preview/2023-02-01-preview/examples/Monitors_List.json -func ExampleMonitorsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armelastic.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewMonitorsClient().NewListPager(nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.MonitorResourceListResponse = armelastic.MonitorResourceListResponse{ - // Value: []*armelastic.MonitorResource{ - // { - // Name: to.Ptr("myMonitor"), - // Type: to.Ptr("Microsoft.Elastic/monitors"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/monitors/myMonitor"), - // Location: to.Ptr("West US 2"), - // Properties: &armelastic.MonitorProperties{ - // ElasticProperties: &armelastic.Properties{ - // ElasticCloudDeployment: &armelastic.CloudDeployment{ - // Name: to.Ptr("deploymentname"), - // AzureSubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // DeploymentID: to.Ptr("deployment_id"), - // ElasticsearchRegion: to.Ptr("azure-westus2"), - // ElasticsearchServiceURL: to.Ptr("https://elasticsearchendpoint.com"), - // KibanaServiceURL: to.Ptr("https://kibanaserviceurl.com"), - // KibanaSsoURL: to.Ptr("https://kibanssourl.com"), - // }, - // ElasticCloudUser: &armelastic.CloudUser{ - // ElasticCloudSsoDefaultURL: to.Ptr("https://examplessourl.com"), - // EmailAddress: to.Ptr("alice@microsoft.com"), - // ID: to.Ptr("myid123"), - // }, - // }, - // LiftrResourceCategory: to.Ptr(armelastic.LiftrResourceCategoriesMonitorLogs), - // LiftrResourcePreference: to.Ptr[int32](0), - // MonitoringStatus: to.Ptr(armelastic.MonitoringStatusEnabled), - // ProvisioningState: to.Ptr(armelastic.ProvisioningStateSucceeded), - // }, - // Tags: map[string]*string{ - // "Environment": to.Ptr("Dev"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/dbd896bc9a795bcb3ec7db0a340b517fd3059620/specification/elastic/resource-manager/Microsoft.Elastic/preview/2023-02-01-preview/examples/Monitors_ListByResourceGroup.json -func ExampleMonitorsClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armelastic.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewMonitorsClient().NewListByResourceGroupPager("myResourceGroup", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.MonitorResourceListResponse = armelastic.MonitorResourceListResponse{ - // Value: []*armelastic.MonitorResource{ - // { - // Name: to.Ptr("myMonitor"), - // Type: to.Ptr("Microsoft.Elastic/monitors"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/monitors/myMonitor"), - // Location: to.Ptr("West US 2"), - // Properties: &armelastic.MonitorProperties{ - // ElasticProperties: &armelastic.Properties{ - // ElasticCloudDeployment: &armelastic.CloudDeployment{ - // Name: to.Ptr("deploymentname"), - // AzureSubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // DeploymentID: to.Ptr("deployment_id"), - // ElasticsearchRegion: to.Ptr("azure-westus2"), - // ElasticsearchServiceURL: to.Ptr("https://elasticsearchendpoint.com"), - // KibanaServiceURL: to.Ptr("https://kibanaserviceurl.com"), - // KibanaSsoURL: to.Ptr("https://kibanssourl.com"), - // }, - // ElasticCloudUser: &armelastic.CloudUser{ - // ElasticCloudSsoDefaultURL: to.Ptr("https://examplessourl.com"), - // EmailAddress: to.Ptr("alice@microsoft.com"), - // ID: to.Ptr("myid123"), - // }, - // }, - // LiftrResourceCategory: to.Ptr(armelastic.LiftrResourceCategoriesMonitorLogs), - // LiftrResourcePreference: to.Ptr[int32](0), - // MonitoringStatus: to.Ptr(armelastic.MonitoringStatusEnabled), - // ProvisioningState: to.Ptr(armelastic.ProvisioningStateSucceeded), - // }, - // Tags: map[string]*string{ - // "Environment": to.Ptr("Dev"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/dbd896bc9a795bcb3ec7db0a340b517fd3059620/specification/elastic/resource-manager/Microsoft.Elastic/preview/2023-02-01-preview/examples/Monitors_Get.json -func ExampleMonitorsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armelastic.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewMonitorsClient().Get(ctx, "myResourceGroup", "myMonitor", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.MonitorResource = armelastic.MonitorResource{ - // Name: to.Ptr("myMonitor"), - // Type: to.Ptr("Microsoft.Elastic/monitors"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/monitors/myMonitor"), - // Location: to.Ptr("West US 2"), - // Properties: &armelastic.MonitorProperties{ - // ElasticProperties: &armelastic.Properties{ - // ElasticCloudDeployment: &armelastic.CloudDeployment{ - // Name: to.Ptr("deploymentname"), - // AzureSubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // DeploymentID: to.Ptr("deployment_id"), - // ElasticsearchRegion: to.Ptr("azure-westus2"), - // ElasticsearchServiceURL: to.Ptr("https://elasticsearchendpoint.com"), - // KibanaServiceURL: to.Ptr("https://kibanaserviceurl.com"), - // KibanaSsoURL: to.Ptr("https://kibanssourl.com"), - // }, - // ElasticCloudUser: &armelastic.CloudUser{ - // ElasticCloudSsoDefaultURL: to.Ptr("https://examplessourl.com"), - // EmailAddress: to.Ptr("alice@microsoft.com"), - // ID: to.Ptr("myid123"), - // }, - // }, - // LiftrResourceCategory: to.Ptr(armelastic.LiftrResourceCategoriesMonitorLogs), - // LiftrResourcePreference: to.Ptr[int32](0), - // MonitoringStatus: to.Ptr(armelastic.MonitoringStatusEnabled), - // ProvisioningState: to.Ptr(armelastic.ProvisioningStateSucceeded), - // }, - // Tags: map[string]*string{ - // "Environment": to.Ptr("Dev"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/dbd896bc9a795bcb3ec7db0a340b517fd3059620/specification/elastic/resource-manager/Microsoft.Elastic/preview/2023-02-01-preview/examples/Monitors_Create.json -func ExampleMonitorsClient_BeginCreate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armelastic.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewMonitorsClient().BeginCreate(ctx, "myResourceGroup", "myMonitor", &armelastic.MonitorsClientBeginCreateOptions{Body: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.MonitorResource = armelastic.MonitorResource{ - // Name: to.Ptr("myMonitor"), - // Type: to.Ptr("Microsoft.Elastic/monitors"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/monitors/myMonitor"), - // Location: to.Ptr("West US 2"), - // Properties: &armelastic.MonitorProperties{ - // ElasticProperties: &armelastic.Properties{ - // ElasticCloudDeployment: &armelastic.CloudDeployment{ - // Name: to.Ptr("deploymentname"), - // AzureSubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // DeploymentID: to.Ptr("deployment_id"), - // ElasticsearchRegion: to.Ptr("azure-westus2"), - // ElasticsearchServiceURL: to.Ptr("https://elasticsearchendpoint.com"), - // KibanaServiceURL: to.Ptr("https://kibanaserviceurl.com"), - // KibanaSsoURL: to.Ptr("https://kibanssourl.com"), - // }, - // ElasticCloudUser: &armelastic.CloudUser{ - // ElasticCloudSsoDefaultURL: to.Ptr("https://examplessourl.com"), - // EmailAddress: to.Ptr("alice@microsoft.com"), - // ID: to.Ptr("myid123"), - // }, - // }, - // ProvisioningState: to.Ptr(armelastic.ProvisioningStateSucceeded), - // }, - // SKU: &armelastic.ResourceSKU{ - // Name: to.Ptr("free_Monthly"), - // }, - // Tags: map[string]*string{ - // "Environment": to.Ptr("Dev"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/dbd896bc9a795bcb3ec7db0a340b517fd3059620/specification/elastic/resource-manager/Microsoft.Elastic/preview/2023-02-01-preview/examples/Monitors_Update.json -func ExampleMonitorsClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armelastic.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewMonitorsClient().Update(ctx, "myResourceGroup", "myMonitor", &armelastic.MonitorsClientUpdateOptions{Body: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.MonitorResource = armelastic.MonitorResource{ - // Name: to.Ptr("myMonitor"), - // Type: to.Ptr("Microsoft.Elastic/monitors"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/monitors/myMonitor"), - // Location: to.Ptr("West US 2"), - // Properties: &armelastic.MonitorProperties{ - // ElasticProperties: &armelastic.Properties{ - // ElasticCloudDeployment: &armelastic.CloudDeployment{ - // Name: to.Ptr("deploymentname"), - // AzureSubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // DeploymentID: to.Ptr("deployment_id"), - // ElasticsearchRegion: to.Ptr("azure-westus2"), - // ElasticsearchServiceURL: to.Ptr("https://elasticsearchendpoint.com"), - // KibanaServiceURL: to.Ptr("https://kibanaserviceurl.com"), - // KibanaSsoURL: to.Ptr("https://kibanssourl.com"), - // }, - // ElasticCloudUser: &armelastic.CloudUser{ - // ElasticCloudSsoDefaultURL: to.Ptr("https://examplessourl.com"), - // EmailAddress: to.Ptr("alice@microsoft.com"), - // ID: to.Ptr("myid123"), - // }, - // }, - // LiftrResourceCategory: to.Ptr(armelastic.LiftrResourceCategoriesMonitorLogs), - // LiftrResourcePreference: to.Ptr[int32](0), - // MonitoringStatus: to.Ptr(armelastic.MonitoringStatusEnabled), - // ProvisioningState: to.Ptr(armelastic.ProvisioningStateSucceeded), - // }, - // SKU: &armelastic.ResourceSKU{ - // Name: to.Ptr("free_Monthly"), - // }, - // Tags: map[string]*string{ - // "Environment": to.Ptr("Dev"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/dbd896bc9a795bcb3ec7db0a340b517fd3059620/specification/elastic/resource-manager/Microsoft.Elastic/preview/2023-02-01-preview/examples/Monitors_Delete.json -func ExampleMonitorsClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armelastic.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewMonitorsClient().BeginDelete(ctx, "myResourceGroup", "myMonitor", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} diff --git a/sdk/resourcemanager/elastic/armelastic/operations_client.go b/sdk/resourcemanager/elastic/armelastic/operations_client.go index 1129237f0312..a1f1282fa7f5 100644 --- a/sdk/resourcemanager/elastic/armelastic/operations_client.go +++ b/sdk/resourcemanager/elastic/armelastic/operations_client.go @@ -13,7 +13,7 @@ // 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. -// DO NOT EDIT. +// Code generated by @autorest/go. DO NOT EDIT. package armelastic @@ -36,7 +36,7 @@ type OperationsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { - cl, err := arm.NewClient(moduleName+".OperationsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -48,7 +48,7 @@ func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientO // NewListPager - List all operations provided by Microsoft.Elastic. // -// Generated from API version 2023-02-01-preview +// Generated from API version 2023-11-01-preview // - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[OperationsClientListResponse]{ @@ -56,25 +56,20 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *OperationsClientListResponse) (OperationsClientListResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listCreateRequest(ctx, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "OperationsClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, nil) if err != nil { return OperationsClientListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return OperationsClientListResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return OperationsClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -86,7 +81,7 @@ func (client *OperationsClient) listCreateRequest(ctx context.Context, options * return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-02-01-preview") + reqQP.Set("api-version", "2023-11-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/elastic/armelastic/operations_client_example_test.go b/sdk/resourcemanager/elastic/armelastic/operations_client_example_test.go deleted file mode 100644 index 4e66391319ee..000000000000 --- a/sdk/resourcemanager/elastic/armelastic/operations_client_example_test.go +++ /dev/null @@ -1,63 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. 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. -// DO NOT EDIT. - -package armelastic_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/dbd896bc9a795bcb3ec7db0a340b517fd3059620/specification/elastic/resource-manager/Microsoft.Elastic/preview/2023-02-01-preview/examples/Operations_List.json -func ExampleOperationsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armelastic.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewOperationsClient().NewListPager(nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.OperationListResult = armelastic.OperationListResult{ - // Value: []*armelastic.OperationResult{ - // { - // Name: to.Ptr("Microsoft.Elastic/monitors/write"), - // Display: &armelastic.OperationDisplay{ - // Description: to.Ptr("Write monitors resource"), - // Operation: to.Ptr("write"), - // Provider: to.Ptr("Microsoft.Elastic"), - // Resource: to.Ptr("monitors"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/elastic/armelastic/options.go b/sdk/resourcemanager/elastic/armelastic/options.go new file mode 100644 index 000000000000..b2110a352481 --- /dev/null +++ b/sdk/resourcemanager/elastic/armelastic/options.go @@ -0,0 +1,229 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. 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. +// Code generated by @autorest/go. DO NOT EDIT. + +package armelastic + +// AllTrafficFiltersClientListOptions contains the optional parameters for the AllTrafficFiltersClient.List method. +type AllTrafficFiltersClientListOptions struct { + // placeholder for future optional parameters +} + +// AssociateTrafficFilterClientBeginAssociateOptions contains the optional parameters for the AssociateTrafficFilterClient.BeginAssociate +// method. +type AssociateTrafficFilterClientBeginAssociateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string + + // Ruleset Id of the filter + RulesetID *string +} + +// BillingInfoClientGetOptions contains the optional parameters for the BillingInfoClient.Get method. +type BillingInfoClientGetOptions struct { + // placeholder for future optional parameters +} + +// ConnectedPartnerResourcesClientListOptions contains the optional parameters for the ConnectedPartnerResourcesClient.NewListPager +// method. +type ConnectedPartnerResourcesClientListOptions struct { + // placeholder for future optional parameters +} + +// CreateAndAssociateIPFilterClientBeginCreateOptions contains the optional parameters for the CreateAndAssociateIPFilterClient.BeginCreate +// method. +type CreateAndAssociateIPFilterClientBeginCreateOptions struct { + // List of ips + IPs *string + + // Name of the traffic filter + Name *string + + // Resumes the LRO from the provided token. + ResumeToken string +} + +// CreateAndAssociatePLFilterClientBeginCreateOptions contains the optional parameters for the CreateAndAssociatePLFilterClient.BeginCreate +// method. +type CreateAndAssociatePLFilterClientBeginCreateOptions struct { + // Name of the traffic filter + Name *string + + // Guid of the private endpoint + PrivateEndpointGUID *string + + // Name of the private endpoint + PrivateEndpointName *string + + // Resumes the LRO from the provided token. + ResumeToken string +} + +// DeploymentInfoClientListOptions contains the optional parameters for the DeploymentInfoClient.List method. +type DeploymentInfoClientListOptions struct { + // placeholder for future optional parameters +} + +// DetachAndDeleteTrafficFilterClientDeleteOptions contains the optional parameters for the DetachAndDeleteTrafficFilterClient.Delete +// method. +type DetachAndDeleteTrafficFilterClientDeleteOptions struct { + // Ruleset Id of the filter + RulesetID *string +} + +// DetachTrafficFilterClientBeginUpdateOptions contains the optional parameters for the DetachTrafficFilterClient.BeginUpdate +// method. +type DetachTrafficFilterClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string + + // Ruleset Id of the filter + RulesetID *string +} + +// ExternalUserClientCreateOrUpdateOptions contains the optional parameters for the ExternalUserClient.CreateOrUpdate method. +type ExternalUserClientCreateOrUpdateOptions struct { + // Elastic External User Creation Parameters + Body *ExternalUserInfo +} + +// ListAssociatedTrafficFiltersClientListOptions contains the optional parameters for the ListAssociatedTrafficFiltersClient.List +// method. +type ListAssociatedTrafficFiltersClientListOptions struct { + // placeholder for future optional parameters +} + +// MonitorClientBeginUpgradeOptions contains the optional parameters for the MonitorClient.BeginUpgrade method. +type MonitorClientBeginUpgradeOptions struct { + // Elastic Monitor Upgrade Parameters + Body *MonitorUpgrade + + // Resumes the LRO from the provided token. + ResumeToken string +} + +// MonitoredResourcesClientListOptions contains the optional parameters for the MonitoredResourcesClient.NewListPager method. +type MonitoredResourcesClientListOptions struct { + // placeholder for future optional parameters +} + +// MonitorsClientBeginCreateOptions contains the optional parameters for the MonitorsClient.BeginCreate method. +type MonitorsClientBeginCreateOptions struct { + // Elastic monitor resource model + Body *MonitorResource + + // Resumes the LRO from the provided token. + ResumeToken string +} + +// MonitorsClientBeginDeleteOptions contains the optional parameters for the MonitorsClient.BeginDelete method. +type MonitorsClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// MonitorsClientGetOptions contains the optional parameters for the MonitorsClient.Get method. +type MonitorsClientGetOptions struct { + // placeholder for future optional parameters +} + +// MonitorsClientListByResourceGroupOptions contains the optional parameters for the MonitorsClient.NewListByResourceGroupPager +// method. +type MonitorsClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// MonitorsClientListOptions contains the optional parameters for the MonitorsClient.NewListPager method. +type MonitorsClientListOptions struct { + // placeholder for future optional parameters +} + +// MonitorsClientUpdateOptions contains the optional parameters for the MonitorsClient.Update method. +type MonitorsClientUpdateOptions struct { + // Elastic resource model update parameters. + Body *MonitorResourceUpdateParameters +} + +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. +type OperationsClientListOptions struct { + // placeholder for future optional parameters +} + +// OrganizationsClientGetAPIKeyOptions contains the optional parameters for the OrganizationsClient.GetAPIKey method. +type OrganizationsClientGetAPIKeyOptions struct { + // Email Id parameter of the User Organization, of which the API Key must be returned + Body *UserEmailID +} + +// OrganizationsClientGetElasticToAzureSubscriptionMappingOptions contains the optional parameters for the OrganizationsClient.GetElasticToAzureSubscriptionMapping +// method. +type OrganizationsClientGetElasticToAzureSubscriptionMappingOptions struct { + // placeholder for future optional parameters +} + +// TagRulesClientBeginDeleteOptions contains the optional parameters for the TagRulesClient.BeginDelete method. +type TagRulesClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// TagRulesClientCreateOrUpdateOptions contains the optional parameters for the TagRulesClient.CreateOrUpdate method. +type TagRulesClientCreateOrUpdateOptions struct { + // request body of MonitoringTagRules + Body *MonitoringTagRules +} + +// TagRulesClientGetOptions contains the optional parameters for the TagRulesClient.Get method. +type TagRulesClientGetOptions struct { + // placeholder for future optional parameters +} + +// TagRulesClientListOptions contains the optional parameters for the TagRulesClient.NewListPager method. +type TagRulesClientListOptions struct { + // placeholder for future optional parameters +} + +// TrafficFiltersClientDeleteOptions contains the optional parameters for the TrafficFiltersClient.Delete method. +type TrafficFiltersClientDeleteOptions struct { + // Ruleset Id of the filter + RulesetID *string +} + +// UpgradableVersionsClientDetailsOptions contains the optional parameters for the UpgradableVersionsClient.Details method. +type UpgradableVersionsClientDetailsOptions struct { + // placeholder for future optional parameters +} + +// VMCollectionClientUpdateOptions contains the optional parameters for the VMCollectionClient.Update method. +type VMCollectionClientUpdateOptions struct { + // VM resource Id + Body *VMCollectionUpdate +} + +// VMHostClientListOptions contains the optional parameters for the VMHostClient.NewListPager method. +type VMHostClientListOptions struct { + // placeholder for future optional parameters +} + +// VMIngestionClientDetailsOptions contains the optional parameters for the VMIngestionClient.Details method. +type VMIngestionClientDetailsOptions struct { + // placeholder for future optional parameters +} + +// VersionsClientListOptions contains the optional parameters for the VersionsClient.NewListPager method. +type VersionsClientListOptions struct { + // placeholder for future optional parameters +} diff --git a/sdk/resourcemanager/elastic/armelastic/organizations_client.go b/sdk/resourcemanager/elastic/armelastic/organizations_client.go index 30606f13b2cb..bbd6d1256b3e 100644 --- a/sdk/resourcemanager/elastic/armelastic/organizations_client.go +++ b/sdk/resourcemanager/elastic/armelastic/organizations_client.go @@ -13,7 +13,7 @@ // 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. -// DO NOT EDIT. +// Code generated by @autorest/go. DO NOT EDIT. package armelastic @@ -37,11 +37,11 @@ type OrganizationsClient struct { } // NewOrganizationsClient creates a new instance of OrganizationsClient with the specified values. -// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewOrganizationsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*OrganizationsClient, error) { - cl, err := arm.NewClient(moduleName+".OrganizationsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -56,21 +56,28 @@ func NewOrganizationsClient(subscriptionID string, credential azcore.TokenCreden // Organization. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-02-01-preview +// Generated from API version 2023-11-01-preview // - options - OrganizationsClientGetAPIKeyOptions contains the optional parameters for the OrganizationsClient.GetAPIKey method. func (client *OrganizationsClient) GetAPIKey(ctx context.Context, options *OrganizationsClientGetAPIKeyOptions) (OrganizationsClientGetAPIKeyResponse, error) { + var err error + const operationName = "OrganizationsClient.GetAPIKey" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.getAPIKeyCreateRequest(ctx, options) if err != nil { return OrganizationsClientGetAPIKeyResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return OrganizationsClientGetAPIKeyResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return OrganizationsClientGetAPIKeyResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return OrganizationsClientGetAPIKeyResponse{}, err } - return client.getAPIKeyHandleResponse(resp) + resp, err := client.getAPIKeyHandleResponse(httpResp) + return resp, err } // getAPIKeyCreateRequest creates the GetAPIKey request. @@ -85,11 +92,14 @@ func (client *OrganizationsClient) getAPIKeyCreateRequest(ctx context.Context, o return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-02-01-preview") + reqQP.Set("api-version", "2023-11-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.Body != nil { - return req, runtime.MarshalAsJSON(req, *options.Body) + if err := runtime.MarshalAsJSON(req, *options.Body); err != nil { + return nil, err + } + return req, nil } return req, nil } @@ -102,3 +112,59 @@ func (client *OrganizationsClient) getAPIKeyHandleResponse(resp *http.Response) } return result, nil } + +// GetElasticToAzureSubscriptionMapping - Get Elastic Organization To Azure Subscription Mapping details for the logged-in +// user. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-01-preview +// - options - OrganizationsClientGetElasticToAzureSubscriptionMappingOptions contains the optional parameters for the OrganizationsClient.GetElasticToAzureSubscriptionMapping +// method. +func (client *OrganizationsClient) GetElasticToAzureSubscriptionMapping(ctx context.Context, options *OrganizationsClientGetElasticToAzureSubscriptionMappingOptions) (OrganizationsClientGetElasticToAzureSubscriptionMappingResponse, error) { + var err error + const operationName = "OrganizationsClient.GetElasticToAzureSubscriptionMapping" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getElasticToAzureSubscriptionMappingCreateRequest(ctx, options) + if err != nil { + return OrganizationsClientGetElasticToAzureSubscriptionMappingResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return OrganizationsClientGetElasticToAzureSubscriptionMappingResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return OrganizationsClientGetElasticToAzureSubscriptionMappingResponse{}, err + } + resp, err := client.getElasticToAzureSubscriptionMappingHandleResponse(httpResp) + return resp, err +} + +// getElasticToAzureSubscriptionMappingCreateRequest creates the GetElasticToAzureSubscriptionMapping request. +func (client *OrganizationsClient) getElasticToAzureSubscriptionMappingCreateRequest(ctx context.Context, options *OrganizationsClientGetElasticToAzureSubscriptionMappingOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Elastic/getElasticOrganizationToAzureSubscriptionMapping" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getElasticToAzureSubscriptionMappingHandleResponse handles the GetElasticToAzureSubscriptionMapping response. +func (client *OrganizationsClient) getElasticToAzureSubscriptionMappingHandleResponse(resp *http.Response) (OrganizationsClientGetElasticToAzureSubscriptionMappingResponse, error) { + result := OrganizationsClientGetElasticToAzureSubscriptionMappingResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.OrganizationToAzureSubscriptionMappingResponse); err != nil { + return OrganizationsClientGetElasticToAzureSubscriptionMappingResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/elastic/armelastic/organizations_client_example_test.go b/sdk/resourcemanager/elastic/armelastic/organizations_client_example_test.go deleted file mode 100644 index 30f043dbcc02..000000000000 --- a/sdk/resourcemanager/elastic/armelastic/organizations_client_example_test.go +++ /dev/null @@ -1,51 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. 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. -// DO NOT EDIT. - -package armelastic_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/dbd896bc9a795bcb3ec7db0a340b517fd3059620/specification/elastic/resource-manager/Microsoft.Elastic/preview/2023-02-01-preview/examples/Organizations_GetApiKey.json -func ExampleOrganizationsClient_GetAPIKey() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armelastic.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewOrganizationsClient().GetAPIKey(ctx, &armelastic.OrganizationsClientGetAPIKeyOptions{Body: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.UserAPIKeyResponse = armelastic.UserAPIKeyResponse{ - // Properties: &armelastic.UserAPIKeyResponseProperties{ - // APIKey: to.Ptr("AbCdEfGhIjKlMnOpQrStUvWxYz"), - // }, - // } -} diff --git a/sdk/resourcemanager/elastic/armelastic/response_types.go b/sdk/resourcemanager/elastic/armelastic/response_types.go index 66eca2ad7c13..c1caf473e840 100644 --- a/sdk/resourcemanager/elastic/armelastic/response_types.go +++ b/sdk/resourcemanager/elastic/armelastic/response_types.go @@ -13,12 +13,13 @@ // 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. -// DO NOT EDIT. +// Code generated by @autorest/go. DO NOT EDIT. package armelastic // AllTrafficFiltersClientListResponse contains the response from method AllTrafficFiltersClient.List. type AllTrafficFiltersClientListResponse struct { + // List of elastic traffic filters in the account TrafficFilterResponse } @@ -27,6 +28,18 @@ type AssociateTrafficFilterClientAssociateResponse struct { // placeholder for future response values } +// BillingInfoClientGetResponse contains the response from method BillingInfoClient.Get. +type BillingInfoClientGetResponse struct { + // Marketplace Subscription and Organization details to which resource gets billed into. + BillingInfoResponse +} + +// ConnectedPartnerResourcesClientListResponse contains the response from method ConnectedPartnerResourcesClient.NewListPager. +type ConnectedPartnerResourcesClientListResponse struct { + // List of all active elastic deployments. + ConnectedPartnerResourcesListResponse +} + // CreateAndAssociateIPFilterClientCreateResponse contains the response from method CreateAndAssociateIPFilterClient.BeginCreate. type CreateAndAssociateIPFilterClientCreateResponse struct { // placeholder for future response values @@ -39,6 +52,7 @@ type CreateAndAssociatePLFilterClientCreateResponse struct { // DeploymentInfoClientListResponse contains the response from method DeploymentInfoClient.List. type DeploymentInfoClientListResponse struct { + // The properties of deployment in Elastic cloud corresponding to the Elastic monitor resource. DeploymentInfoResponse } @@ -54,11 +68,13 @@ type DetachTrafficFilterClientUpdateResponse struct { // ExternalUserClientCreateOrUpdateResponse contains the response from method ExternalUserClient.CreateOrUpdate. type ExternalUserClientCreateOrUpdateResponse struct { + // The properties of the response we got from elastic while creating external user ExternalUserCreationResponse } // ListAssociatedTrafficFiltersClientListResponse contains the response from method ListAssociatedTrafficFiltersClient.List. type ListAssociatedTrafficFiltersClientListResponse struct { + // List of elastic traffic filters in the account TrafficFilterResponse } @@ -69,11 +85,13 @@ type MonitorClientUpgradeResponse struct { // MonitoredResourcesClientListResponse contains the response from method MonitoredResourcesClient.NewListPager. type MonitoredResourcesClientListResponse struct { + // Response of a list operation. MonitoredResourceListResponse } // MonitorsClientCreateResponse contains the response from method MonitorsClient.BeginCreate. type MonitorsClientCreateResponse struct { + // Monitor resource. MonitorResource } @@ -84,36 +102,49 @@ type MonitorsClientDeleteResponse struct { // MonitorsClientGetResponse contains the response from method MonitorsClient.Get. type MonitorsClientGetResponse struct { + // Monitor resource. MonitorResource } // MonitorsClientListByResourceGroupResponse contains the response from method MonitorsClient.NewListByResourceGroupPager. type MonitorsClientListByResourceGroupResponse struct { + // Response of a list operation. MonitorResourceListResponse } // MonitorsClientListResponse contains the response from method MonitorsClient.NewListPager. type MonitorsClientListResponse struct { + // Response of a list operation. MonitorResourceListResponse } // MonitorsClientUpdateResponse contains the response from method MonitorsClient.Update. type MonitorsClientUpdateResponse struct { + // Monitor resource. MonitorResource } // OperationsClientListResponse contains the response from method OperationsClient.NewListPager. type OperationsClientListResponse struct { + // Result of GET request to list the Microsoft.Elastic operations. OperationListResult } // OrganizationsClientGetAPIKeyResponse contains the response from method OrganizationsClient.GetAPIKey. type OrganizationsClientGetAPIKeyResponse struct { + // The User Api Key created for the Organization associated with the User Email Id that was passed in the request UserAPIKeyResponse } +// OrganizationsClientGetElasticToAzureSubscriptionMappingResponse contains the response from method OrganizationsClient.GetElasticToAzureSubscriptionMapping. +type OrganizationsClientGetElasticToAzureSubscriptionMappingResponse struct { + // The Azure Subscription ID to which the Organization of the logged in user belongs and gets billed into. + OrganizationToAzureSubscriptionMappingResponse +} + // TagRulesClientCreateOrUpdateResponse contains the response from method TagRulesClient.CreateOrUpdate. type TagRulesClientCreateOrUpdateResponse struct { + // Capture logs and metrics of Azure resources based on ARM tags. MonitoringTagRules } @@ -124,11 +155,13 @@ type TagRulesClientDeleteResponse struct { // TagRulesClientGetResponse contains the response from method TagRulesClient.Get. type TagRulesClientGetResponse struct { + // Capture logs and metrics of Azure resources based on ARM tags. MonitoringTagRules } // TagRulesClientListResponse contains the response from method TagRulesClient.NewListPager. type TagRulesClientListResponse struct { + // Response of a list operation. MonitoringTagRulesListResponse } @@ -139,6 +172,7 @@ type TrafficFiltersClientDeleteResponse struct { // UpgradableVersionsClientDetailsResponse contains the response from method UpgradableVersionsClient.Details. type UpgradableVersionsClientDetailsResponse struct { + // Stack Versions that this version can upgrade to UpgradableVersionsList } @@ -149,15 +183,18 @@ type VMCollectionClientUpdateResponse struct { // VMHostClientListResponse contains the response from method VMHostClient.NewListPager. type VMHostClientListResponse struct { + // Response of a list operation. VMHostListResponse } // VMIngestionClientDetailsResponse contains the response from method VMIngestionClient.Details. type VMIngestionClientDetailsResponse struct { + // The vm ingestion details to install an agent. VMIngestionDetailsResponse } // VersionsClientListResponse contains the response from method VersionsClient.NewListPager. type VersionsClientListResponse struct { + // List of elastic versions available in a region. VersionsListResponse } diff --git a/sdk/resourcemanager/elastic/armelastic/tagrules_client.go b/sdk/resourcemanager/elastic/armelastic/tagrules_client.go index d244a9e2c72f..8adf0bc8a2d4 100644 --- a/sdk/resourcemanager/elastic/armelastic/tagrules_client.go +++ b/sdk/resourcemanager/elastic/armelastic/tagrules_client.go @@ -13,7 +13,7 @@ // 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. -// DO NOT EDIT. +// Code generated by @autorest/go. DO NOT EDIT. package armelastic @@ -37,11 +37,11 @@ type TagRulesClient struct { } // NewTagRulesClient creates a new instance of TagRulesClient with the specified values. -// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewTagRulesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*TagRulesClient, error) { - cl, err := arm.NewClient(moduleName+".TagRulesClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -55,24 +55,31 @@ func NewTagRulesClient(subscriptionID string, credential azcore.TokenCredential, // CreateOrUpdate - Create or update a tag rule set for a given monitor resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-02-01-preview -// - resourceGroupName - The name of the resource group to which the Elastic resource belongs. +// Generated from API version 2023-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - monitorName - Monitor resource name // - ruleSetName - Tag Rule Set resource name // - options - TagRulesClientCreateOrUpdateOptions contains the optional parameters for the TagRulesClient.CreateOrUpdate method. func (client *TagRulesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, monitorName string, ruleSetName string, options *TagRulesClientCreateOrUpdateOptions) (TagRulesClientCreateOrUpdateResponse, error) { + var err error + const operationName = "TagRulesClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, monitorName, ruleSetName, options) if err != nil { return TagRulesClientCreateOrUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return TagRulesClientCreateOrUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return TagRulesClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return TagRulesClientCreateOrUpdateResponse{}, err } - return client.createOrUpdateHandleResponse(resp) + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err } // createOrUpdateCreateRequest creates the CreateOrUpdate request. @@ -99,11 +106,14 @@ func (client *TagRulesClient) createOrUpdateCreateRequest(ctx context.Context, r return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-02-01-preview") + reqQP.Set("api-version", "2023-11-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.Body != nil { - return req, runtime.MarshalAsJSON(req, *options.Body) + if err := runtime.MarshalAsJSON(req, *options.Body); err != nil { + return nil, err + } + return req, nil } return req, nil } @@ -120,8 +130,8 @@ func (client *TagRulesClient) createOrUpdateHandleResponse(resp *http.Response) // BeginDelete - Delete a tag rule set for a given monitor resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-02-01-preview -// - resourceGroupName - The name of the resource group to which the Elastic resource belongs. +// Generated from API version 2023-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - monitorName - Monitor resource name // - ruleSetName - Tag Rule Set resource name // - options - TagRulesClientBeginDeleteOptions contains the optional parameters for the TagRulesClient.BeginDelete method. @@ -131,29 +141,40 @@ func (client *TagRulesClient) BeginDelete(ctx context.Context, resourceGroupName if err != nil { return nil, err } - return runtime.NewPoller[TagRulesClientDeleteResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[TagRulesClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[TagRulesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[TagRulesClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) } } // Delete - Delete a tag rule set for a given monitor resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-02-01-preview +// Generated from API version 2023-11-01-preview func (client *TagRulesClient) deleteOperation(ctx context.Context, resourceGroupName string, monitorName string, ruleSetName string, options *TagRulesClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "TagRulesClient.BeginDelete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.deleteCreateRequest(ctx, resourceGroupName, monitorName, ruleSetName, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // deleteCreateRequest creates the Delete request. @@ -180,7 +201,7 @@ func (client *TagRulesClient) deleteCreateRequest(ctx context.Context, resourceG return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-02-01-preview") + reqQP.Set("api-version", "2023-11-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -189,24 +210,31 @@ func (client *TagRulesClient) deleteCreateRequest(ctx context.Context, resourceG // Get - Get a tag rule set for a given monitor resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-02-01-preview -// - resourceGroupName - The name of the resource group to which the Elastic resource belongs. +// Generated from API version 2023-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - monitorName - Monitor resource name // - ruleSetName - Tag Rule Set resource name // - options - TagRulesClientGetOptions contains the optional parameters for the TagRulesClient.Get method. func (client *TagRulesClient) Get(ctx context.Context, resourceGroupName string, monitorName string, ruleSetName string, options *TagRulesClientGetOptions) (TagRulesClientGetResponse, error) { + var err error + const operationName = "TagRulesClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.getCreateRequest(ctx, resourceGroupName, monitorName, ruleSetName, options) if err != nil { return TagRulesClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return TagRulesClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return TagRulesClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return TagRulesClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -233,7 +261,7 @@ func (client *TagRulesClient) getCreateRequest(ctx context.Context, resourceGrou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-02-01-preview") + reqQP.Set("api-version", "2023-11-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -250,8 +278,8 @@ func (client *TagRulesClient) getHandleResponse(resp *http.Response) (TagRulesCl // NewListPager - List the tag rules for a given monitor resource. // -// Generated from API version 2023-02-01-preview -// - resourceGroupName - The name of the resource group to which the Elastic resource belongs. +// Generated from API version 2023-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - monitorName - Monitor resource name // - options - TagRulesClientListOptions contains the optional parameters for the TagRulesClient.NewListPager method. func (client *TagRulesClient) NewListPager(resourceGroupName string, monitorName string, options *TagRulesClientListOptions) *runtime.Pager[TagRulesClientListResponse] { @@ -260,25 +288,20 @@ func (client *TagRulesClient) NewListPager(resourceGroupName string, monitorName return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *TagRulesClientListResponse) (TagRulesClientListResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listCreateRequest(ctx, resourceGroupName, monitorName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "TagRulesClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, monitorName, options) + }, nil) if err != nil { return TagRulesClientListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return TagRulesClientListResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return TagRulesClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -302,7 +325,7 @@ func (client *TagRulesClient) listCreateRequest(ctx context.Context, resourceGro return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-02-01-preview") + reqQP.Set("api-version", "2023-11-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/elastic/armelastic/tagrules_client_example_test.go b/sdk/resourcemanager/elastic/armelastic/tagrules_client_example_test.go deleted file mode 100644 index f5df71fbe0bd..000000000000 --- a/sdk/resourcemanager/elastic/armelastic/tagrules_client_example_test.go +++ /dev/null @@ -1,187 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. 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. -// DO NOT EDIT. - -package armelastic_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/dbd896bc9a795bcb3ec7db0a340b517fd3059620/specification/elastic/resource-manager/Microsoft.Elastic/preview/2023-02-01-preview/examples/TagRules_List.json -func ExampleTagRulesClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armelastic.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewTagRulesClient().NewListPager("myResourceGroup", "myMonitor", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.MonitoringTagRulesListResponse = armelastic.MonitoringTagRulesListResponse{ - // Value: []*armelastic.MonitoringTagRules{ - // { - // Name: to.Ptr("default"), - // Type: to.Ptr("Microsoft.Datadog/monitors/tagRules"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Datadog/monitors/myMonitor/tagRules/default"), - // Properties: &armelastic.MonitoringTagRulesProperties{ - // LogRules: &armelastic.LogRules{ - // FilteringTags: []*armelastic.FilteringTag{ - // { - // Name: to.Ptr("Environment"), - // Action: to.Ptr(armelastic.TagActionInclude), - // Value: to.Ptr("Prod"), - // }, - // { - // Name: to.Ptr("Environment"), - // Action: to.Ptr(armelastic.TagActionExclude), - // Value: to.Ptr("Dev"), - // }}, - // SendAADLogs: to.Ptr(false), - // SendActivityLogs: to.Ptr(true), - // SendSubscriptionLogs: to.Ptr(true), - // }, - // ProvisioningState: to.Ptr(armelastic.ProvisioningStateSucceeded), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/dbd896bc9a795bcb3ec7db0a340b517fd3059620/specification/elastic/resource-manager/Microsoft.Elastic/preview/2023-02-01-preview/examples/TagRules_CreateOrUpdate.json -func ExampleTagRulesClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armelastic.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewTagRulesClient().CreateOrUpdate(ctx, "myResourceGroup", "myMonitor", "default", &armelastic.TagRulesClientCreateOrUpdateOptions{Body: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.MonitoringTagRules = armelastic.MonitoringTagRules{ - // Name: to.Ptr("default"), - // Type: to.Ptr("Microsoft.Datadog/monitors/tagRules"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Datadog/monitors/myMonitor/tagRules/default"), - // Properties: &armelastic.MonitoringTagRulesProperties{ - // LogRules: &armelastic.LogRules{ - // FilteringTags: []*armelastic.FilteringTag{ - // { - // Name: to.Ptr("Environment"), - // Action: to.Ptr(armelastic.TagActionInclude), - // Value: to.Ptr("Prod"), - // }, - // { - // Name: to.Ptr("Environment"), - // Action: to.Ptr(armelastic.TagActionExclude), - // Value: to.Ptr("Dev"), - // }}, - // SendAADLogs: to.Ptr(false), - // SendActivityLogs: to.Ptr(true), - // SendSubscriptionLogs: to.Ptr(true), - // }, - // ProvisioningState: to.Ptr(armelastic.ProvisioningStateSucceeded), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/dbd896bc9a795bcb3ec7db0a340b517fd3059620/specification/elastic/resource-manager/Microsoft.Elastic/preview/2023-02-01-preview/examples/TagRules_Get.json -func ExampleTagRulesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armelastic.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewTagRulesClient().Get(ctx, "myResourceGroup", "myMonitor", "default", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.MonitoringTagRules = armelastic.MonitoringTagRules{ - // Name: to.Ptr("default"), - // Type: to.Ptr("Microsoft.Datadog/monitors/tagRules"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Datadog/monitors/myMonitor/tagRules/default"), - // Properties: &armelastic.MonitoringTagRulesProperties{ - // LogRules: &armelastic.LogRules{ - // FilteringTags: []*armelastic.FilteringTag{ - // { - // Name: to.Ptr("Environment"), - // Action: to.Ptr(armelastic.TagActionInclude), - // Value: to.Ptr("Prod"), - // }, - // { - // Name: to.Ptr("Environment"), - // Action: to.Ptr(armelastic.TagActionExclude), - // Value: to.Ptr("Dev"), - // }}, - // SendAADLogs: to.Ptr(false), - // SendActivityLogs: to.Ptr(true), - // SendSubscriptionLogs: to.Ptr(true), - // }, - // ProvisioningState: to.Ptr(armelastic.ProvisioningStateSucceeded), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/dbd896bc9a795bcb3ec7db0a340b517fd3059620/specification/elastic/resource-manager/Microsoft.Elastic/preview/2023-02-01-preview/examples/TagRules_Delete.json -func ExampleTagRulesClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armelastic.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewTagRulesClient().BeginDelete(ctx, "myResourceGroup", "myMonitor", "default", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} diff --git a/sdk/resourcemanager/elastic/armelastic/time_rfc3339.go b/sdk/resourcemanager/elastic/armelastic/time_rfc3339.go index f95524655b97..fe22f723f088 100644 --- a/sdk/resourcemanager/elastic/armelastic/time_rfc3339.go +++ b/sdk/resourcemanager/elastic/armelastic/time_rfc3339.go @@ -13,7 +13,7 @@ // 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. -// DO NOT EDIT. +// Code generated by @autorest/go. DO NOT EDIT. package armelastic @@ -27,50 +27,50 @@ import ( "time" ) -const ( - utcLayoutJSON = `"2006-01-02T15:04:05.999999999"` - utcLayout = "2006-01-02T15:04:05.999999999" - rfc3339JSON = `"` + time.RFC3339Nano + `"` -) - // Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) -type timeRFC3339 time.Time +const ( + utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` + utcDateTime = "2006-01-02T15:04:05.999999999" + dateTimeJSON = `"` + time.RFC3339Nano + `"` +) + +type dateTimeRFC3339 time.Time -func (t timeRFC3339) MarshalJSON() (json []byte, err error) { +func (t dateTimeRFC3339) MarshalJSON() ([]byte, error) { tt := time.Time(t) return tt.MarshalJSON() } -func (t timeRFC3339) MarshalText() (text []byte, err error) { +func (t dateTimeRFC3339) MarshalText() ([]byte, error) { tt := time.Time(t) return tt.MarshalText() } -func (t *timeRFC3339) UnmarshalJSON(data []byte) error { - layout := utcLayoutJSON +func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { + layout := utcDateTimeJSON if tzOffsetRegex.Match(data) { - layout = rfc3339JSON + layout = dateTimeJSON } return t.Parse(layout, string(data)) } -func (t *timeRFC3339) UnmarshalText(data []byte) (err error) { - layout := utcLayout +func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + layout := utcDateTime if tzOffsetRegex.Match(data) { layout = time.RFC3339Nano } return t.Parse(layout, string(data)) } -func (t *timeRFC3339) Parse(layout, value string) error { +func (t *dateTimeRFC3339) Parse(layout, value string) error { p, err := time.Parse(layout, strings.ToUpper(value)) - *t = timeRFC3339(p) + *t = dateTimeRFC3339(p) return err } -func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { +func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return } else if azcore.IsNullValue(t) { @@ -79,14 +79,14 @@ func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { } else if reflect.ValueOf(t).IsNil() { return } - m[k] = (*timeRFC3339)(t) + m[k] = (*dateTimeRFC3339)(t) } -func unpopulateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { +func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { if data == nil || strings.EqualFold(string(data), "null") { return nil } - var aux timeRFC3339 + var aux dateTimeRFC3339 if err := json.Unmarshal(data, &aux); err != nil { return fmt.Errorf("struct field %s: %v", fn, err) } diff --git a/sdk/resourcemanager/elastic/armelastic/trafficfilters_client.go b/sdk/resourcemanager/elastic/armelastic/trafficfilters_client.go index f9496ea07a1a..108584d53377 100644 --- a/sdk/resourcemanager/elastic/armelastic/trafficfilters_client.go +++ b/sdk/resourcemanager/elastic/armelastic/trafficfilters_client.go @@ -13,7 +13,7 @@ // 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. -// DO NOT EDIT. +// Code generated by @autorest/go. DO NOT EDIT. package armelastic @@ -37,11 +37,11 @@ type TrafficFiltersClient struct { } // NewTrafficFiltersClient creates a new instance of TrafficFiltersClient with the specified values. -// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewTrafficFiltersClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*TrafficFiltersClient, error) { - cl, err := arm.NewClient(moduleName+".TrafficFiltersClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -55,21 +55,27 @@ func NewTrafficFiltersClient(subscriptionID string, credential azcore.TokenCrede // Delete - Delete traffic filter from the account. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-02-01-preview -// - resourceGroupName - The name of the resource group to which the Elastic resource belongs. +// Generated from API version 2023-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - monitorName - Monitor resource name // - options - TrafficFiltersClientDeleteOptions contains the optional parameters for the TrafficFiltersClient.Delete method. func (client *TrafficFiltersClient) Delete(ctx context.Context, resourceGroupName string, monitorName string, options *TrafficFiltersClientDeleteOptions) (TrafficFiltersClientDeleteResponse, error) { + var err error + const operationName = "TrafficFiltersClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.deleteCreateRequest(ctx, resourceGroupName, monitorName, options) if err != nil { return TrafficFiltersClientDeleteResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return TrafficFiltersClientDeleteResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return TrafficFiltersClientDeleteResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return TrafficFiltersClientDeleteResponse{}, err } return TrafficFiltersClientDeleteResponse{}, nil } @@ -94,7 +100,7 @@ func (client *TrafficFiltersClient) deleteCreateRequest(ctx context.Context, res return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-02-01-preview") + reqQP.Set("api-version", "2023-11-01-preview") if options != nil && options.RulesetID != nil { reqQP.Set("rulesetId", *options.RulesetID) } diff --git a/sdk/resourcemanager/elastic/armelastic/trafficfilters_client_example_test.go b/sdk/resourcemanager/elastic/armelastic/trafficfilters_client_example_test.go deleted file mode 100644 index f99ab24bb6e1..000000000000 --- a/sdk/resourcemanager/elastic/armelastic/trafficfilters_client_example_test.go +++ /dev/null @@ -1,44 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. 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. -// DO NOT EDIT. - -package armelastic_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/dbd896bc9a795bcb3ec7db0a340b517fd3059620/specification/elastic/resource-manager/Microsoft.Elastic/preview/2023-02-01-preview/examples/TrafficFilters_Delete.json -func ExampleTrafficFiltersClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armelastic.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewTrafficFiltersClient().Delete(ctx, "myResourceGroup", "myMonitor", &armelastic.TrafficFiltersClientDeleteOptions{RulesetID: to.Ptr("31d91b5afb6f4c2eaaf104c97b1991dd")}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/elastic/armelastic/upgradableversions_client.go b/sdk/resourcemanager/elastic/armelastic/upgradableversions_client.go index bc73c2a0072b..29a8edfa20ba 100644 --- a/sdk/resourcemanager/elastic/armelastic/upgradableversions_client.go +++ b/sdk/resourcemanager/elastic/armelastic/upgradableversions_client.go @@ -13,7 +13,7 @@ // 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. -// DO NOT EDIT. +// Code generated by @autorest/go. DO NOT EDIT. package armelastic @@ -37,11 +37,11 @@ type UpgradableVersionsClient struct { } // NewUpgradableVersionsClient creates a new instance of UpgradableVersionsClient with the specified values. -// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewUpgradableVersionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*UpgradableVersionsClient, error) { - cl, err := arm.NewClient(moduleName+".UpgradableVersionsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -55,24 +55,31 @@ func NewUpgradableVersionsClient(subscriptionID string, credential azcore.TokenC // Details - List of upgradable versions for a given monitor resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-02-01-preview -// - resourceGroupName - The name of the resource group to which the Elastic resource belongs. +// Generated from API version 2023-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - monitorName - Monitor resource name // - options - UpgradableVersionsClientDetailsOptions contains the optional parameters for the UpgradableVersionsClient.Details // method. func (client *UpgradableVersionsClient) Details(ctx context.Context, resourceGroupName string, monitorName string, options *UpgradableVersionsClientDetailsOptions) (UpgradableVersionsClientDetailsResponse, error) { + var err error + const operationName = "UpgradableVersionsClient.Details" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.detailsCreateRequest(ctx, resourceGroupName, monitorName, options) if err != nil { return UpgradableVersionsClientDetailsResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return UpgradableVersionsClientDetailsResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return UpgradableVersionsClientDetailsResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return UpgradableVersionsClientDetailsResponse{}, err } - return client.detailsHandleResponse(resp) + resp, err := client.detailsHandleResponse(httpResp) + return resp, err } // detailsCreateRequest creates the Details request. @@ -95,7 +102,7 @@ func (client *UpgradableVersionsClient) detailsCreateRequest(ctx context.Context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-02-01-preview") + reqQP.Set("api-version", "2023-11-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/elastic/armelastic/upgradableversions_client_example_test.go b/sdk/resourcemanager/elastic/armelastic/upgradableversions_client_example_test.go deleted file mode 100644 index d1b3806ec723..000000000000 --- a/sdk/resourcemanager/elastic/armelastic/upgradableversions_client_example_test.go +++ /dev/null @@ -1,52 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. 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. -// DO NOT EDIT. - -package armelastic_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/dbd896bc9a795bcb3ec7db0a340b517fd3059620/specification/elastic/resource-manager/Microsoft.Elastic/preview/2023-02-01-preview/examples/UpgradableVersions_Details.json -func ExampleUpgradableVersionsClient_Details() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armelastic.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewUpgradableVersionsClient().Details(ctx, "myResourceGroup", "myMonitor", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.UpgradableVersionsList = armelastic.UpgradableVersionsList{ - // CurrentVersion: to.Ptr("7.15.0"), - // UpgradableVersions: []*string{ - // to.Ptr("7.15.1"), - // to.Ptr("7.16.0")}, - // } -} diff --git a/sdk/resourcemanager/elastic/armelastic/versions_client.go b/sdk/resourcemanager/elastic/armelastic/versions_client.go index 0731e7208569..702fc8c4e5f1 100644 --- a/sdk/resourcemanager/elastic/armelastic/versions_client.go +++ b/sdk/resourcemanager/elastic/armelastic/versions_client.go @@ -13,7 +13,7 @@ // 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. -// DO NOT EDIT. +// Code generated by @autorest/go. DO NOT EDIT. package armelastic @@ -37,11 +37,11 @@ type VersionsClient struct { } // NewVersionsClient creates a new instance of VersionsClient with the specified values. -// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewVersionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*VersionsClient, error) { - cl, err := arm.NewClient(moduleName+".VersionsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -54,7 +54,7 @@ func NewVersionsClient(subscriptionID string, credential azcore.TokenCredential, // NewListPager - Get a list of available versions for a region. // -// Generated from API version 2023-02-01-preview +// Generated from API version 2023-11-01-preview // - region - Region where elastic deployment will take place. // - options - VersionsClientListOptions contains the optional parameters for the VersionsClient.NewListPager method. func (client *VersionsClient) NewListPager(region string, options *VersionsClientListOptions) *runtime.Pager[VersionsClientListResponse] { @@ -63,25 +63,20 @@ func (client *VersionsClient) NewListPager(region string, options *VersionsClien return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *VersionsClientListResponse) (VersionsClientListResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listCreateRequest(ctx, region, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "VersionsClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, region, options) + }, nil) if err != nil { return VersionsClientListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return VersionsClientListResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return VersionsClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -97,7 +92,7 @@ func (client *VersionsClient) listCreateRequest(ctx context.Context, region stri return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-02-01-preview") + reqQP.Set("api-version", "2023-11-01-preview") reqQP.Set("region", region) req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} diff --git a/sdk/resourcemanager/elastic/armelastic/versions_client_example_test.go b/sdk/resourcemanager/elastic/armelastic/versions_client_example_test.go deleted file mode 100644 index bb40611f6426..000000000000 --- a/sdk/resourcemanager/elastic/armelastic/versions_client_example_test.go +++ /dev/null @@ -1,59 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. 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. -// DO NOT EDIT. - -package armelastic_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/dbd896bc9a795bcb3ec7db0a340b517fd3059620/specification/elastic/resource-manager/Microsoft.Elastic/preview/2023-02-01-preview/examples/ElasticVersions_List.json -func ExampleVersionsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armelastic.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewVersionsClient().NewListPager("myregion", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.VersionsListResponse = armelastic.VersionsListResponse{ - // Value: []*armelastic.VersionListFormat{ - // { - // Properties: &armelastic.VersionListProperties{ - // Version: to.Ptr("version1"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/elastic/armelastic/vmcollection_client.go b/sdk/resourcemanager/elastic/armelastic/vmcollection_client.go index ae9eaf9dd967..14751ceb9479 100644 --- a/sdk/resourcemanager/elastic/armelastic/vmcollection_client.go +++ b/sdk/resourcemanager/elastic/armelastic/vmcollection_client.go @@ -13,7 +13,7 @@ // 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. -// DO NOT EDIT. +// Code generated by @autorest/go. DO NOT EDIT. package armelastic @@ -37,11 +37,11 @@ type VMCollectionClient struct { } // NewVMCollectionClient creates a new instance of VMCollectionClient with the specified values. -// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewVMCollectionClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*VMCollectionClient, error) { - cl, err := arm.NewClient(moduleName+".VMCollectionClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -55,21 +55,27 @@ func NewVMCollectionClient(subscriptionID string, credential azcore.TokenCredent // Update - Update the vm details that will be monitored by the Elastic monitor resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-02-01-preview -// - resourceGroupName - The name of the resource group to which the Elastic resource belongs. +// Generated from API version 2023-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - monitorName - Monitor resource name // - options - VMCollectionClientUpdateOptions contains the optional parameters for the VMCollectionClient.Update method. func (client *VMCollectionClient) Update(ctx context.Context, resourceGroupName string, monitorName string, options *VMCollectionClientUpdateOptions) (VMCollectionClientUpdateResponse, error) { + var err error + const operationName = "VMCollectionClient.Update" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.updateCreateRequest(ctx, resourceGroupName, monitorName, options) if err != nil { return VMCollectionClientUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return VMCollectionClientUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return VMCollectionClientUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return VMCollectionClientUpdateResponse{}, err } return VMCollectionClientUpdateResponse{}, nil } @@ -94,11 +100,14 @@ func (client *VMCollectionClient) updateCreateRequest(ctx context.Context, resou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-02-01-preview") + reqQP.Set("api-version", "2023-11-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.Body != nil { - return req, runtime.MarshalAsJSON(req, *options.Body) + if err := runtime.MarshalAsJSON(req, *options.Body); err != nil { + return nil, err + } + return req, nil } return req, nil } diff --git a/sdk/resourcemanager/elastic/armelastic/vmcollection_client_example_test.go b/sdk/resourcemanager/elastic/armelastic/vmcollection_client_example_test.go deleted file mode 100644 index c8b7844d8145..000000000000 --- a/sdk/resourcemanager/elastic/armelastic/vmcollection_client_example_test.go +++ /dev/null @@ -1,43 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. 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. -// DO NOT EDIT. - -package armelastic_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/dbd896bc9a795bcb3ec7db0a340b517fd3059620/specification/elastic/resource-manager/Microsoft.Elastic/preview/2023-02-01-preview/examples/VMCollection_Update.json -func ExampleVMCollectionClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armelastic.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewVMCollectionClient().Update(ctx, "myResourceGroup", "myMonitor", &armelastic.VMCollectionClientUpdateOptions{Body: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/elastic/armelastic/vmhost_client.go b/sdk/resourcemanager/elastic/armelastic/vmhost_client.go index c8e898c4b78a..9dc48cace17b 100644 --- a/sdk/resourcemanager/elastic/armelastic/vmhost_client.go +++ b/sdk/resourcemanager/elastic/armelastic/vmhost_client.go @@ -13,7 +13,7 @@ // 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. -// DO NOT EDIT. +// Code generated by @autorest/go. DO NOT EDIT. package armelastic @@ -37,11 +37,11 @@ type VMHostClient struct { } // NewVMHostClient creates a new instance of VMHostClient with the specified values. -// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewVMHostClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*VMHostClient, error) { - cl, err := arm.NewClient(moduleName+".VMHostClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -54,8 +54,8 @@ func NewVMHostClient(subscriptionID string, credential azcore.TokenCredential, o // NewListPager - List the vm resources currently being monitored by the Elastic monitor resource. // -// Generated from API version 2023-02-01-preview -// - resourceGroupName - The name of the resource group to which the Elastic resource belongs. +// Generated from API version 2023-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - monitorName - Monitor resource name // - options - VMHostClientListOptions contains the optional parameters for the VMHostClient.NewListPager method. func (client *VMHostClient) NewListPager(resourceGroupName string, monitorName string, options *VMHostClientListOptions) *runtime.Pager[VMHostClientListResponse] { @@ -64,25 +64,20 @@ func (client *VMHostClient) NewListPager(resourceGroupName string, monitorName s return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *VMHostClientListResponse) (VMHostClientListResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listCreateRequest(ctx, resourceGroupName, monitorName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "VMHostClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, monitorName, options) + }, nil) if err != nil { return VMHostClientListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return VMHostClientListResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return VMHostClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -106,7 +101,7 @@ func (client *VMHostClient) listCreateRequest(ctx context.Context, resourceGroup return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-02-01-preview") + reqQP.Set("api-version", "2023-11-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/elastic/armelastic/vmhost_client_example_test.go b/sdk/resourcemanager/elastic/armelastic/vmhost_client_example_test.go deleted file mode 100644 index 16db21206dd7..000000000000 --- a/sdk/resourcemanager/elastic/armelastic/vmhost_client_example_test.go +++ /dev/null @@ -1,57 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. 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. -// DO NOT EDIT. - -package armelastic_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/dbd896bc9a795bcb3ec7db0a340b517fd3059620/specification/elastic/resource-manager/Microsoft.Elastic/preview/2023-02-01-preview/examples/VMHost_List.json -func ExampleVMHostClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armelastic.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewVMHostClient().NewListPager("myResourceGroup", "myMonitor", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.VMHostListResponse = armelastic.VMHostListResponse{ - // Value: []*armelastic.VMResources{ - // { - // VMResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualmachines/myVM"), - // }}, - // } - } -} diff --git a/sdk/resourcemanager/elastic/armelastic/vmingestion_client.go b/sdk/resourcemanager/elastic/armelastic/vmingestion_client.go index 4bfc79bc2ff3..74da9767203c 100644 --- a/sdk/resourcemanager/elastic/armelastic/vmingestion_client.go +++ b/sdk/resourcemanager/elastic/armelastic/vmingestion_client.go @@ -13,7 +13,7 @@ // 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. -// DO NOT EDIT. +// Code generated by @autorest/go. DO NOT EDIT. package armelastic @@ -37,11 +37,11 @@ type VMIngestionClient struct { } // NewVMIngestionClient creates a new instance of VMIngestionClient with the specified values. -// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewVMIngestionClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*VMIngestionClient, error) { - cl, err := arm.NewClient(moduleName+".VMIngestionClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -55,23 +55,30 @@ func NewVMIngestionClient(subscriptionID string, credential azcore.TokenCredenti // Details - List the vm ingestion details that will be monitored by the Elastic monitor resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-02-01-preview -// - resourceGroupName - The name of the resource group to which the Elastic resource belongs. +// Generated from API version 2023-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - monitorName - Monitor resource name // - options - VMIngestionClientDetailsOptions contains the optional parameters for the VMIngestionClient.Details method. func (client *VMIngestionClient) Details(ctx context.Context, resourceGroupName string, monitorName string, options *VMIngestionClientDetailsOptions) (VMIngestionClientDetailsResponse, error) { + var err error + const operationName = "VMIngestionClient.Details" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.detailsCreateRequest(ctx, resourceGroupName, monitorName, options) if err != nil { return VMIngestionClientDetailsResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return VMIngestionClientDetailsResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return VMIngestionClientDetailsResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return VMIngestionClientDetailsResponse{}, err } - return client.detailsHandleResponse(resp) + resp, err := client.detailsHandleResponse(httpResp) + return resp, err } // detailsCreateRequest creates the Details request. @@ -94,7 +101,7 @@ func (client *VMIngestionClient) detailsCreateRequest(ctx context.Context, resou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-02-01-preview") + reqQP.Set("api-version", "2023-11-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/elastic/armelastic/vmingestion_client_example_test.go b/sdk/resourcemanager/elastic/armelastic/vmingestion_client_example_test.go deleted file mode 100644 index f2b6bbc145ce..000000000000 --- a/sdk/resourcemanager/elastic/armelastic/vmingestion_client_example_test.go +++ /dev/null @@ -1,50 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. 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. -// DO NOT EDIT. - -package armelastic_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/dbd896bc9a795bcb3ec7db0a340b517fd3059620/specification/elastic/resource-manager/Microsoft.Elastic/preview/2023-02-01-preview/examples/VMIngestion_Details.json -func ExampleVMIngestionClient_Details() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armelastic.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewVMIngestionClient().Details(ctx, "myResourceGroup", "myMonitor", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.VMIngestionDetailsResponse = armelastic.VMIngestionDetailsResponse{ - // CloudID: to.Ptr("myid123"), - // IngestionKey: to.Ptr("Vmingeationkey"), - // } -}